Skip to content

Instantly share code, notes, and snippets.

@andrewfulton
Created August 21, 2019 23:11
Show Gist options
  • Save andrewfulton/f4801cab5299f988fd7eda015dd41dc2 to your computer and use it in GitHub Desktop.
Save andrewfulton/f4801cab5299f988fd7eda015dd41dc2 to your computer and use it in GitHub Desktop.
File Chooser
File Chooser
Empty
Change -> Choosing
Choosing
Cancel -> Empty
Choose -> Selected
Selected
Change -> Choosing
Remove -> Empty
function render(model){
let current_state_name = model.active_states[0].name;
switch(current_state_name){
case 'Empty':
return (<div>
<em>Empty</em>
<button onClick={()=>model.emit('Change')}>Choose</button>
</div>)
break;
case 'Choosing':
return (<div>
<select>
<option>One</option>
<option>Two</option>
</select>
<button onClick={()=>model.emit('Choose')}>Confirm</button>
<button onClick={()=>model.emit('Cancel')}>Cancel</button>
</div>)
break;
case 'Selected':
return (
<div>
<strong>One</strong>
<button onClick={()=>model.emit('Change')}>Change</button>
<button onClick={()=>model.emit('Remove')}>Remove</button>
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment