-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
copy in code from material-ui typescript example (and edit for typesc…
…ript errors)
- Loading branch information
1 parent
87f8306
commit f50a89e
Showing
11 changed files
with
407 additions
and
58 deletions.
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.