Skip to content

Commit

Permalink
fix: Allow theme on switch, update dummy app more
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Radchenko authored and knownasilya committed May 18, 2017
1 parent 973e47d commit 5174457
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
10 changes: 9 additions & 1 deletion addon/components/x-toggle-switch/component.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import Ember from 'ember';
import layout from './template';

const { computed } = Ember;

export default Ember.Component.extend({
layout,
tagName: ''
tagName: '',

themeClass: computed('theme', function () {
var theme = this.get('theme') || 'default';

return 'x-toggle-' + theme;
}),
});
6 changes: 0 additions & 6 deletions addon/components/x-toggle/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ const ToggleComponent = Ember.Component.extend({
// private
toggled: computed.readOnly('value'),

themeClass: computed('theme', function () {
var theme = this.get('theme') || 'default';

return 'x-toggle-' + theme;
}),

forId: computed(function () {
return this.get('elementId') + '-x-toggle';
}),
Expand Down
4 changes: 2 additions & 2 deletions addon/components/x-toggle/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
switch=(component 'x-toggle-switch' onClick=(action 'onClick')
onChangeValue=(action 'setToValue')
value=value
themeClass=themeClass
theme=theme
size=size
disabled=disabled
toggled=toggled
Expand Down Expand Up @@ -32,7 +32,7 @@
{{x-toggle-switch onClick=(action 'onClick')
onChangeValue=(action 'setToValue')
value=value
themeClass=themeClass
theme=theme
size=size
disabled=disabled
toggled=toggled
Expand Down
20 changes: 14 additions & 6 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,23 @@
<h2>Block Form</h2>
<pre>
\{{#x-toggle value=value showLabels=true onToggle=(action (mut value)) as |toggle|}}
\{{toggle.offLabel}}
\{{toggle.onLabel}}
\{{toggle.switch}}
\{{#toggle.offLabel as |label|}}
&lt;b&gt;\{{label}}&lt;/b&gt;
\{{/toggle.offLabel}}
\{{#toggle.onLabel as |label|}}
&lt;b&gt;\{{label}}&lt;/b&gt;
\{{/toggle.onLabel}}
\{{toggle.switch theme='flip' onLabel='diff on' offLabel='diff off'}}
\{{/x-toggle}}
</pre>
<span class='flexy'>
{{#x-toggle value=value showLabels=true onToggle=(action (mut value)) as |toggle|}}
{{toggle.offLabel}}
{{toggle.onLabel}}
{{toggle.switch}}
{{#toggle.offLabel as |label|}}
<b>{{label}}</b>
{{/toggle.offLabel}}
{{#toggle.onLabel as |label|}}
<b>{{label}}</b>
{{/toggle.onLabel}}
{{toggle.switch theme='flip' onLabel='diff on' offLabel='diff off'}}
{{/x-toggle}}
</span>

0 comments on commit 5174457

Please sign in to comment.