First Light
A simple yellow light author(s): Roy Sutton
by gorillawit
CoffeeScript
enyo.kind
name: "Light"
published:
color: "yellow"
style: "width: 50px; height: 50px; border-radius: 50%;"
create: ->
@inherited arguments
@colorChanged()
colorChanged: (oldValue) ->
@applyStyle "background-color", @color
enyo.kind
name: "PoweredLight"
kind: "Light"
published:
powered: true
handlers:
ontap: "tapped"
create: ->
@inherited arguments_
@poweredChanged()
tapped: (inSender, inEvent) ->
@setPowered not @getPowered()
poweredChanged: (oldValue) ->
@applyStyle "opacity", (if @powered then "1" else "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 TrafficLight().renderInto document.body