liquid menu

This commit is contained in:
Tommy Parnell
2019-06-02 17:10:51 -04:00
commit 4cc335744b
18 changed files with 11308 additions and 0 deletions

26
src/App.js Normal file
View File

@@ -0,0 +1,26 @@
import React from "react";
import styles from "./App.module.scss";
import Table from "./Table";
import CssBaseline from "@material-ui/core/CssBaseline";
import { MuiThemeProvider, createMuiTheme } from "@material-ui/core";
import NavBar from "./NavBar.js";
function App() {
const theme = createMuiTheme({
typography: {
useNextVariants: true
}
});
return (
<CssBaseline>
<MuiThemeProvider theme={theme}>
<NavBar />
<div className={styles.container}>
<Table />
</div>
</MuiThemeProvider>
</CssBaseline>
);
}
export default App;

5
src/App.module.scss Normal file
View File

@@ -0,0 +1,5 @@
.container {
padding: 0 1rem;
text-align: center;
padding-top: 1rem;
}

9
src/App.test.js Normal file
View File

@@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});

95
src/Card.js Normal file
View File

@@ -0,0 +1,95 @@
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import Card from "@material-ui/core/Card";
import CardActions from "@material-ui/core/CardActions";
import CardContent from "@material-ui/core/CardContent";
import Button from "@material-ui/core/Button";
import Typography from "@material-ui/core/Typography";
import clsx from "clsx";
const useStyles = makeStyles({
card: {
width: 275,
marginRight: "1rem",
marginBottom: "1rem"
},
inHouse: {
// backgroundColor: '#2bfc58'
},
bullet: {
display: "inline-block",
margin: "0 2px",
transform: "scale(0.8)"
},
title: {
fontSize: 14
},
btmBox: {
padding: "1rem",
display: "flex",
flexDirection: "row"
},
spacer: {
flexGrow: 1
},
nitro: {
fontSize: 14,
color: "#3f51b5"
},
pos: {
marginBottom: 12
},
header: {
height: '3rem'
}
});
function SimpleCard({ name, number, inHouse, isNitro, desc, abv }) {
const classes = useStyles();
const bull = <span className={classes.bullet}></span>;
return (
<Card
className={clsx({ [classes.card]: true, [classes.inHouse]: inHouse })}
>
<CardContent>
<Typography
className={classes.title}
color="textSecondary"
gutterBottom
>
#{number}
</Typography>
<Typography className={classes.header} variant="h5" component="h2">
{name}
</Typography>
<Typography variant="body2" component="p">
{desc}
</Typography>
</CardContent>
<div className={classes.btmBox}>
{abv && (
<Typography
className={classes.nitro}
color="textSecondary"
gutterBottom
>
ABV: {abv}%
</Typography>
)}
<div className={classes.spacer} />
{isNitro && (
<Typography
className={classes.nitro}
color="textSecondary"
gutterBottom
>
NITRO
</Typography>
)}
</div>
</Card>
);
}
export default SimpleCard;

29
src/NavBar.js Normal file
View File

@@ -0,0 +1,29 @@
import React, { useState } from 'react';
import { withStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
const styles = {
appBar: {
height: '7vh',
display: 'flex',
alignItems: 'center'
},
};
function ButtonAppBar(props) {
const { classes } = props;
return (
<div>
<AppBar className={classes.appBar} position="static">
<Toolbar>
<Typography variant="h6" color="inherit">
Liquid Therapy Menu
</Typography>
</Toolbar>
</AppBar>
</div>
);
}
export default withStyles(styles)(ButtonAppBar);

25
src/Table.js Normal file
View File

@@ -0,0 +1,25 @@
import React from "react";
import { makeStyles } from '@material-ui/core/styles';
import { beers } from "./beers.js";
import Card from './Card.js';
const useStyles = makeStyles({
container: {
display: 'flex',
flexDirection: 'row',
flexWrap: 'wrap',
}
});
export default function Table() {
const styles = useStyles();
console.log(styles);
const cards = beers
.filter(i => i.inHouse)
.map((i, index) => (
<Card key={`${i.name}-${index}`} number={index + 1} {...i} />
));
return (
<div className={styles.container}>
{cards}
</div>
);
}

78
src/beers.js Normal file
View File

@@ -0,0 +1,78 @@
export const beers = [
{
name: "Scotch Ale",
inHouse: true,
abv: '6.3',
},
{
name: "NE Therapy IPA",
inHouse: true,
abv: '5.6',
},
{
name: "Mandarina Warrior Pale Ale",
inHouse: true,
abv: '6.5',
},
{
name: "PBJ",
inHouse: true,
abv: '5.3',
},
{
name: "Lavebdar Chamomile IPA Sour",
inHouse: true,
abv: '6.1',
},
{
name: "Franken Stout",
inHouse: true,
abv: '5.2',
},
{
name: "Dark Roast Ale",
inHouse: true,
abv: '5.6',
},
{
name: "Amber Ale",
inHouse: true,
abv: '5.2',
},
{
name: "Citra Pale Ale",
inHouse: true,
abv: '5.3',
isNitro: true,
},
{
name: "Lemon Peel Cream Ale",
inHouse: true,
abv: '5.5',
isNitro: true,
},
{
name: "Mexican Nut Brown",
inHouse: true,
abv: '5.5',
isNitro: true,
},
{
name: "Orange Milkshake",
abv: '6.5',
},
{
name: "Downeast Cider",
abv: '5.2',
},
{
name: "Kentucky Burbon Ale",
abv: '8.2',
},
{
name: "NHCBW Saison",
abv: '6.1',
},
]

15
src/index.css Normal file
View File

@@ -0,0 +1,15 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: rgb(54, 53, 53);
color: white;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}

12
src/index.js Normal file
View File

@@ -0,0 +1,12 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();

135
src/serviceWorker.js Normal file
View File

@@ -0,0 +1,135 @@
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA'
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch(error => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister();
});
}
}

2
src/variables.scss Normal file
View File

@@ -0,0 +1,2 @@
$gray: gray;
$green: #3c853c;