New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@gavant/ember-button-spinner

Package Overview
Dependencies
Maintainers
6
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gavant/ember-button-spinner

The default blueprint for ember-cli addons.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
increased by700%
Maintainers
6
Weekly downloads
 
Created
Source

@gavant/ember-button-spinner

A button component built on @gavant/ember-button-basic that accepts an action that returns a promise, and displays a spinner while waiting for the promise to resolve. Also optionally shows a "success" icon if the promise resolves, and "shakes" if the promise rejects.

Compatibility

  • Ember.js v3.12 or above
  • Ember CLI v2.13 or above
  • Node.js v10 or above

Installation

ember install @gavant/ember-button-spinner

To use the addon styles, you must use SASS:

ember install ember-cli-sass

(Upon addon installation, an import statement will be added to your app.scss)

NOTE: This addon uses FontAwesome 5 (@fortawesome/ember-fontawesome) for icon support. However it does NOT install any icon set packages. You must install these separately, following the addon's installation guide, e.g.

yarn add --dev @fortawesome/free-solid-svg-icons

Usage

An example <ButtonSpinner> usage, with all available arguments used. Note that all arguments provided by the base <Button> component are supported too, but are not all listed here. See the addon's usage documentation for details. None of the component arguments are required.

<ButtonSpinner
    @action={{function}}
    @label={{string}}
    @isSpinning={{boolean}}
    @showSuccess={{boolean}}
    @showError={{boolean}}
    @loadingClass={{string}}
    @successClass={{string}}
    @successAnimationClass={{string}}
    @successIcon={{string}}
    @successIconClass={{string}}
/>

{{!-- block form is supported too --}}
<ButtonSpinner @action={{this.someAction}}>
    Look ma, block content!
</Button>

In order for the button to show the spinner animation, the function passed to @action must return a Promise (or be an async function). If the returned promise resolves or rejects with another function, the component will invoke that function as a callback when the button's success or error animation completes. This can be useful in situations where you want to execute some logic after the animation is displayed to the user, such as transitioning to another page. For example:

@action
async saveAndTransition() {
    await this.someAsyncSaveLogic();
    //resolve with a function that will be executed once the success animation finishes
    return () => this.transitionToRoute('somewhere.else');
}
<ButtonSpinner
    @action={{this.saveAndTransition}}
    @label="Transitions after success!"
/>

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 31 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc