2.1.11 • Published 13 days ago

ember-ladda-button v2.1.11

Weekly downloads
67
License
MIT
Repository
github
Last release
13 days ago

ember-ladda-button

Ember wrapper for Ladda spinner buttons.

Installation

ember install ember-ladda-button

Usage

The button is themeless, so you will need to style it yourself.

Example usage:

<LaddaButton
  @action={{this.functionThatDoesNotReturnPromise}}
  @buttonStyle="zoom-out"
  @inFlight={{this.inFlight}}
  @text="My Button"
  @type="submit"
/>

<LaddaButton
  @action={{this.functionThatReturnsPromise}}
  @buttonStyle="expand-down"
  @longAction={{this.otherFunctionThatReturnsPromise}}
  @longDelay={{400}}
  as |longPress longProgress|
>
  {{#if longPress}}
    Long Press Text
  {{else}}
    Short Press Text
  {{/if}}

  {{longProgress}}% of the way to a long press!
</LaddaButton>

You can set the default spinner style attributes using the included service:

@service laddaButton;

constructor() {
  super(...arguments);

  this.laddaButton.buttonStyle = 'expand-left';
  this.laddaButton.spinnerColor = '#007eff';
  this.laddaButton.spinnerLines = 10;
  this.laddaButton.spinnerSize = 30;
}

The arguments you can pass are:

  • action - The function to call when the button is clicked. If this returns a promise, the button will start spinning when it is clicked, and stop spinning when the promise resolves or rejects. (defaults to undefined)

  • buttonStyle - How the spinner should appear while it is active - 'expand-left' | 'expand-right' | 'expand-up' | 'expand-down' | 'contract' | 'contract-overlay' | 'zoom-in' | 'zoom-out' | 'slide-left' | 'slide-right' | 'slide-up' | 'slide-down' - (defaults to 'expand-right')

  • disabled - The disabled attribute for the button element - (defaults to false)

  • inFlight - Whether the button should currently be spinning (alternative to returning a promise in action) - (defaults to false)

  • longAction - Identical to action except will be called after the button is held for longDelayms (see below) (defaults to undefined)

  • longDelay - How many milliseconds it should take before the button has been considered long pressed (see longAction). If no value is passed, long press functionality will be disabled. longPress and longProgress are yielded when passing a block for updating the appearance (defaults to undefined)

  • spinnerColor - The colour of the spinner - any valid CSS colour value - (defaults to #fff)

  • spinnerLines - The number of lines to be displayed in the spinner - (defaults to 12)

  • spinnerSize- Pixel dimensions of the spinner - (defaults to dynamic size based on the button height)

  • text - Text to be displayed on the button (alternative to passing a block) (defaults to undefined)

  • type - The type attribute for the button element - button | reset | submit - (defaults to button)

2.1.10

13 days ago

2.1.11

13 days ago

2.1.9

2 months ago

2.1.8

2 months ago

2.1.7

4 months ago

2.1.6

5 months ago

2.1.5

5 months ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.0.27

3 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago