GithubHelp home page GithubHelp logo

hasandikengul / microfeedback-button Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microfeedback/microfeedback-button

0.0 0.0 0.0 403 KB

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

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

License: MIT License

JavaScript 92.52% CSS 7.48%

microfeedback-button's Introduction

microfeedback-button

Current Version Build Status

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.

microfeedback-button's People

Contributors

sloria avatar greenkeeper[bot] avatar dependabot-preview[bot] avatar dependabot-support avatar greenkeeperio-bot avatar laurenbarker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.