Last active
January 26, 2016 22:05
-
-
Save adamesque/9021a8e1ff7ab51b7efd to your computer and use it in GitHub Desktop.
Revisions
-
adamesque revised this gist
Jan 26, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,2 @@ <button>Button</button> <label>{{currentLabel}}</label> -
adamesque created this gist
Jan 26, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ import Ember from 'ember'; export default Ember.Controller.extend({ appName:'Ember Twiddle', isActive: false, actions: { toggle() { this.toggleProperty('isActive'); } } }); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ <h1>Welcome to {{appName}}</h1> <br> <br> {{toggle-button isActive=isActive action='toggle'}} <br> <br> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ body { margin: 12px 16px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12pt; } button { background: lightgrey; border: none; border-radius: 4px; font-size: 20px; padding: 0.5em 1em; transition: background 200ms ease-in-out; } .is-active button { background: hotpink; } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ import Ember from 'ember'; const { computed, computed: { reads, }, observer, run: { cancel, later, } } = Ember; export default Ember.Component.extend({ classNameBindings: ['isActive'], isActive: false, defaultLabel: 'Label', currentLabel: reads('defaultLabel'), updateLabel: observer('isActive', function () { let isActive = this.get('isActive'); if (isActive) { this.set('currentLabel', 'ON'); } else { this.set('currentLabel', 'OFF'); } this._timer = later(this, 'resetLabel', 1000); }), resetLabel() { this.set('currentLabel', this.get('defaultLabel')); }, willDestroy() { if (this._timer) { cancel(this._timer); } }, click() { this.sendAction(); } }); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ <label>{{currentLabel}}</label><br> <button>Button</button> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ { "version": "0.5.0", "EmberENV": { "FEATURES": {} }, "options": { "enable-testing": false }, "dependencies": { "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", "ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js", "ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js", "ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js" } }