-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dummy app and split into components, block form
Allows using the `{{x-toggle}}` in block form.
- Loading branch information
1 parent
fd53ec4
commit 8b295cf
Showing
12 changed files
with
195 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Ember from 'ember'; | ||
import layout from './template'; | ||
|
||
const { computed } = Ember; | ||
|
||
export default Ember.Component.extend({ | ||
layout, | ||
tagName: '', | ||
|
||
type: computed('value', { | ||
get() { | ||
let value = this.get('value'); | ||
return value ? 'on' : 'off'; | ||
} | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{#if show}} | ||
<label id='{{type}}-label-{{switchId}}' for={{switchId}} class="toggle-text toggle-prefix {{type}}-label" | ||
onclick={{action onClick value}}> | ||
{{label}} | ||
</label> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Ember from 'ember'; | ||
import layout from './template'; | ||
|
||
export default Ember.Component.extend({ | ||
layout, | ||
tagName: '' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<span class="x-toggle-container {{size}}{{if value ' x-toggle-container-checked'}}{{if disabled ' x-toggle-container-disabled'}}"> | ||
<input id="{{forId}}" | ||
name={{name}} | ||
type='checkbox' | ||
checked={{toggled}} | ||
changed={{action onChangeValue value='target.checked'}} | ||
class='x-toggle' | ||
disabled={{disabled}}> | ||
|
||
<div id="x-toggle-visual-{{forId}}" | ||
class="x-toggle-btn {{themeClass}} {{size}}{{if disabled ' x-toggle-disabled'}}" | ||
onclick={{action onClick}} | ||
data-tg-on={{onLabel}} | ||
data-tg-off={{offLabel}} | ||
for={{forId}} | ||
aria-role="checkbox" | ||
aria-owns={{forId}}> | ||
</div> | ||
</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,49 @@ | ||
{{#if showLabels}} | ||
<label id='off-label-{{elementId}}' for={{forId}} class="toggle-text toggle-prefix off-label" | ||
onclick={{action 'setToValue' false}}> | ||
{{offLabel}} | ||
</label> | ||
{{/if}} | ||
|
||
<span class="x-toggle-container {{size}}{{if value ' x-toggle-container-checked'}}{{if disabled ' x-toggle-container-disabled'}}"> | ||
<input id="input-{{elementId}}" | ||
name={{name}} | ||
type='checkbox' | ||
checked={{toggled}} | ||
changed={{action 'setToValue' value='target.checked'}} | ||
class='x-toggle' | ||
disabled={{disabled}}> | ||
{{#if hasBlock}} | ||
{{yield (hash | ||
switch=(component 'x-toggle-switch' onClick=(action 'onClick') | ||
onChangeValue=(action 'setToValue') | ||
value=value | ||
themeClass=themeClass | ||
size=size | ||
disabled=disabled | ||
toggled=toggled | ||
name=name | ||
offLabel=offLabel | ||
onLabel=onLabel | ||
forId=forId) | ||
offLabel=(component 'x-toggle-label' onClick=(action 'setToValue') | ||
label=offLabel | ||
value=false | ||
show=showLabels | ||
switchId=forId) | ||
onLabel=(component 'x-toggle-label' onClick=(action 'setToValue') | ||
label=onLabel | ||
value=true | ||
show=showLabels | ||
switchId=forId) | ||
)}} | ||
{{else}} | ||
{{x-toggle-label onClick=(action 'setToValue') | ||
label=offLabel | ||
value=false | ||
show=showLabels | ||
switchId=forId}} | ||
|
||
<div id="visual-{{elementId}}" | ||
class="x-toggle-btn {{themeClass}} {{size}}{{if disabled ' x-toggle-disabled'}}" | ||
onclick={{action 'onClick'}} | ||
for="input-{{elementId}}" | ||
aria-role="checkbox" | ||
aria-owns="input-{{elementId}}"> | ||
</div> | ||
</span> | ||
{{x-toggle-switch onClick=(action 'onClick') | ||
onChangeValue=(action 'setToValue') | ||
value=value | ||
themeClass=themeClass | ||
size=size | ||
disabled=disabled | ||
toggled=toggled | ||
name=name | ||
offLabel=offLabel | ||
onLabel=onLabel | ||
forId=forId}} | ||
|
||
{{#if showLabels}} | ||
<label id='on-label-{{elementId}}' for="input-{{elementId}}" class="toggle-text toggle-postfix {{size}} on-label" | ||
onclick={{action 'setToValue' true}}> | ||
{{onLabel}} | ||
</label> | ||
{{x-toggle-label onClick=(action 'setToValue') | ||
label=onLabel | ||
value=true | ||
show=showLabels | ||
switchId=forId}} | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'ember-toggle/components/x-toggle-label/component'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'ember-toggle/components/x-toggle-switch/component'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.