npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@opiumteam/react-slack-feedback

v3.0.0

Published

React component for gathering user feedback to send to slack.

Downloads

13

Readme

React Slack Feedback

View live demo

Customizable React component for gathering user feedback to send to slack.

Build Status XO code style

Usage

Install with yarn or npm:

yarn add react-slack-feedback styled-components

To use the component, import it and render in your app's global component, or individual components (if you don't want it on every page).

NOTE: Your Slack Webhook URL should never be available on the front end. For this reason you must have a server which sends the request to slack. This component will produce the JSON object to send to Slack but it won't send the request for you.

import SlackFeedback, { themes } from 'react-slack-feedback'

ReactDOM.render(
  <SlackFeedback
    channel="#general"
    theme={themes.dark} // (optional) See src/themes/default for default theme
    user="Slack Feedback" // The logged in user (default = "Unknown User")
    onImageUpload={(image, success,error) => 
      uploadImage(image)
        .then(({ url }) => success(url))
        .catch(error)
    }
    onSubmit={(payload, success, error) => 
      sendToServer(payload)
        .then(success)
        .catch(error)
     }
  />,
  document.getElementById('root')
)

function sendToServer(payload, success, error) {
  return fetch('/api/slack', {
    method: 'POST',
    body: JSON.stringify(payload)
  })
  .then(success)
  .catch(error)
}

function uploadImage(image, success, error) {
  var form = new FormData()
  form.append('image', image)

  return fetch('/api/upload', { method: 'POST', data: form })
    .then(({ url }) => success(url))
    .catch(err => error(err))
  )
}

Props

| Prop | Type | Default | Required | Description | | ------------------- | ----------------------------------------- | --------------------- | :------: | ---------------------------------------------------------------------------------------------------- | | channel | String | | | For visual purposes - changing this value will not change the slack channel. | | defaultSelectedType | String | | | | disabled | Boolean | false | | Disable the component entirely. Returns null. Can be used to disable the component on specific pages | | errorTimeout | Number | 8000 (8 seconds) | | | | feedbackTypes | Array<{ value: String, label: String }> | See code | | | | icon | Function | () => <SlackIcon /> | | | | onClose | Function | | | | onImageUpload | Function | | | Method that will be called with a file argument | | onOpen | Function | | | | onSubmit | Function | | required | A JSON payload object will be returned when the user submits the form. | | sentTimeout | Number | 5000 (5 seconds) | | | | showChannel | Boolean | true | | | showIcon | Boolean | true | | | theme | Object | See themes directory | | | translations | Object | See translations file | | | user | String | "Unknown User" | | The logged in user's name (if applicable) |

NOTE: All slack channels are lowercase. The string should be identical to the channel name e.g '#feedback'

Callback Functions

| Function | Arguments | Description | | ------------- | ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | | onSubmit | (payload: Object, success: Function, error: Function) | Called when the user hits send. Use the success callback to indicate that the request was successful. Use the error callback to indicate failure. | | onImageUpload | (image: Object, success: Function, error: Function) | Called when an image has been uploaded. |


Contributing

Running Locally

To run this module locally:

  1. Clone the repo:
git clone https://github.com/markmur/react-slack-feedback.git
  1. Install the node modules
yarn
  1. Run the demo:
WEBHOOK_URL='YOUR_SLACK_WEBHOOK_URL' yarn start

This will bundle the client with parcel and startup a simple express server.

The server will be listening on http://localhost:8080

The client will be listening on http://localhost:1234

Open http://localhost:1234 to view the demo