aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Header
diff options
context:
space:
mode:
authorEug-VS <eug-vs@keemail.me>2020-02-03 20:19:57 +0300
committerEug-VS <eug-vs@keemail.me>2020-02-03 20:19:57 +0300
commitddb2ba73406d6982e81bc779c155e6c687f98bb5 (patch)
treea1ccdb2a0d83c9bc2da0d71cafcb7ec47f2e08e7 /src/lib/Header
parentf0a70407aaf633eeb2612ca054af27204d8c0a9f (diff)
downloadreact-benzin-ddb2ba73406d6982e81bc779c155e6c687f98bb5.tar.gz
feat: separate HeaderTab component
@asketonim, feel free to correct these changes
Diffstat (limited to 'src/lib/Header')
-rw-r--r--src/lib/Header/Header.tsx26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/lib/Header/Header.tsx b/src/lib/Header/Header.tsx
index 2b13e3f..cc73fd9 100644
--- a/src/lib/Header/Header.tsx
+++ b/src/lib/Header/Header.tsx
@@ -10,14 +10,13 @@ import {
import { makeStyles } from '@material-ui/core/styles';
-
interface PropTypes {
logo: {
icon: React.ReactNode;
title: string;
};
contents: {
- [key: string]: React.ReactNode;
+ [key: string]: React.ReactNode | null;
};
page: string;
setPage: any;
@@ -49,6 +48,19 @@ const useStyles = makeStyles((theme: any) => ({
const Header: React.FC<PropTypes> = ({ logo, contents, page, setPage }) => {
const classes = useStyles();
+ const HeaderTab: React.FC<{ item: string }> = ({ item }) => {
+ const icon = contents[item];
+ return (
+ <Tab
+ label={item}
+ icon={icon}
+ value={item}
+ className={classes.tab}
+ key={item}
+ />
+ )
+ };
+
const handleChange = (event: any, newPage: string) => {
setPage(newPage);
};
@@ -61,14 +73,8 @@ const Header: React.FC<PropTypes> = ({ logo, contents, page, setPage }) => {
{logo.title}
</Typography>
<Tabs onChange={handleChange} value={page}>
- {contents && Object.keys(contents).map(item => (
- <Tab
- label={item}
- icon={contents[item]}
- value={item}
- className={classes.tab}
- key={item}
- />
+ {contents && Object.keys(contents).map((item: string) => (
+ <HeaderTab item={item}/>
))}
</Tabs>
</Toolbar>