From 1ad4b552361e7753d164fa8ffe9f5ae132221fed Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sat, 27 Jun 2020 02:14:41 +0300
Subject: feat: add verified mark in new UserStrip comp

---
 src/components/UserStrip/UserStrip.tsx | 65 ++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 src/components/UserStrip/UserStrip.tsx

(limited to 'src/components/UserStrip/UserStrip.tsx')

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;
-- 
cgit v1.2.3

