From 4bcabf751b8292fee696db5e027f38b1838b0be6 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Tue, 11 Aug 2020 21:38:47 +0300
Subject: feat: add mobile header

---
 src/components/Header/Header.tsx | 75 ++++++++++++++++++++++------------------
 1 file changed, 42 insertions(+), 33 deletions(-)

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

diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx
index c3a678c..b314d79 100644
--- a/src/components/Header/Header.tsx
+++ b/src/components/Header/Header.tsx
@@ -8,20 +8,22 @@ import {
   Avatar,
   useMediaQuery
 } from '@material-ui/core';
+import {
+  AccountCircle,
+  Notifications,
+  Home,
+  Menu,
+  Search,
+} from '@material-ui/icons';
 import { makeStyles, useTheme } from '@material-ui/core/styles';
-import AccountCircle from '@material-ui/icons/AccountCircle';
-import NotificationsIcon from '@material-ui/icons/Notifications';
-import HomeIcon from '@material-ui/icons/Home';
 
 import { useAuth } from '../../hooks/useAuth';
 import SearchBar from './SearchBar';
+import MobileHeader from './MobileHeader';
+import BottomBar from './BottomBar';
 
 
 const useStyles = makeStyles(theme => ({
-  mobile: {
-    top: 'auto',
-    bottom: 0
-  },
   toolbar: {
     display: 'flex',
     justifyContent: 'space-around'
@@ -41,7 +43,6 @@ const useStyles = makeStyles(theme => ({
   }
 }));
 
-
 const Header: React.FC = React.memo(() => {
   const classes = useStyles();
   const { user } = useAuth();
@@ -66,19 +67,37 @@ const Header: React.FC = React.memo(() => {
     history.push('/notifications');
   };
 
-  const FeedButton = (
+  const feed = (
     <IconButton onClick={handleFeed}>
-      <HomeIcon />
+      <Home />
+    </IconButton>
+  );
+
+  const notifications = (
+    <IconButton onClick={handleNotifications}>
+      <Notifications />
+    </IconButton>
+  );
+
+  const menu = (
+    <IconButton>
+      <Menu />
     </IconButton>
   );
 
-  const NotificationsButton = (
+  const search = (
     <IconButton onClick={handleNotifications}>
-      <NotificationsIcon />
+      <Search />
     </IconButton>
   );
 
-  const ProfileButton = (
+  const logo = (
+    <Typography variant="h5" className={classes.logo} onClick={handleHome}>
+      Which
+    </Typography>
+  );
+
+  const profile= (
     <IconButton onClick={handleProfile}>
       {
         user?.avatarUrl
@@ -91,33 +110,23 @@ const Header: React.FC = React.memo(() => {
   const BrowserVersion = (
     <AppBar position="fixed">
       <Toolbar className={`${classes.toolbar} ${classes.browserToolbar}`}>
-        <Typography variant="h5" className={classes.logo} onClick={handleHome}>
-          Which
-        </Typography>
+        {logo}
         <SearchBar />
         <div>
-          {FeedButton}
-          {NotificationsButton}
-          {ProfileButton}
+          {feed}
+          {notifications}
+          {profile}
         </div>
       </Toolbar>
     </AppBar>
   );
 
-  const MobileVersion = (
-    <AppBar position="fixed" className={classes.mobile}>
-      <Toolbar className={classes.toolbar}>
-        <IconButton onClick={handleHome}>
-          <Typography className={`${classes.logo} ${classes.round}`}>W</Typography>
-        </IconButton>
-        {FeedButton}
-        {NotificationsButton}
-        {ProfileButton}
-      </Toolbar>
-    </AppBar>
-  );
-
-  return isMobile ? MobileVersion : BrowserVersion;
+  return isMobile ? (
+    <>
+      <MobileHeader logo={logo} menu={menu} search={search} />
+      <BottomBar feed={feed} profile={profile} notifications={notifications} />
+    </>
+  ) : BrowserVersion;
 });
 
 export default Header;
-- 
cgit v1.2.3


From a9d713a73b65847af419016d2d97c4e8dab950f9 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Tue, 11 Aug 2020 22:00:10 +0300
Subject: refactor: cleanup header components

---
 src/components/Header/Header.tsx | 40 +++++++++-------------------------------
 1 file changed, 9 insertions(+), 31 deletions(-)

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

diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx
index b314d79..344b839 100644
--- a/src/components/Header/Header.tsx
+++ b/src/components/Header/Header.tsx
@@ -1,8 +1,6 @@
 import React from 'react';
 import { useHistory } from 'react-router-dom';
 import {
-  AppBar,
-  Toolbar,
   IconButton,
   Typography,
   Avatar,
@@ -13,31 +11,23 @@ import {
   Notifications,
   Home,
   Menu,
-  Search,
+  Search
 } from '@material-ui/icons';
 import { makeStyles, useTheme } from '@material-ui/core/styles';
 
 import { useAuth } from '../../hooks/useAuth';
-import SearchBar from './SearchBar';
 import MobileHeader from './MobileHeader';
 import BottomBar from './BottomBar';
+import BrowserHeader from './BrowserHeader';
 
 
 const useStyles = makeStyles(theme => ({
-  toolbar: {
-    display: 'flex',
-    justifyContent: 'space-around'
-  },
-  browserToolbar: {
-    width: '60%',
-    margin: 'auto'
-  },
   logo: {
     fontWeight: 'bold',
     cursor: 'pointer',
     color: 'white'
   },
-  round: {
+  avatar: {
     width: theme.spacing(3),
     height: theme.spacing(3)
   }
@@ -86,7 +76,7 @@ const Header: React.FC = React.memo(() => {
   );
 
   const search = (
-    <IconButton onClick={handleNotifications}>
+    <IconButton>
       <Search />
     </IconButton>
   );
@@ -97,36 +87,24 @@ const Header: React.FC = React.memo(() => {
     </Typography>
   );
 
-  const profile= (
+  const profile = (
     <IconButton onClick={handleProfile}>
       {
         user?.avatarUrl
-          ? <Avatar className={classes.round} src={user?.avatarUrl} />
+          ? <Avatar className={classes.avatar} src={user?.avatarUrl} />
           : <AccountCircle />
       }
     </IconButton>
   );
 
-  const BrowserVersion = (
-    <AppBar position="fixed">
-      <Toolbar className={`${classes.toolbar} ${classes.browserToolbar}`}>
-        {logo}
-        <SearchBar />
-        <div>
-          {feed}
-          {notifications}
-          {profile}
-        </div>
-      </Toolbar>
-    </AppBar>
-  );
-
   return isMobile ? (
     <>
       <MobileHeader logo={logo} menu={menu} search={search} />
       <BottomBar feed={feed} profile={profile} notifications={notifications} />
     </>
-  ) : BrowserVersion;
+  ) : (
+    <BrowserHeader logo={logo} profile={profile} notifications={notifications} feed={feed} />
+  );
 });
 
 export default Header;
-- 
cgit v1.2.3


From b5ce9be31993f5b4bee9abbe57d775b7ea407507 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Tue, 11 Aug 2020 22:19:23 +0300
Subject: refactor: create separate Avatar component

---
 src/components/Header/Header.tsx | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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

diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx
index 344b839..5621dbf 100644
--- a/src/components/Header/Header.tsx
+++ b/src/components/Header/Header.tsx
@@ -3,7 +3,6 @@ import { useHistory } from 'react-router-dom';
 import {
   IconButton,
   Typography,
-  Avatar,
   useMediaQuery
 } from '@material-ui/core';
 import {
@@ -19,6 +18,7 @@ import { useAuth } from '../../hooks/useAuth';
 import MobileHeader from './MobileHeader';
 import BottomBar from './BottomBar';
 import BrowserHeader from './BrowserHeader';
+import Avatar from '../Avatar/Avatar';
 
 
 const useStyles = makeStyles(theme => ({
@@ -90,9 +90,9 @@ const Header: React.FC = React.memo(() => {
   const profile = (
     <IconButton onClick={handleProfile}>
       {
-        user?.avatarUrl
-          ? <Avatar className={classes.avatar} src={user?.avatarUrl} />
-          : <AccountCircle />
+        user
+          ? <Avatar className={classes.avatar} user={user} />
+          : <AccountCircle className={classes.avatar} />
       }
     </IconButton>
   );
-- 
cgit v1.2.3

