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

ember-cancelable-button

v0.2.1

Published

A button with a built-in cancel feature

Downloads

9

Readme

ember-cancelable-button

This add-on provides a cancelable-button component. When you click the button and you realize you don't want to take that action, you can just cancel it within the given timeout by clicking on the "cancel" part of the button.

Installation

  • git clone <repository-url> this repository
  • cd ember-cancelable-button
  • yarn install

Demo site

Check out examples at https://balinterdi.github.io/ember-cancelable-button.

Usage

At a minimum, the action to take should be passed in:

{{#cancelable-button action=(action 'submitProposal')}}
  Submit proposal to EmberConf
{{/cancelable-button}}

Customizing the button text

The component yields out whether the action is scheduled to be sent and the number of seconds it will be sent in.

You can, for example, use that to modify the button's text:

{{#cancelable-button action=(action 'submitProposal') as |isSending sendingIn|}}
  {{#if isSending}}
    Submitting in {{sendingIn}}...
  {{else}}
    Submit proposal to EmberConf
  {{/if}}
{{/cancelable-button}}

Custom delay

By default, the action is sent in 5 seconds, but a custom delay can be passed in for the number of seconds (only an integer value will be accepted).

{{#cancelable-button action=(action 'buyBook') delay=2 as |isSending sendingIn|}}
  {{#if isSending}}
    Buying in {{sendingIn}}...
  {{else}}
    Buy Rock & Roll with Ember.js
  {{/if}}
{{/cancelable-button}}

Running Tests

  • yarn test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

Coming features/improvements (so these don't work yet)

  • ~~Only show the X when the action is about to be taken (isSending)~~
  • ~~Have a default delay of 5 seconds~~
  • ~~Also yield the time left so that the button can be customized to display it ("Sending in 3, 2, 1... ")~~
  • ~~Guard against passing in non-integer values for delay~~
  • ~~While the cancel part is not shown, have rounded corners on the right side, too.~~
  • Let the button know when the action is being carried out (so there should be 3 states: start (same as canceled), scheduled-to-send, and sending. Maybe even a fourth one, which is sent. So a button could go even show "Submitted" (or "Bought") after the action has been carried out.
  • Pass an old-style (non-closure) action as the action
  • Better customization of the button style (pruning down the provided styles)
  • Allow using it with ember-concurrency if it's already a dependency of the project
  • Have a non-block form where the text when the button is about to send is the gerundive form of the verb: "Send proposal" => "Sending in 3, 2, 1"
  • Also yield a value that is true right after the action is taken so that it can be used for feedback: "Sent."
  • Allow customization of where the cancel part is shown (Gumroad puts it on the left, for example)