1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-31 06:18:07 +00:00
_/styles/TopAppBar.tsx

32 lines
773 B
TypeScript
Raw Normal View History

2019-07-09 19:16:29 +09:00
import React from "react";
import { useRouter } from "next/router";
2019-04-24 00:12:28 +09:00
import { AppBar, Tabs, Tab } from "@material-ui/core";
2019-04-24 00:29:07 +09:00
import routes from "../routes";
2019-04-23 16:48:33 +09:00
2019-07-09 19:16:29 +09:00
const TopAppBar = () => {
const router = useRouter();
const pathname = (
routes.find(({ pathname }) => pathname === router.pathname) || {
pathname: "/"
}
).pathname;
2019-04-23 16:48:33 +09:00
return (
2019-07-09 15:46:11 +09:00
<AppBar color="default">
<Tabs
2019-07-09 19:16:29 +09:00
value={pathname}
2019-07-09 15:46:11 +09:00
onChange={(_, value) => {
2019-07-09 19:16:29 +09:00
router.push(value);
2019-07-09 15:46:11 +09:00
}}
variant="fullWidth"
indicatorColor="primary"
textColor="primary"
>
2019-07-09 19:16:29 +09:00
{routes.map(({ pathname, icon }) => (
<Tab key={pathname} value={pathname} icon={icon} />
2019-07-09 15:46:11 +09:00
))}
</Tabs>
</AppBar>
2019-04-23 16:48:33 +09:00
);
2019-07-09 19:16:29 +09:00
};
2019-07-09 15:46:11 +09:00
export default TopAppBar;