Last active
August 2, 2018 15:29
-
-
Save mkircher/fc1bc3d551d22e9fd6a872a05be61edc to your computer and use it in GitHub Desktop.
Avatar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| yep |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Avatar | |
| Inactive | |
| clicked -> Active | |
| Active | |
| clicked -> Inactive | |
| deleted -> Deleted | |
| Deleted | |
| clicked -> Inactive | |
| Butt | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function render(model){ | |
| console.log(model) | |
| let current_state_name = model.active_states[0].name, | |
| isActive = current_state_name == 'Active', | |
| isDeleted = current_state_name == 'Deleted'; | |
| let css = { | |
| avatarContainer:{ | |
| display: 'inline-block', | |
| position: 'relative' | |
| }, | |
| avatar:{ | |
| width: 100, | |
| height: 100, | |
| display: 'inline-block', | |
| borderRadius: '50%', | |
| overflow: 'hidden', | |
| border: `5px solid ${ isActive ? '#EC297E' : '#DDD' }`, | |
| cursor: 'pointer', | |
| opacity: `${ isDeleted ? 0.25 : 1 }` | |
| }, | |
| avatarDelete:{ | |
| position:'absolute', | |
| top: 0, | |
| right: 0, | |
| borderRadius:'50%', | |
| width: 25, | |
| height:25, | |
| textAlign: 'center', | |
| border:'none', | |
| background:'#B01800', | |
| color:'#FFF', | |
| boxShadow:'0px 1px 4px #000' | |
| } | |
| } | |
| return ( | |
| <div style={ css.avatarContainer }> | |
| { isActive && !isDeleted && <button style={css.avatarDelete} onClick={ () => model.emit('deleted') }>✕</button> } | |
| <div style={css.avatar} onClick={ () => { model.emit('clicked') } }> | |
| <img src="https://source.unsplash.com/random/100x100" /> | |
| </div> | |
| </div> | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment