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

react-feedback-popup

v1.3.1

Published

A highly customizable React component to get user feedback via a popup

Downloads

77

Readme

MIT NPM Version npm downloads build status code style: prettier PRs Welcome

This project was bootstrapped with Create React App and this React Feedback Component

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

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. 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.

import React from 'react';
import logo from './logo.svg';
import FeedBack from 'react-feedback-popup';
import './App.css';

function App() {
	return (
		<div className="App">
			<header className="App-header">
				<img src={logo} className="App-logo" alt="logo" />
				<p>
					Edit <code>src/App.js</code> and save to reload.
        </p>
				<a
					className="App-link"
					href="https://reactjs.org"
					target="_blank"
					rel="noopener noreferrer"
				>
					Learn React
        </a>
			</header>
			<FeedBack
				style={{zIndex:'2', marginLeft:'20px', position:'fixed'}}
				position="left"
				numberOfStars={5}
				headerText="Hello"
				bodyText="Custom Body test"
				buttonText="This is also custom"
				handleClose={() => console.log("handleclose")}
				handleSubmit={(data) => 
					fetch('xxxxxx', {
						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")}
			/>
		</div>
	);
}

export default App;

As you can see, the fetch address is xxxxxx. Here, you can provide a URL to send your POST request, so that the form can be submitted to this link. There are 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.

Options

| Option | Type | Default | Description | | ------------------------------------- | -------- | ----------------------- | -------------------------------------------------------------- | | position | String | right | Position of the feedback pop. Possible options are right and left | | numberOfStars | Integer | 5 | Number of rating stars to be displayed. | | headerText | String | "Have Feedback? 📝?" | Text to be displayed on header when pop is expanded. | | bodyText | 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 | String | "Feedback? ☝️" | Text to be displayed on header when pop is no expanded | | handleClose | Function | This function collapses the popup | Called when close button is clicked. | | handleSubmit | Function | alert('Success!') or alert('Error') | Called when submit button is clicked. | | handleButtonClick | Function | () | Called when user clicks on Feedback button to expand the popup. |

Sample Usage:

<FeedBack
	style={{zIndex:'2', marginLeft:'20px', position:'fixed'}}
	position="left"
	numberOfStars={5}
	headerText="Hello"
	bodyText="Custom Body test"
	buttonText="This is also custom"
	handleClose={() => console.log("handleclose")}
	handleSubmit={(data) => 
		fetch('https://formspree.io/xxxxxx', {
			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,

style={{zIndex:'2', marginLeft:'20px', position:'fixed'}}

Dev

The component is written in ES6 and uses Webpack as its build tool.

Set up instructions

git clone [email protected]:ya332/react-feedback-popup.git
cd react-feedback-popup
npm install
npm run start

open http://localhost:3000

Contributing

Got ideas on how to make this better? Open an issue here! Issues, Pull Requests and all Comments are welcome!