Skip to content

Instantly share code, notes, and snippets.

@webOS101
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webOS101/353ebcc64124da89ed2d to your computer and use it in GitHub Desktop.
Save webOS101/353ebcc64124da89ed2d to your computer and use it in GitHub Desktop.
Powered Light
enyo.ready(function() {
enyo.kind({
name: 'Light',
color: 'yellow',
style: 'width: 50px; height: 50px; border-radius: 50%;',
create: function() {
this.inherited(arguments);
this.colorChanged();
},
colorChanged: function(oldValue) {
this.applyStyle('background-color', this.color);
}
});
enyo.kind({
name: 'PoweredLight',
kind: 'Light',
powered: true,
handlers: {
'ontap': 'tapped'
},
create: function() {
this.inherited(arguments);
this.poweredChanged();
},
tapped: function(sender, event) {
this.set('powered', !this.get('powered'));
},
poweredChanged: function(oldValue) {
this.applyStyle('opacity', this.powered ? '1' : '0.2');
}
});
enyo.kind({
name: 'TrafficLight',
components: [
{ name: 'stop', kind: 'PoweredLight', color: 'red' },
{ name: 'slow', kind: 'PoweredLight', color: 'yellow' },
{ name: 'go', kind: 'PoweredLight', color: 'green' }
]
});
new enyo.Application({ name: 'app', view: 'TrafficLight' });
});
name: Powered Light
description: A light that can be powered on and off
authors:
- Roy Sutton
normalize_css: no
@webOS101
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment