diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-06-07 20:16:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-07 20:16:35 +0300 |
commit | b8b848dfd6e3843c6b455c8344320dcd187b72da (patch) | |
tree | 448562cddde0e5cdf6014fab6b00554970539dff | |
parent | 4e4c9d529e6f70e7dac84aaecb5b6a25769c3290 (diff) | |
parent | 796271adc4bf815c19c58f4231019502cb0bed24 (diff) | |
download | which-ui-b8b848dfd6e3843c6b455c8344320dcd187b72da.tar.gz |
Merge pull request #13 from ilyayudovin/header-enhanced
Improve Header styles
-rw-r--r-- | .eslintrc.json | 3 | ||||
-rw-r--r-- | package-lock.json | 8 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | src/Header/Header.tsx | 70 | ||||
-rw-r--r-- | src/Header/SearchBar.tsx | 31 | ||||
-rw-r--r-- | src/index.tsx | 7 |
6 files changed, 88 insertions, 32 deletions
diff --git a/.eslintrc.json b/.eslintrc.json index 4899960..ac3fbd3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -21,6 +21,7 @@ "linebreak-style": 0, "react/prop-types": 0, "react/no-children-prop": 0, - "react/no-danger": 0 + "react/no-danger": 0, + "react/jsx-one-expression-per-line": 0 } } diff --git a/package-lock.json b/package-lock.json index 52e71f8..670ba1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1366,6 +1366,14 @@ "react-transition-group": "^4.4.0" } }, + "@material-ui/icons": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/@material-ui/icons/-/icons-4.9.1.tgz", + "integrity": "sha512-GBitL3oBWO0hzBhvA9KxqcowRUsA0qzwKkURyC8nppnC3fw54KPKZ+d4V1Eeg/UnDRSzDaI9nGCdel/eh9AQMg==", + "requires": { + "@babel/runtime": "^7.4.4" + } + }, "@material-ui/styles": { "version": "4.10.0", "resolved": "https://registry.npmjs.org/@material-ui/styles/-/styles-4.10.0.tgz", diff --git a/package.json b/package.json index c4dbec6..0ace916 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@material-ui/core": "^4.10.1", + "@material-ui/icons": "^4.9.1", "@types/node": "^12.12.44", "@types/react": "^16.9.35", "@types/react-dom": "^16.9.8", diff --git a/src/Header/Header.tsx b/src/Header/Header.tsx index 8e8a301..0ee6b5f 100644 --- a/src/Header/Header.tsx +++ b/src/Header/Header.tsx @@ -2,45 +2,63 @@ import React from 'react'; import { AppBar, Toolbar, - Tabs, - Tab + IconButton, + Typography } from '@material-ui/core'; import { makeStyles } 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 SearchBar from './SearchBar'; interface PropTypes { - page: string; setPage: (newPage: string) => void; } -const useStyles = makeStyles(theme => ({ - tab: { - '& .MuiTab-wrapper': { - padding: theme.spacing(2), - flexDirection: 'row', - fontSize: '0.8125rem' - } +const useStyles = makeStyles({ + root: { + display: 'flex', + justifyContent: 'space-around', + width: '60%', + margin: 'auto' + }, + logo: { + fontWeight: 'bold' } -})); - -const tabs = ['Profile', 'Feed']; +}); -const Header: React.FC<PropTypes> = ({ page /* , setPage */ }) => { +const Header: React.FC<PropTypes> = ({ setPage }) => { const classes = useStyles(); - const handleChange = () => {}; + const handleHome = (): void => { + setPage('feed'); + }; + + const handleProfile = (): void => { + setPage('profile'); + }; + + const handleNotifications = (): void => {}; return ( - <AppBar position="static"> - <Toolbar> - <Tabs onChange={handleChange} value={page}> - {tabs.map((tab: string) => ( - <Tab - label={tab} - key={tab} - className={classes.tab} - /> - ))} - </Tabs> + <AppBar position="fixed"> + <Toolbar className={classes.root}> + <Typography variant="h5" className={classes.logo}> + Which + </Typography> + <SearchBar /> + <div> + <IconButton onClick={handleHome}> + <HomeIcon /> + </IconButton> + <IconButton onClick={handleNotifications}> + <NotificationsIcon /> + </IconButton> + <IconButton onClick={handleProfile}> + <AccountCircle /> + </IconButton> + </div> </Toolbar> </AppBar> ); diff --git a/src/Header/SearchBar.tsx b/src/Header/SearchBar.tsx new file mode 100644 index 0000000..182a1a4 --- /dev/null +++ b/src/Header/SearchBar.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import SearchIcon from '@material-ui/icons/Search'; +import { InputBase } from '@material-ui/core'; +import { makeStyles } from '@material-ui/core/styles'; + +const useStyles = makeStyles(theme => ({ + root: { + background: 'rgba(255, 255, 255, 0.5)', + borderRadius: '2px', + padding: theme.spacing(0.5), + display: 'flex', + alignItems: 'center' + } +})); + +const SearchBar: React.FC = () => { + const classes = useStyles(); + + return ( + <div className={classes.root}> + <SearchIcon /> + <InputBase + placeholder="Search..." + /> + </div> + ); +}; + + +export default SearchBar; + diff --git a/src/index.tsx b/src/index.tsx index d7efbf7..48bad48 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -13,10 +13,6 @@ const theme = createMuiTheme({ palette: { primary: { main: teal[700] - }, - text: { - primary: '#000000', - secondary: 'rgba(255, 255, 255, 0.6)' } } }); @@ -47,8 +43,9 @@ const App: React.FC = () => { return ( <ThemeProvider theme={theme}> <CssBaseline /> - <Header page={page} setPage={setPage} /> + <Header setPage={setPage} /> <PollCard author={pollProps.author} contents={pollProps.contents} /> + <h1> We are on page {page}! </h1> </ThemeProvider> ); }; |