Skip to content

Instantly share code, notes, and snippets.

@glebsexy
Last active May 23, 2019 15:20
Show Gist options
  • Save glebsexy/d8e4a0f5082a54d39a8685bc9f5c07e0 to your computer and use it in GitHub Desktop.
Save glebsexy/d8e4a0f5082a54d39a8685bc9f5c07e0 to your computer and use it in GitHub Desktop.
Green*
Green*
tick -> Yellow
Yellow
tick -> Red
Red
tick -> Green
function light(color, is_illuminated){
var attrs = {width: '20px', height: '20px', 'margin-left': '20px'};
if(is_illuminated){
attrs.backgroundColor = color;
} else {
attrs.backgroundColor = 'black';
}
return $('div', {style: attrs});
}
function render(model){
var active_light = model.active_states[0].name;
return $('div',
light('Red', active_light === 'Red'),
light('Yellow', active_light === 'Yellow'),
light('Green', active_light === 'Green'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment