Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

starter-react-flux v4 #29

Merged
merged 19 commits into from
Mar 18, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add menu to navi to create hamburger menu
  • Loading branch information
SokichiFujita committed Mar 18, 2019
commit f0ef934e42844086b8d8c6edb605d97972d46c24
73 changes: 54 additions & 19 deletions bin/app/components/Navi.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,60 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import React, { useState } from "react";

class Navi extends Component {
render() {
return (
<AppBar position="absolute" style={this.props.style}>
import AppBar from "@material-ui/core/AppBar";
import Toolbar from "@material-ui/core/Toolbar";
import Typography from "@material-ui/core/Typography";

import ListSubheader from "@material-ui/core/ListSubheader";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import Drawer from "@material-ui/core/Drawer";

import IconButton from "@material-ui/core/IconButton";
import MenuIcon from "@material-ui/icons/Menu";

import { Link } from "react-router-dom";

const Navi = ({ title }) => {
const [isOpen, setOpen] = useState(false);
return (
<>
<AppBar position="sticky" style={{ backgroundColor: "white" }}>
<Toolbar>
<Typography variant="title" color="inherit">
{this.props.title}
</Typography>
<IconButton onClick={() => setOpen(!isOpen)}>
<MenuIcon />
</IconButton>
<div
style={{
fontWeight: 900,
fontSize: 20,
marginLeft: 24,
color: "black"
}}
>
{title}
</div>
</Toolbar>
</AppBar>
);
}
}

Navi.propTypes = {
title: PropTypes.string.isRequired,
}
<Drawer open={isOpen} onClose={() => setOpen(false)}>
<List
style={{
width: 200,
height: "100%",
backgroundColor: "rgb(44,44,44)",
color: "white"
}}
>
<ListSubheader style={{ color: "white" }}>Menu</ListSubheader>
<ListItem component={Link} to="/" button>
Top
</ListItem>
<ListItem component={Link} to="/sample" button>
Sample
</ListItem>
</List>
</Drawer>
</>
);
};

export default Navi;