ember-select-light v2.0.0
This commit is contained in:
parent
31b2ed38b8
commit
50e2d61ba7
1 changed files with 65 additions and 81 deletions
|
@ -1,29 +1,85 @@
|
||||||
---
|
---
|
||||||
title: "ember-select-light"
|
title: "ember-select-light"
|
||||||
date: 2019-09-01
|
date: 2020-11-05
|
||||||
pinned: false
|
pinned: true
|
||||||
---
|
---
|
||||||
|
|
||||||
> Ember Select Light is an Ember Addon written data-down, actions up (DDAU) written with in test-driven development practices.
|
> Ember Select Light is an Ember Addon focused on simplicity. Just powerful enough to offer expected baseline functionality while being easy to implement, style, and make accessible.
|
||||||
|
|
||||||
<!--more-->
|
<!--more-->
|
||||||
|
|
||||||
[Fork from Github](https://github.com/q2ebanking/ember-select-light)
|
[Fork from Github](https://github.com/ember-a11y/ember-select-light)
|
||||||
|
|
||||||
# Ember-Select-Light
|
# Ember-Select-Light
|
||||||
|
|
||||||
 [](https://badge.fury.io/js/ember-select-light) [](https://emberobserver.com/addons/ember-select-light)
|
   [](https://badge.fury.io/js/ember-select-light) [](https://emberobserver.com/addons/ember-select-light)
|
||||||
|
|
||||||
Ember Select Light is an Ember Addon written [data-down, actions up (DDAU)](https://dockyard.com/blog/2016/11/18/checkbox-list-ember) written with in [test-driven development](https://www.agilealliance.org/glossary/tdd/) practices.
|
Ember-Select-Light is an Ember Addon focused on simplicity. Just powerful enough to offer expected baseline functionality while being easy to implement, style, and make accessible.
|
||||||
|
|
||||||
The intent is to provide a barebones `<select>` element that pairs well with modern Ember practices without styling assumptions. The result is a very functional, yet customizable, option for developers seeking a simple solution to select elements in their forms and apps.
|
This addon is [Octane ready](https://emberjs.com/editions/octane/) and follows [ember-component-pattern's for how to best write a Select Element](https://emberjs-1.gitbook.io/ember-component-patterns/form-components/select-element).
|
||||||
|
|
||||||
## Install
|
## Getting Started
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ember install ember-select-light
|
ember install ember-select-light
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Example Usage
|
||||||
|
|
||||||
|
```handlebars
|
||||||
|
<SelectLight
|
||||||
|
@value="turtle"
|
||||||
|
@options=(array "turtle" "tortoise")
|
||||||
|
@change={{action "handleChange"}} />
|
||||||
|
```
|
||||||
|
|
||||||
|
#### With an array of objects...
|
||||||
|
|
||||||
|
```handlebars
|
||||||
|
<SelectLight
|
||||||
|
@options=(array
|
||||||
|
(hash value="shortfin" label="Shortfin Shark")
|
||||||
|
(hash value="mako" label="Mako Shark")
|
||||||
|
) />
|
||||||
|
```
|
||||||
|
|
||||||
|
`value` and `label` will be the default object keys used unless `@valueKey="...` and/or `@displayKey="...` are used respectively, like so...
|
||||||
|
|
||||||
|
```handlebars
|
||||||
|
<SelectLight
|
||||||
|
@options=(array
|
||||||
|
(hash myValue="shortfin" myLabel="Shortfin Shark")
|
||||||
|
(hash myValue="mako" myLabel="Mako Shark")
|
||||||
|
)
|
||||||
|
@valueKey="myValue"
|
||||||
|
@displayKey="myLabel" />
|
||||||
|
```
|
||||||
|
|
||||||
|
#### As a Yield
|
||||||
|
|
||||||
|
```handlebars
|
||||||
|
<SelectLight>
|
||||||
|
<option value="clown">Clown Fish</option>
|
||||||
|
<option value="cat">Cat Fish</option>
|
||||||
|
</SelectLight>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Other arguments
|
||||||
|
|
||||||
|
Other arguments are spread onto the `<select ...attributes` as you'd expect, allowing you to use common attributes such as `disabled`, `tabindex` and of course `class`.
|
||||||
|
|
||||||
|
```handlebars
|
||||||
|
<SelectLight class="my-select" disabled="true" />
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Upgrading
|
||||||
|
|
||||||
|
See [the upgrading guide for how to upgrade from previous versions](./UPGRADE.md).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
* `ember serve`
|
* `ember serve`
|
||||||
|
@ -39,7 +95,7 @@ ember install ember-select-light
|
||||||
|
|
||||||
We love pull requests from everyone. By participating in this project, you agree to abide by the [code of conduct](./code-of-conduct.md) and is subject to the [project license](./LICENSE.md).
|
We love pull requests from everyone. By participating in this project, you agree to abide by the [code of conduct](./code-of-conduct.md) and is subject to the [project license](./LICENSE.md).
|
||||||
|
|
||||||
Clone this repo, make your changes with test coverage, push up a fork and [submit a pull request](https://github.com/hergaiety/ember-select-light/compare).
|
Clone this repo, make your changes with test coverage, push up a fork and [submit a pull request](https://github.com/sharpshark28/ember-select-light/compare).
|
||||||
|
|
||||||
Soon after some primary contributors will review your code and submit feedback and hopefully click the fancy green approve button. Any test and linting failures should be caught during the pull request continuous integration environment and human eyes here after.
|
Soon after some primary contributors will review your code and submit feedback and hopefully click the fancy green approve button. Any test and linting failures should be caught during the pull request continuous integration environment and human eyes here after.
|
||||||
|
|
||||||
|
@ -48,75 +104,3 @@ Soon after some primary contributors will review your code and submit feedback a
|
||||||
* `npm run test` (Runs `ember try:each` to test your addon against multiple Ember versions)
|
* `npm run test` (Runs `ember try:each` to test your addon against multiple Ember versions)
|
||||||
* or `ember test`
|
* or `ember test`
|
||||||
|
|
||||||
## Example Usage
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
this.setProperties({
|
|
||||||
myValue: 'turtle',
|
|
||||||
myOptions: ['turtle', 'tortoise'],
|
|
||||||
myAction: (event) => {
|
|
||||||
console.log(event.target.value);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
```handlebars
|
|
||||||
{{select-light value=myValue options=myOptions change=(action myAction)}}
|
|
||||||
```
|
|
||||||
|
|
||||||
### `value`
|
|
||||||
|
|
||||||
String that matches the selected `<option value="...`.
|
|
||||||
|
|
||||||
### `options`
|
|
||||||
|
|
||||||
#### As a Flat Array
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
['clam', 'starfish']
|
|
||||||
```
|
|
||||||
|
|
||||||
#### As an Array of Key/Value Objects
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
[
|
|
||||||
{ value: 'shortfin', label: 'Shortfin Shark' },
|
|
||||||
{ value: 'mako', label: 'Mako Shark' },
|
|
||||||
]
|
|
||||||
```
|
|
||||||
`value` and `label` will be the default keys used unless `valueKey="...` and/or `displayKey="...` are used respectively.
|
|
||||||
|
|
||||||
#### As a Yield
|
|
||||||
|
|
||||||
```handlebars
|
|
||||||
{{#select-light}}
|
|
||||||
<option value="clown">Clown Fish</option>
|
|
||||||
<option value="cat">Cat Fish</option>
|
|
||||||
{{/select-light}}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Handling Events
|
|
||||||
|
|
||||||
Any javascript event can be handled directly on the component such as `change` or `focusIn`. The `event` javascript object is passed along to be used however you desire.
|
|
||||||
|
|
||||||
Common usages are...
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
myAction(event) {
|
|
||||||
console.log(event.target.value); // Do something useful with the changed value
|
|
||||||
},
|
|
||||||
```
|
|
||||||
|
|
||||||
or to modify a property without a custom action...
|
|
||||||
|
|
||||||
```handlebars
|
|
||||||
{{select-light change=(action (mut myValue) value="target.value")}}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Other parameters
|
|
||||||
|
|
||||||
`disabled`, `tabindex`, and `class` work as you'd expect.
|
|
||||||
|
|
||||||
```handlebars
|
|
||||||
{{select-light disabled=true tabindex="0" class="my-dropdown"}}
|
|
||||||
```
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue