Last active
October 21, 2016 20:19
-
-
Save bnhansn/67a76d7f926856a67e35caa9922727a1 to your computer and use it in GitHub Desktop.
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
| // @flow | |
| import React from 'react'; | |
| import { Link } from 'react-router'; | |
| import { css, StyleSheet } from 'aphrodite'; | |
| const styles = StyleSheet.create({ | |
| sidebar: { | |
| display: 'flex', | |
| flexDirection: 'column', | |
| background: 'rgb(38,28,37)', | |
| }, | |
| link: { | |
| position: 'relative', | |
| display: 'flex', | |
| width: '65px', | |
| color: 'rgba(255,255,255,.6)', | |
| ':hover': { | |
| textDecoration: 'none', | |
| }, | |
| ':focus': { | |
| textDecoration: 'none', | |
| }, | |
| }, | |
| activeLink: { | |
| color: '#fff', | |
| ':after': { | |
| position: 'absolute', | |
| top: '12px', | |
| bottom: '12px', | |
| left: '0', | |
| width: '3px', | |
| background: 'rgba(255,255,255,.2)', | |
| borderTopRightRadius: '3px', | |
| borderBottomRightRadius: '3px', | |
| content: '""', | |
| }, | |
| }, | |
| badge: { | |
| display: 'flex', | |
| alignItems: 'center', | |
| justifyContent: 'center', | |
| width: '45px', | |
| height: '45px', | |
| margin: '12px auto', | |
| fontSize: '20px', | |
| background: 'rgba(255,255,255,.2)', | |
| borderRadius: '5px', | |
| }, | |
| logoutButton: { | |
| padding: '0', | |
| background: 'transparent', | |
| border: '0', | |
| cursor: 'pointer', | |
| }, | |
| }); | |
| type Room = { | |
| id: number, | |
| name: string, | |
| } | |
| type RoomLinkProps = { | |
| room: Room | |
| } | |
| const RoomLink = ({ room }: RoomLinkProps) => | |
| <Link to={`/r/${room.id}`} className={css(styles.link)} activeClassName={css(styles.activeLink)}> | |
| <div className={css(styles.badge)}> | |
| <span>{room.name.charAt(0)}</span> | |
| </div> | |
| </Link>; | |
| type Props = { | |
| rooms: Array<Room>, | |
| router: Object, | |
| onLogoutClick: () => void, | |
| } | |
| const Sidebar = ({ rooms, router, onLogoutClick }: Props) => | |
| <div className={css(styles.sidebar)}> | |
| {rooms.map(room => <RoomLink key={room.id} room={room} />)} | |
| <Link | |
| to="/" | |
| activeOnlyWhenExact | |
| className={css(styles.link)} | |
| activeClassName={css(styles.activeLink)} | |
| > | |
| <div className={css(styles.badge)}> | |
| <span className="fa fa-plus" /> | |
| </div> | |
| </Link> | |
| <div style={{ flex: '1' }} /> | |
| <button | |
| onClick={() => onLogoutClick(router)} | |
| className={css(styles.link, styles.logoutButton)} | |
| > | |
| <div className={css(styles.badge)}> | |
| <span className="fa fa-sign-out" /> | |
| </div> | |
| </button> | |
| </div>; | |
| export default Sidebar; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment