https://github.com/ya332/react-feedback-popup
A highly customizable React component that I published to npm to get user feedback via a popup. You can also find the npm package here: https://www.npmjs.com/package/react-feedback-popup
https://github.com/ya332/react-feedback-popup
feedback feedback-component popup react user-feedback
Last synced: about 1 year ago
JSON representation
A highly customizable React component that I published to npm to get user feedback via a popup. You can also find the npm package here: https://www.npmjs.com/package/react-feedback-popup
- Host: GitHub
- URL: https://github.com/ya332/react-feedback-popup
- Owner: ya332
- License: mit
- Created: 2020-01-05T22:17:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-20T15:52:52.000Z (almost 5 years ago)
- Last Synced: 2025-04-10T23:43:50.194Z (about 1 year ago)
- Topics: feedback, feedback-component, popup, react, user-feedback
- Language: JavaScript
- Homepage: https://stackblitz.com/edit/react-feedback-popup
- Size: 1.62 MB
- Stars: 7
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://github.com/ya332/react-feedback-popup/blob/master/LICENSE.md)
[](https://www.npmjs.com/package/react-feedback-popup)
[](https://www.npmjs.com/package/react-feedback-popup)
[](https://travis-ci.org/ya332/react-feedback-popup)
[](https://github.com/prettier/prettier)
[](https://github.com/ya332/react-feedback-popup/blob/master/CONTRIBUTING.md)
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app) and [this React Feedback Component](https://www.npmjs.com/package/react-feedback)
# React-Feedback-Popup
React-Feedback-Popup is a blazingly fast and highly customizable component to get user feedback.
Collapsed Feedback Popup:

Expanded Feedback Popup:

# Live Demo
[Live Demo at StackBlitz](https://stackblitz.com/edit/react-feedback-popup)
### Features
- Gets user name, email, rating.
- User can determine the position (left or right)
- User can determine the header, body, and button text as well as the number of star ratings.
- Form validation (name, email, feedback and rating are required)
### Why
I needed a "feedback component" for my [projects](http://ya332.github.io#projects). Since I was unable to find one which met my requirements (and the fact that I generally enjoy re-inventing the wheel) this is what I came up with.
### Demo

### Installation
The preferred way of using the component is via NPM
```
npm install --save react-feedback-popup
```
### Usage
Here's a sample implementation that creates a custom popup on a dummy Create-React-App page.
```javascript
import React from 'react';
import logo from './logo.svg';
import FeedBack from 'react-feedback-popup';
import './App.css';
var axios = require('axios');
function App() {
return (
Edit src/App.js and save to reload.
Learn React
console.log("handleclose")}
handleSubmit={(data) =>
fetch('https://teamgogoemail.herokuapp.com/receiver_email@gmail.com', {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
method: 'POST', // or 'PUT'
body: JSON.stringify(data),
}).then((response) => {
if (!response.ok) {
return Promise.reject('Our servers are having issues! We couldn\'t send your feedback!');
}
response.json()
}).then(() => {
alert('Success!');
}).catch((error) => {
alert('Our servers are having issues! We couldn\'t send your feedback!', error);
})
}
handleButtonClick={() => console.log("handleButtonClick")}
/>
);
}
export default App;
```
As you can see, the fetch address is `https://teamgogoemail.herokuapp.com/receiver_email@gmail.com`. Here, you can provide use a service called https://teamgogoemail.herokuapp.com to forward the form submission to your email. There are also other 3rd party tools like formspree.io, email.js, mailchimp, Amazon Lambda functions etc to send emails once you get the user data via this React Popup Form.
### Options
| Option | Type | Default | Description |
| ------------------------------------- | -------- | ----------------------- | -------------------------------------------------------------- |
| [`position`](#tagsOption) | `String` | `right` | Position of the feedback pop. Possible options are `right` and `left` |
| [`numberOfStars`](#suggestionsOption) | `Integer` | `5` | Number of rating stars to be displayed. |
| [`headerText`](#delimiters) | `String` | `"Have Feedback? 📝?"` | Text to be displayed on header when pop is expanded. |
| [`bodyText`](#delimiters) | `String` | `"Need help? Have feedback? I'm a human so please be nice and I'll fix it!"` | Text to be displayed on on the body when pop is expanded |
| [`buttonText`](#delimiters) | `String` | `"Feedback? ☝️"` | Text to be displayed on header when pop is no expanded |
| [`handleClose`](#delimiters) | `Function` | `This function collapses the popup` | Called when `close button` is clicked. |
| [`handleSubmit`](#delimiters) | `Function` | `alert('Success!') or alert('Error')` | Called when `submit button` is clicked. |
| [`handleButtonClick`](#delimiters) | `Function` | `()` | Called when user clicks on Feedback button to expand the popup. |
Sample Usage:
```js
console.log("handleclose")}
handleSubmit={(data) =>
fetch('https://teamgogoemail.herokuapp.com/receiver_email@gmail.com', {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
method: 'POST', // or 'PUT'
body: JSON.stringify(data),
}).then((response) => {
if (!response.ok) {
return Promise.reject('Our servers are having issues! We couldn\'t send your feedback!');
}
response.json()
}).then(() => {
alert('Success!');
}).catch((error) => {
alert('Our servers are having issues! We couldn\'t send your feedback!', error);
})
}
handleButtonClick={() => console.log("handleButtonClick")}
/>
```
### Styling
style is a props to the Form component. You can overwrite the default values via passing CSS attributes.
For example,
```js
style={{zIndex:'2', marginLeft:'20px', position:'fixed'}}
```
### Dev
The component is written in ES6 and uses [Webpack](http://webpack.github.io/) as its build tool.
#### Set up instructions
```
git clone git@github.com:ya332/react-feedback-popup.git
cd react-feedback-popup
npm install
npm run start
```
open [http://localhost:3000](http://localhost:3000)
### Contributing
Got ideas on how to make this better? Open an issue [here!](https://github.com/ya332/react-feedback-popup/issues/new)
Issues, Pull Requests and all Comments are welcome!
[default-suggestions-filter-logic]: https://github.com/ya332/react-feedback-popup/blob/v4.0.1/lib/MadeBy.js#L83
[includes-polyfill]: https://github.com/mathiasbynens/String.prototype.includes