-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add material ui #762
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,8 @@ | |
"config/**/*.js", | ||
"node_modules/**/*.ts" | ||
] | ||
}, | ||
"rules": { | ||
"ordered-imports": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare module 'jss-preset-default'; | ||
declare module 'react-jss/*'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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