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

microfeedback-button

v1.1.0

Published

A simple feedback button/widget. Use together with a microfeedback backend.

Downloads

288

Readme

microfeedback-button

Current Version Build Status Greenkeeper badge

A simple widget for capturing user feedback. Use together with a microfeedback backend such as microfeedback-github.

Uses sweetalert2 under the hood to display responsive, customizable, and accessible input dialogs.

Documentation (with demos)

https://microfeedback.js.org/ui-components/microfeedback-button/

API

microfeedback([elem], [options])

  • elem: The HTMLElement to bind to. If not given, the default button will be rendered.
  • options
    • url: URL for your microfeedback backend. If null, feedback will be logged to the console. May also be a function that receives btn and result (the user input) as arguments and returns a URL. Default: null
    • buttonText: Text to display in the default button. Default: 'Feedback'
    • buttonAriaLabel: aria-label for the default button. Default: 'Send feedback'
    • title: Title to display in the dialog. Default: 'Send feedback'
    • placeholder: Placeholder text in the dialog input. Default: 'Describe your issue or share your ideas'
    • backgroundColor: Background color for the default button. Default: '#3085d6'
    • color: Color for the default button text. Default: '#fff'
    • animation: Enable animations. Default: true
    • showDialog: Function that displays a sweetalert2 dialog. Returns a Promise that resolves to the input result. Use return btn.alert(...) to display the dialog.
    • getPayload: Function that receives btn (the MicroFeedbackButton instance) and input result and returns the request payload to send to the microfeedback backend.
    • preSend: Function that receives btn (the MicroFeedbackButton instance) and input result. This is called before sending the request to the microfeedback backend. Useful for displaying a "Thank you" message with return btn.alert(...).
    • optimistic: If true, display success message immediately after user submits input (don't wait for request to finish). If false, wait until request finishes to show message (use together with onSuccess to customize message). Default: true
    • showSuccessDialog: Function that receives btn (the MicroFeedbackButton instance) and input result and displays a dialog using return btn.alert(...).
    • onSuccess: Function called when request succeeds. Receives btn (the MicroFeedbackButton instance) and input result. By default, calls options.showSuccessDialog(btn, input) if optimistic is false, otherwise noop.
    • onFailure: Function called when request fails. Receives btn (the MicroFeedbackButton instance). Default: noop

Additionally, any valid sweetalert2 option may be passed to configure the input dialog.

Methods

btn.alert(...args)

Display a sweetalert2 dialog. This is equivalent to the swal function from sweetalert2.

Developing

  • npm install
  • To run tests: npm test
  • To run tests in watch mode: npm test -- --watch
  • To run the example: npm run dev

License

MIT Licensed.