Skip to content

Commit ed3fb21

Browse files
committed
API updates, using native ariaRole and NPM updates
- API uses `onclick` instead of `action` for strict closure action handling - Use native Ember `ariaRole` property - `package.json` dependencies
1 parent 76e1906 commit ed3fb21

28 files changed

+170
-112
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
66
### Updated
77
- `package.json` dependencies
88
- Integration tests now use standard DOM instead of jQuery
9+
- API uses `onclick` instead of `action` for strict closure action handling
10+
- Use native Ember `ariaRole` property
11+
- `package.json` dependencies
912

1013
### Removed
1114
- Acceptance tests

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Global optional parameters:
3838
### Menu
3939
Menu optional parameters:
4040
* `is-open` boolean - Set initial open menu state.
41-
* `action` string - The name of your upstream controller action to handle an icon click. Returned with 1 parameter `isOpen`, which is a boolean type indicating if the current state is open or closed.
41+
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isOpen`, which is a boolean type indicating if the current state is open or closed.
4242

4343
**animation**
4444
```handlebars
@@ -63,7 +63,7 @@ Menu optional parameters:
6363
### Grid
6464
Grid optional parameters:
6565
* `is-open` boolean - Set initial open grid state.
66-
* `action` string - The name of your upstream controller action to handle an icon click. Returned with 1 parameter `isOpen`, which is a boolean type indicating if the current state is open or closed.
66+
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isOpen`, which is a boolean type indicating if the current state is open or closed.
6767

6868
**animation**
6969
```handlebars
@@ -84,7 +84,7 @@ Grid optional parameters:
8484
### Add
8585
Add optional parameters:
8686
* `is-added` boolean - Set initial open add state.
87-
* `action` string - The name of your upstream controller action to handle an icon click. Returned with 1 parameter `isAdded`, which is a boolean type indicating if the current state is pending add.
87+
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isAdded`, which is a boolean type indicating if the current state is pending add.
8888

8989
**animation**
9090
```handlebars
@@ -105,7 +105,7 @@ Add optional parameters:
105105
### Remove
106106
Remove optional parameters:
107107
* `is-removed` boolean - Set initial open removed state.
108-
* `action` string - The name of your upstream controller action to handle an icon click. Returned with 1 parameter `isRemoved`, which is a boolean type indicating if the current state is pending remove.
108+
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isRemoved`, which is a boolean type indicating if the current state is pending remove.
109109

110110
**animation**
111111
```handlebars
@@ -134,7 +134,7 @@ Remove optional parameters:
134134
### Mail
135135
Mail optional parameters:
136136
* `is-open` boolean - Set initial open mail state.
137-
* `action` string - The name of your upstream controller action to handle an icon click. Returned with 1 parameter `isOpen`, which is a boolean type indicating if the current state is open or closed.
137+
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isOpen`, which is a boolean type indicating if the current state is open or closed.
138138

139139
```handlebars
140140
{{t-mail}}
@@ -152,7 +152,7 @@ Mail optional parameters:
152152
### Form
153153
Form optional parameters:
154154
* `is-searching` boolean - Set initial searching state.
155-
* `action` string - The name of your upstream controller action to handle an icon click. Returned with 1 parameter `isSearching`, which is a boolean type indicating if the current state is searching or not searching.
155+
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isSearching`, which is a boolean type indicating if the current state is searching or not searching.
156156

157157
```handlebars
158158
{{t-form}}
@@ -170,7 +170,7 @@ Form optional parameters:
170170
### Video
171171
Video optional parameters:
172172
* `is-playing` boolean - Set initial playing state.
173-
* `action` string - The name of your upstream controller action to handle an icon click. Returned with 1 parameter `isPlaying`, which is a boolean type indicating if the current state is playing or stopped.
173+
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isPlaying`, which is a boolean type indicating if the current state is playing or stopped.
174174

175175
```handlebars
176176
{{t-video}}

addon/components/base-transformicon.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Ember from 'ember';
22

33
const {
44
get,
5+
assert,
56
Component
67
} = Ember;
78

