Skip to content

Instantly share code, notes, and snippets.

@tnightingale
Last active June 20, 2018 21:43
Show Gist options
  • Save tnightingale/fcb919e32a474bf38eb7de2a6a940fb2 to your computer and use it in GitHub Desktop.
Save tnightingale/fcb919e32a474bf38eb7de2a6a940fb2 to your computer and use it in GitHub Desktop.
Task states
Task states
Not in my list
addToList -> In my list
In my list
markDone -> Done
removeFromList -> Not in my list
Done
markNotDone -> In my list
function render(model){
let current_state_name = model.active_states[0].name;
let buttonText;
switch(current_state_name) {
case 'Not in my list':
return <>
<button onClick={() => model.emit('addToList')}>Add to list</button>
</>;
case 'In my list':
return <>
<button onClick={() => model.emit('markDone')}>Mark done</button>
<button onClick={() => model.emit('removeFromList')}>Remove from my list</button>
</>;
case 'Done':
return <>
<button onClick={() => model.emit('markNotDone')}>Mark as not done</button>
</>
}
return <button style={{color: "darkBlue"}}>{current_state_name}</button>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment