Skip to content

Commit

Permalink
feat(material-ui): setup Header
Browse files Browse the repository at this point in the history
  • Loading branch information
topheman committed Mar 13, 2018
1 parent 783b566 commit d516748
Show file tree
Hide file tree
Showing 10 changed files with 612 additions and 36 deletions.
371 changes: 371 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"axios": "^0.18.0",
"axios-cache-adapter": "^2.0.0",
"invariant": "^2.2.3",
"material-ui": "^1.0.0-beta.37",
"material-ui-icons": "^1.0.0-beta.36",
"prop-types": "^15.6.1",
"react": "^16.2.0",
"react-dom": "^16.2.0",
Expand Down
40 changes: 22 additions & 18 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -19,14 +20,16 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<title>React App</title>
</head>

<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand All @@ -36,5 +39,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</body>

</html>
Binary file added src/assets/images/github-retina-white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/github-retina.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/twitter-retina-white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/twitter-retina.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions src/components/Header/Header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/** github logo from my other sites**/
/** networks header */
.site-networks {
position: absolute;
right: 20px;
top: 16px;
margin: 0;
padding: 0;
}
ul.site-networks {
list-style: none;
text-align: center;
padding: 0px 0px 10px 0px;
}
ul.site-networks li {
position: relative;
display: inline-block;
vertical-align: middle;
margin-left: 15px;
}
ul.site-networks li a {
display: block;
width: 32px;
height: 32px;
text-decoration: none;
padding-top: 0px;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-ms-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
ul.site-networks li a span.icon {
position: absolute;
display: block;
width: 32px;
height: 32px;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-ms-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
ul.site-networks li a span.desc {
display: none;
}
ul.site-networks li a:hover {
}
ul.site-networks li a:hover span.icon {
left: 0px;
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
/** since logos are included with the css in base64, we don't bother about pixel ratio media query (everybody gets the retina version)*/
ul.site-networks li.twitter a span.icon {
background-image: url(../../assets/images/twitter-retina-white.png);
background-size: 32px 32px;
}
ul.site-networks li.github a span.icon {
background-image: url(../../assets/images/github-retina-white.png);
background-size: 32px 32px;
}
/** for small devices */
@media only screen and (max-width: 600px) {
ul.site-networks {
top: 12px;
}
} /** for extra-small devices */
@media only screen and (max-width: 500px) {
ul.site-networks li {
margin-left: 5px;
}
}
94 changes: 94 additions & 0 deletions src/components/Header/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// inspired by https://material-ui-next.com/demos/app-bar/#app-bar-with-buttons

import React from "react";
import PropTypes from "prop-types";
import { withStyles } from "material-ui/styles";
import AppBar from "material-ui/AppBar";
import Toolbar from "material-ui/Toolbar";
import Typography from "material-ui/Typography";
import IconButton from "material-ui/IconButton";
import MenuIcon from "material-ui-icons/Menu";

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

import "./Header.css";

const styles = theme => ({
root: {
flexGrow: 1
},
title: {
textDecoration: "none",
fontWeight: 500,
flex: 1,
[theme.breakpoints.down("sm")]: {
fontSize: "100%"
},
[theme.breakpoints.up("sm")]: {
fontSize: "130%"
}
},
menuButton: {
marginLeft: -12,
[theme.breakpoints.down("sm")]: {
marginRight: 0
},
[theme.breakpoints.up("sm")]: {
marginRight: 20
}
}
});

const Header = props => {
const { classes } = props;
return (
<header className={classes.root}>
<AppBar position="fixed">
<Toolbar>
<IconButton
className={classes.menuButton}
color="inherit"
aria-label="Menu"
>
<MenuIcon />
</IconButton>
<Typography
component={Link}
to="/"
title="Home"
color="inherit"
className={classes.title}
>
npm-registry-browser
</Typography>
<ul className="site-networks">
<li className="twitter">
<a
href="https://twitter.com/topheman"
title="@topheman on twitter"
>
<span className="icon" />
<span className="desc">Twitter</span>
</a>
</li>
<li className="github">
<a
href="https://github.com/topheman/npm-registry-browser"
title="Fork on github"
>
<span className="icon" />
<span className="desc">Github</span>
</a>
</li>
</ul>
</Toolbar>
</AppBar>
</header>
);
};

Header.propTypes = {
classes: PropTypes.object.isRequired
};

export default withStyles(styles)(Header);
65 changes: 47 additions & 18 deletions src/containers/MainLayout/MainLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ import React from "react";
import PropTypes from "prop-types";
import { Link } from "react-router-dom";

import { MuiThemeProvider, createMuiTheme } from "material-ui/styles";
import Button from "material-ui/Button";
import CssBaseline from "material-ui/CssBaseline";

import Header from "../../components/Header/Header";

const theme = createMuiTheme({
palette: {
primary: {
main: "#900000",
light: "#c8412a"
},
secondary: { main: "#DDDDDD" }
}
});

const packages = [
"react",
"react@16.2.0",
Expand All @@ -10,25 +26,38 @@ const packages = [
];

const MainLayout = ({ children }) => (
<div className="layout">
<header>
<h2>Some header</h2>
<nav>
<ul>
<li>
<Link to="/">Home</Link>
</li>
{packages.map(name => (
<li key={name}>
<Link to={`/package/${name}`}>{name}</Link>
<MuiThemeProvider theme={theme}>
<CssBaseline />
<div className="layout">
<Header />
<div style={{ marginTop: 70 }}>
<h2>Temporary page</h2>
<nav>
<ul>
<li>
<Button color="primary" variant="raised" to="/" component={Link}>
Home
</Button>
</li>
))}
</ul>
</nav>
</header>
{children}
<footer>Some Footer</footer>
</div>
{packages.map(name => (
<li key={name}>
<Button
color="primary"
to={`/package/${name}`}
component={Link}
key={name}
>
{name}
</Button>
</li>
))}
</ul>
</nav>
</div>
{children}
<footer>Some Footer</footer>
</div>
</MuiThemeProvider>
);

MainLayout.propTypes = {
Expand Down

0 comments on commit d516748

Please sign in to comment.