diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-06-27 18:32:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-27 18:32:53 +0300 |
commit | 9c4d6400ae83a32853d4437236f42796f08dbde7 (patch) | |
tree | 482d910d7841ff39b9a1bc5af9516e2b2f64b532 /src/components/UserStrip/UserStrip.tsx | |
parent | 8c5d7716e18e1da9a6556c581dc8056b7c182ae8 (diff) | |
parent | 1ad4b552361e7753d164fa8ffe9f5ae132221fed (diff) | |
download | which-ui-9c4d6400ae83a32853d4437236f42796f08dbde7.tar.gz |
Merge pull request #49 from which-ecosystem/feed-improvements
Feed improvements
Diffstat (limited to 'src/components/UserStrip/UserStrip.tsx')
-rw-r--r-- | src/components/UserStrip/UserStrip.tsx | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/components/UserStrip/UserStrip.tsx b/src/components/UserStrip/UserStrip.tsx new file mode 100644 index 0000000..6e84768 --- /dev/null +++ b/src/components/UserStrip/UserStrip.tsx @@ -0,0 +1,65 @@ +import React from 'react'; +import { makeStyles } from '@material-ui/core/styles'; +import VerifiedIcon from '@material-ui/icons/CheckCircleOutline'; +import { + Avatar, + CardHeader +} from '@material-ui/core/'; +import { User } from 'which-types'; + + +interface PropTypes { + user: User; + info: string | JSX.Element + navigate: (prefix: string, id: string) => void; +} + + +const useStyles = makeStyles(theme => ({ + root: { + display: 'flex', + alignItems: 'center' + }, + verified: { + marginLeft: theme.spacing(0.5), + width: theme.spacing(2), + height: theme.spacing(2) + }, + avatar: { + cursor: 'pointer' + } +})); + + +const UserStrip: React.FC<PropTypes> = ({ user, info, navigate }) => { + const classes = useStyles(); + const { + username, + avatarUrl, + verified + } = user; + + const handleNavigate = () => { + navigate('profile', user._id); + }; + + const avatar = ( + <Avatar + src={avatarUrl} + alt={username[0].toUpperCase()} + onClick={handleNavigate} + className={classes.avatar} + /> + ); + + const title = ( + <div className={classes.root}> + {username} + {verified && <VerifiedIcon color="primary" className={classes.verified} />} + </div> + ); + + return <CardHeader avatar={avatar} title={title} subheader={info} />; +}; + +export default UserStrip; |