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

@nhsuk/user-feedback-form

v2.2.4

Published

A form for collecting user feedback

Downloads

313

Readme

User Feedback Form

A javascript plugin to add a user feedback form to your website.

You will also need a backend data store. See user-feedback-store.

Quickstart

npm

Install from npm

npm install @nhsuk/user-feedback-form

Use script in your javascript build

import userFeedbackForm from '@nhsuk/user-feedback-form';

userFeedbackForm({
    cssSelector: "#my-div-id",
    formEndpoint: "https://example.com/my-api-endpoint/",
    enableTextResponse: false,
});

script

If you do not have a node-based javascript frontend build, you can use the minified javascript distribution.

The latest javascript file can be found in github releases https://github.com/nhsuk/user-feedback-form/releases

<!-- in the html <head> -->
<script src="./user-feedback-form.min.js" defer></script>

...

<!-- where you want the form to appear -->
<div id="nhsuk-user-feedback-form" data-form-endpoint="https://example.com/endpoint/"></div>

Attributes

data-form-endpoint - (required) An HTTP data store endpoint to POST data to. Include the trailing slash data-enable-text-response - (optional) Include to enable text responses on the feedback form.

API

  • userFeedbackForm(settings)

Adds the user feedback form inside a <div> element. settings.cssSelector will be used to select the div from the DOM.

settings should be an object containing:

  • formEndpoint - (required) An HTTP data store endpoint to POST data to.
  • cssSelector - (optional) HTML selector insert the form into. '#nhsuk-user-feedback-form' by default.

Events

An onFeedback event is emitted when the user gives satisfied or unsatisfied feedback by clicking on the yes or no buttons.

You can listen to this event to trigger custom javascript code.

// Listen to the event on the container div
document.querySelector("#nhsuk-user-feedback-form").addEventListener('onFeedback', (event) => {
  // custom code using the boolean `isSatisfied` value.
  console.log(event.detail.isSatisfied)
});

Contributing

Development

Run npm install followed by npm start to start a development server. A test site will be available at http://localhost:8080/tests/example/

Style

For now, this app is very simple, so we don't use any libraries like Vue or React. The App class in src/index.js represents the app as a whole. Each screen has it's own class which can be instantiated and rendered with the render method when the screen should be displayed. The screen classes are responsible for screen-level interactions such as rendering, attaching event listeners and input validation.

Run npm run lint to run eslint code linting.

Tests

Run npm test to run all tests.