@@ -15,10 +16,9 @@ const {
1516
export default Component.extend({
1617
tagName: 'button',
1718

18-
attributeBindings: ['type', 'role', 'aria-label'],
19+
attributeBindings: ['type', 'label:aria-label'],
1920
type: 'button',
20-
role: undefined,
21-
'aria-label': undefined,
21+
label: null,
2222

2323
classNames: ['tcon'],
2424

@@ -38,6 +38,7 @@ export default Component.extend({
3838
3939
* `is-open`
4040
* `is-added`
41+
* `is-searching`
4142
* `is-removed`
4243
* `is-playing`
4344
@@ -51,15 +52,23 @@ export default Component.extend({
5152
/**
5253
This click handler does two things after retrieving the transformicons initital state property name.
5354
54-
- It will toggle the state of the transformicon.
55-
- It will also send a boolean action up to the consuming application when the transformicon is clicked. This action is returned with 1 parameter indicating if the current icon state is open/closed | added/removed | playing/stopped.
55+
- It will toggle the state of the transformicon by toggling the `initialState` property name.
56+
- It will also, if necessary, call an `onclick` closure action from to the consuming application's parent controller or component when the transformicon is clicked. This action is returned with 1 parameter indicating if the current icon state is open | added | searching | removed | playing.
5657
5758
@method click
5859
@public
5960
*/
6061
click() {
6162
let initStateProp = get(this, 'initialState');
63+
let onclick = get(this, 'onclick');
64+
6265
this.toggleProperty(initStateProp);
63-
this.sendAction('action', get(this, initStateProp));
66+
67+
if (onclick) {
68+
assert(`[ember-cli-transformicons] ${this.toString()} \`onclick\` action handler must be a valid closure action`, typeof onclick === 'function');
69+
70+
let boolInitStateProp = get(this, initStateProp);
71+
onclick(boolInitStateProp);
72+
}
6473
}
6574
});

addon/components/t-add.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const animationTypeTable = EmberObject.create({
2121
* `animation` string - Set the add animation type.
2222
* `a` string - Shorthand alias for `animation`.
2323
* `is-added` boolean - Set initial open added state.
24-
* `action` string - The name of your controller/route action to handle an icon click. Returned with 1 parameter `isAdded`, which is a boolean type indicating if the current state is pending add.
24+
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isAdded`, which is a boolean type indicating if the current state is pending add.
2525
2626
Available `animation` types:
2727
* minus
@@ -45,7 +45,7 @@ const animationTypeTable = EmberObject.create({
4545
export default BaseTransformicon.extend({
4646
layout,
4747

48-
'aria-label': 'add item',
48+
label: 'add item',
4949

5050
classNames: ['tcon-plus'],
5151
classNameBindings: ['animationType', 'isAdded'],
@@ -59,7 +59,7 @@ export default BaseTransformicon.extend({
5959
animationType: computed('animation', {
6060
get() {
6161
let anim = get(this, 'animation');
62-
return animationTypeTable.get(anim) || animationTypeTable.get(defaultAnimation);
62+
return get(animationTypeTable, anim) || get(animationTypeTable, defaultAnimation);
6363
}
6464
}),
6565
/**

addon/components/t-form.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const {
1212
1313
PUBLIC - Optional parameters:
1414
* `is-searching` boolean - Set initial searching state.
15-
* `action` string - The name of your controller/route action to handle an icon click. Returned with 1 parameter `isSearching`, which is a boolean type indicating if the current state is searching or not searching.
15+
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isSearching`, which is a boolean type indicating if the current state is searching or not searching.
1616
1717
Examples:
1818
@@ -30,7 +30,7 @@ const {
3030
export default BaseTransformicon.extend({
3131
layout,
3232

33-
'aria-label': 'toggle search',
33+
label: 'toggle search',
3434

3535
classNames: ['tcon-search--xcross'],
3636
classNameBindings: ['isSearching'],

addon/components/t-grid.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const animationTypeTable = EmberObject.create({
2121
* `animation` string - Set the grid animation type.
2222
* `a` string - Shorthand alias for `animation`.
2323
* `is-open` boolean - Set initial open grid state.
24-
* `action` string - The name of your controller/route action to handle an icon click. Returned with 1 parameter `isOpen`, which is a boolean type indicating if the current state is open or closed.
24+
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isOpen`, which is a boolean type indicating if the current state is open or closed.
2525
2626
Available `animation` types:
2727
* rearrange
@@ -45,7 +45,7 @@ const animationTypeTable = EmberObject.create({
4545
export default BaseTransformicon.extend({
4646
layout,
4747

48-
'aria-label': 'toggle grid',
48+
label: 'toggle grid',
4949

5050
classNames: ['tcon-grid'],
5151
classNameBindings: ['animationType', 'isOpen'],
@@ -59,7 +59,7 @@ export default BaseTransformicon.extend({
5959
animationType: computed('animation', {
6060
get() {
6161
let anim = get(this, 'animation');
62-
return animationTypeTable.get(anim) || animationTypeTable.get(defaultAnimation);
62+
return get(animationTypeTable, anim) || get(animationTypeTable, defaultAnimation);
6363
}
6464
}),
6565
/**

addon/components/t-loader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export default Component.extend({
2323

2424
tagName: 'span',
2525

26-
attributeBindings: ['aria-label'],
27-
'aria-label': 'loading',
26+
attributeBindings: ['label:aria-label'],
27+
label: 'loading',
2828

2929
classNames: ['tcon-loader--spinner360']
3030
});

addon/components/t-mail.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import BaseTransformicon from './base-transformicon';
55
const {
66
get,
77
computed,
8-
computed: { alias }
8+
computed: { reads }
99
} = Ember;
1010

1111
/**
1212
Transformicon Mail component.
1313
1414
PUBLIC - Optional parameters:
1515
* `is-open` boolean - Set initial open mail state.
16-
* `action` string - The name of your controller/route action to handle an icon click. Returned with 1 parameter `isOpen`, which is a boolean type indicating if the current state is open or closed.
16+
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isOpen`, which is a boolean type indicating if the current state is open or closed.
1717
1818
Examples:
1919
@@ -31,8 +31,8 @@ const {
3131
export default BaseTransformicon.extend({
3232
layout,
3333

34-
role: alias('type'),
35-
'aria-label': 'open mailbox',
34+
ariaRole: reads('type'),
35+
label: 'open mailbox',
3636

3737
classNames: ['tcon-mail--envelope'],
3838
classNameBindings: ['isOpen'],

addon/components/t-menu.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const animationTypeTable = EmberObject.create({
2525
* `animation` string - Set the menu animation type.
2626
* `a` string - Shorthand alias for `animation`.
2727
* `is-open` boolean - Set initial open menu state.
28-
* `action` string - The name of your controller/route action to handle an icon click. Returned with 1 parameter `isOpen`, which is a boolean type indicating if the current state is open or closed.
28+
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isOpen`, which is a boolean type indicating if the current state is open or closed.
2929
3030
Available `animation` types:
3131
* butterfly
@@ -53,7 +53,7 @@ const animationTypeTable = EmberObject.create({
5353
export default BaseTransformicon.extend({
5454
layout,
5555

56-
'aria-label': 'toggle menu',
56+
label: 'toggle menu',
5757

5858
classNameBindings: ['animationType', 'isOpen'],
5959
/**
@@ -66,7 +66,7 @@ export default BaseTransformicon.extend({
6666
animationType: computed('animation', {
6767
get() {
6868
let anim = get(this, 'animation');
69-
return animationTypeTable.get(anim) || animationTypeTable.get(defaultAnimation);
69+
return get(animationTypeTable, anim) || get(animationTypeTable, defaultAnimation);
7070
}
7171
}),
7272
/**

addon/components/t-remove.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const animationTypeTable = EmberObject.create({
2424
* `animation` string - Set the menu animation type.
2525
* `a` string - Shorthand alias for `animation`.
2626
* `is-removed` boolean - Set initial open removed state.
27-
* `action` string - The name of your controller/route action to handle an icon click. Returned with 1 parameter `isRemoved`, which is a boolean type indicating if the current state is pending remove.
27+
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isRemoved`, which is a boolean type indicating if the current state is pending remove.
2828
2929
Available `animation` types:
3030
* check
@@ -51,7 +51,7 @@ const animationTypeTable = EmberObject.create({
5151
export default BaseTransformicon.extend({
5252
layout,
5353

54-
'aria-label': 'remove item',
54+
label: 'remove item',
5555

5656
classNames: ['tcon-remove'],
5757
classNameBindings: ['animationType', 'isRemoved'],
@@ -65,7 +65,7 @@ export default BaseTransformicon.extend({
6565
animationType: computed('animation', {
6666
get() {
6767
let anim = get(this, 'animation');
68-
return animationTypeTable.get(anim) || animationTypeTable.get(defaultAnimation);
68+
return get(animationTypeTable, anim) || get(animationTypeTable, defaultAnimation);
6969
}
7070
}),
7171
/**

0 commit comments

Comments
 (0)