0.0.8 • Published 5 years ago

bg-button-group v0.0.8

Weekly downloads
103
License
MIT
Repository
github
Last release
5 years ago

Build Status

Bg-button-group

Lightweight component for groupping buttons and sending 1 action when the user clicks on one of the buttons.

Value can be any of data types even ember objects.

Here at British Gas we use bootstrap therefore the rendered buttons have the added btn class.

Example:

Assume there is a buttons array like:

  buttons: [{id: 1, label: 'apple'}, {id: 2, label: 'melon'}],

Template:

      {{#bg-button-group onButtonClick=(action 'onButtonClickHandler') selectedValue=selectedValue as |bg|}}
        {{#each buttons as |btn|}}
          {{#bg.button class="btn-success" value=btn}}
            {{btn.label}}
          {{/bg.button}}
        {{/each}}
      {{/bg-button-group}}

If you want to use as bootstrap botton group feature, simple add btn-group (or similar) class to the component.

      {{#bg-button-group class="btn-group" onButtonClick=(action 'onButtonClickHandler') selectedValue=selectedValue as |bg|}}

Handling event (catching the clicked value)

set onButtonClick action which passes the value set to the button previously

Preselected button

Use selectedValue attrinbute and pass the same value what you passed to the button.

Rendered html

<div>
  <button class="btn text-center bg-button" id="ember123">a label</button>
  <button class="btn text-center bg-button" id="ember125">another label</button>
</div>

DEMO page here: (https://britishgas-engineering.github.io/bg-button-group)

Installation

  • ember install bg-button-group

Running

Running Tests

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

Building

  • ember build

For more information on using ember-cli, visit http://ember-cli.com/.

0.0.8

5 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.1

7 years ago