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

Add material ui #762

Merged
merged 1 commit into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions clients/admin_next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^1.0.0-rc.1",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-scripts-ts": "2.15.1"
Expand Down
1 change: 1 addition & 0 deletions clients/admin_next/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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`.
-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
<title>React App</title>
</head>
<body>
Expand Down
28 changes: 0 additions & 28 deletions clients/admin_next/src/App.css

This file was deleted.

70 changes: 58 additions & 12 deletions clients/admin_next/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,68 @@
import * as React from 'react';
import './App.css';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
import Typography from '@material-ui/core/Typography';
import withStyles, { WithStyles, StyleRulesCallback } from '@material-ui/core/styles/withStyles';
import withRoot from './withRoot';

import logo from './logo.svg';
const styles: StyleRulesCallback<'root'> = theme => ({
root: {
paddingTop: theme.spacing.unit * 20,
textAlign: 'center',
},
});

interface IState {
open: boolean;
};

class Index extends React.Component<WithStyles<'root'>, IState> {
public state = {
open: false,
};

public handleClose = () => {
this.setState({
open: false,
});
};

public handleClick = () => {
this.setState({
open: true,
});
};

class App extends React.Component {
public render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.tsx</code> and save to reload.
</p>
<div className={this.props.classes.root}>
<Dialog open={this.state.open} onClose={this.handleClose}>
<DialogTitle>Super Secret Password</DialogTitle>
<DialogContent>
<DialogContentText>1-2-3-4-5</DialogContentText>
</DialogContent>
<DialogActions>
<Button color="primary" onClick={this.handleClose}>
OK
</Button>
</DialogActions>
</Dialog>
<Typography variant="display1" gutterBottom={true}>
Material-UI
</Typography>
<Typography variant="subheading" gutterBottom={true}>
example project
</Typography>
<Button variant="raised" color="secondary" onClick={this.handleClick}>
Super Secret Password
</Button>
</div>
);
}
}

export default App;
export default withRoot(withStyles(styles)<{}>(Index));
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this pretty ugly but I don't fully understand it yet so I haven't attempted to clean it up. I was able to only do this once and hide it for the player-app. I plan to leave it for now and look deeper when I work on the general app layout

5 changes: 0 additions & 5 deletions clients/admin_next/src/index.css

This file was deleted.

1 change: 0 additions & 1 deletion clients/admin_next/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App';
import './index.css';

ReactDOM.render(
<App />,
Expand Down
7 changes: 0 additions & 7 deletions clients/admin_next/src/logo.svg

This file was deleted.

32 changes: 32 additions & 0 deletions clients/admin_next/src/withRoot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as React from 'react';
import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';
import purple from '@material-ui/core/colors/purple';
import green from '@material-ui/core/colors/green';
import CssBaseline from '@material-ui/core/CssBaseline';

// A theme with custom primary and secondary color.
// It's optional.
const theme = createMuiTheme({
palette: {
primary: purple,
secondary: green,
},
});

function withRoot(Component: React.ComponentType) {
function WithRoot(props: object) {
// MuiThemeProvider makes the theme available down the React tree
// thanks to React context.
return (
<MuiThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<Component {...props} />
</MuiThemeProvider>
);
}

return WithRoot;
}

export default withRoot;
3 changes: 3 additions & 0 deletions clients/admin_next/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"config/**/*.js",
"node_modules/**/*.ts"
]
},
"rules": {
"ordered-imports": false
}
}
2 changes: 2 additions & 0 deletions clients/admin_next/typings/misc.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module 'jss-preset-default';
declare module 'react-jss/*';
Loading