-
Notifications
You must be signed in to change notification settings - Fork 53
Adding react template #30
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package config | ||
|
|
||
| type reactApp struct { | ||
| Name string | ||
| } | ||
|
|
||
| type reactHeader struct { | ||
| Enabled bool | ||
| } | ||
|
|
||
| type reactSidenav struct { | ||
| Enabled bool | ||
| } | ||
|
|
||
| type reactAccount struct { | ||
| Enabled bool | ||
| Required bool | ||
| } | ||
| type React struct { | ||
| App reactApp | ||
| Account reactAccount | ||
| Header reactHeader | ||
| Sidenav reactSidenav | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| /node_modules | ||
| /.pnp | ||
| .pnp.js | ||
| /package-lock.json | ||
|
|
||
| # testing | ||
| /coverage | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "baseUrl": "src" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,17 @@ | ||
| { | ||
| "name": "{{ .Name }}", | ||
| "name": "commit0", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this file is only used for local dev, see corresponding template file that is used in code generation |
||
| "version": "0.1.0", | ||
| "private": true, | ||
| "dependencies": { | ||
| "@material-ui/core": "^4.5.1", | ||
| "@material-ui/icons": "^4.5.1", | ||
| "react": "^16.10.2", | ||
| "react-dom": "^16.10.2", | ||
| "react-scripts": "3.2.0" | ||
| "react-redux": "^7.1.1", | ||
| "react-router": "^5.1.2", | ||
| "react-router-dom": "^5.1.2", | ||
| "react-scripts": "3.2.0", | ||
| "redux": "^4.0.4" | ||
| }, | ||
| "scripts": { | ||
| "start": "react-scripts start", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { | ||
| "name": "{{ .React.App.Name }}", | ||
| "version": "0.1.0", | ||
| "private": true, | ||
| "dependencies": { | ||
| "@material-ui/core": "^4.5.1", | ||
| "@material-ui/icons": "^4.5.1", | ||
| "react": "^16.10.2", | ||
| "react-dom": "^16.10.2", | ||
| "react-redux": "^7.1.1", | ||
| "react-router": "^5.1.2", | ||
| "react-router-dom": "^5.1.2", | ||
| "react-scripts": "3.2.0", | ||
| "redux": "^4.0.4" | ||
| }, | ||
| "scripts": { | ||
| "start": "react-scripts start", | ||
| "build": "react-scripts build", | ||
| "test": "react-scripts test", | ||
| "eject": "react-scripts eject" | ||
| }, | ||
| "eslintConfig": { | ||
| "extends": "react-app" | ||
| }, | ||
| "browserslist": { | ||
| "production": [ | ||
| ">0.2%", | ||
| "not dead", | ||
| "not op_mini all" | ||
| ], | ||
| "development": [ | ||
| "last 1 chrome version", | ||
| "last 1 firefox version", | ||
| "last 1 safari version" | ||
| ] | ||
| } | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,23 @@ | ||
| import React from 'react'; | ||
| import logo from './logo.svg'; | ||
| import './App.css'; | ||
| import { BrowserRouter as Router, Switch, Route } from "react-router-dom"; | ||
| import Layout from 'components/layout'; | ||
|
|
||
| function App() { | ||
| export default function App() { | ||
| return ( | ||
| <div className="App"> | ||
| <header className="App-header"> | ||
| <img src={logo} className="App-logo" alt="logo" /> | ||
| <p> | ||
| Edit <code>src/App.js</code> and save to reload. | ||
| </p> | ||
| <a | ||
| className="App-link" | ||
| href="https://reactjs.org" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| Learn React | ||
| </a> | ||
| </header> | ||
| </div> | ||
| <Layout> | ||
| <Router> | ||
| <Switch> | ||
| <Route path="/a"> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are just placeholders as we add more meaningful content
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we would be eventually be generating routes from API? |
||
| <span>a</span> | ||
| </Route> | ||
| <Route path="/b"> | ||
| <span>b</span> | ||
| </Route> | ||
| <Route path="/"> | ||
| <span>c</span> | ||
| </Route> | ||
| </Switch> | ||
| </Router> | ||
| </Layout> | ||
| ); | ||
| } | ||
|
|
||
| export default App; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import React from 'react'; | ||
| import IconButton from '@material-ui/core/IconButton'; | ||
| import AccountCircle from '@material-ui/icons/AccountCircle'; | ||
| import MenuItem from '@material-ui/core/MenuItem'; | ||
| import Menu from '@material-ui/core/Menu'; | ||
|
|
||
| export default function MenuAppBar() { | ||
| const [anchorEl, setAnchorEl] = React.useState(null); | ||
| const open = Boolean(anchorEl); | ||
|
|
||
| const handleMenu = event => { | ||
| setAnchorEl(event.currentTarget); | ||
| }; | ||
|
|
||
| const handleClose = () => { | ||
| setAnchorEl(null); | ||
| }; | ||
|
|
||
| const anchorOriginProps = { | ||
| vertical: 'top', | ||
| horizontal: 'right', | ||
| }; | ||
| const transformOriginProps = { | ||
| vertical: 'top', | ||
| horizontal: 'right', | ||
| }; | ||
| return ( | ||
| <div> | ||
| <IconButton | ||
| aria-label="account of current user" | ||
| aria-controls="menu-appbar" | ||
| aria-haspopup="true" | ||
| onClick={handleMenu} | ||
| color="inherit" | ||
| > | ||
| <AccountCircle /> | ||
| </IconButton> | ||
| <Menu | ||
| id="menu-appbar" | ||
| anchorEl={anchorEl} | ||
| anchorOrigin={anchorOriginProps} | ||
| keepMounted | ||
| transformOrigin={transformOriginProps} | ||
| open={open} | ||
| onClose={handleClose} | ||
| > | ||
| <MenuItem onClick={handleClose}>Profile</MenuItem> | ||
| <MenuItem onClick={handleClose}>My account</MenuItem> | ||
| </Menu> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import React from 'react'; | ||
| import { makeStyles } 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'; | ||
| import config from 'config'; | ||
| import Sidenav from 'components/layout/header/sidenav'; | ||
| import Account from 'components/layout/header/account'; | ||
|
|
||
| const useStyles = makeStyles(theme => ({ | ||
| root: { | ||
| flexGrow: 1, | ||
| }, | ||
| title: { | ||
| flexGrow: 1, | ||
| }, | ||
| })); | ||
|
|
||
| export default function MenuAppBar() { | ||
| const classes = useStyles(); | ||
| return ( | ||
| <div className={classes.root}> | ||
| <AppBar position="static"> | ||
| <Toolbar> | ||
| { config && config.sidenav && config.sidenav.enabled && <Sidenav />} | ||
| <Typography variant="h6" className={classes.title}> | ||
| { config && config.app && config.app.name } | ||
| </Typography> | ||
| { config && config.account && config.account.enabled && <Account />} | ||
| </Toolbar> | ||
| </AppBar> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import React, { Fragment } from 'react'; | ||
| import { makeStyles } from '@material-ui/core/styles'; | ||
| import IconButton from '@material-ui/core/IconButton'; | ||
| import MenuIcon from '@material-ui/icons/Menu'; | ||
|
|
||
| const useStyles = makeStyles(theme => ({ | ||
| menuButton: { | ||
| marginRight: theme.spacing(2), | ||
| }, | ||
| })); | ||
|
|
||
| export default function Sidenav() { | ||
| const classes = useStyles(); | ||
| return ( | ||
| <Fragment> | ||
| <IconButton | ||
| edge="start" | ||
| className={classes.menuButton} | ||
| color="inherit" | ||
| aria-label="open drawer" | ||
| > | ||
| <MenuIcon /> | ||
| </IconButton> | ||
| </Fragment> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import React, { Fragment } from 'react'; | ||
| import Container from '@material-ui/core/Container'; | ||
| import Header from 'components/layout/header'; | ||
| import config from 'config'; | ||
|
|
||
| export default function App({children}) { | ||
| return ( | ||
| <Fragment> | ||
| { config && config.header && config.header.enabled && <Header />} | ||
| <Container maxWidth={false}> | ||
| {children} | ||
| </Container> | ||
| </Fragment> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| export default { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this file is only used for local dev, see corresponding template file that is used in code generation |
||
| app: { | ||
| name: 'Commit0', | ||
| }, | ||
| account: { | ||
| enabled: true, | ||
| required: true, | ||
| }, | ||
| header: { | ||
| enabled: true, | ||
| }, | ||
| sidenav: { | ||
| enabled: true, | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| export default { | ||
| app: { | ||
| name: '{{ .React.App.Name }}', | ||
| }, | ||
| account: { | ||
| enabled: {{ .React.Account.Enabled }}, | ||
| required: {{ .React.Account.Required }}, | ||
| }, | ||
| header: { | ||
| enabled: {{ .React.Header.Enabled }}, | ||
| }, | ||
| sidenav: { | ||
| enabled: {{ .React.Sidenav.Enabled }}, | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these types are not exported to avoid namespace pollution