2017-04-22 12:52:49 +00:00
|
|
|
import React, {Component} from 'react'
|
|
|
|
import RaisedButton from 'material-ui/RaisedButton'
|
|
|
|
import Dialog from 'material-ui/Dialog'
|
|
|
|
import {deepOrange500} from 'material-ui/styles/colors'
|
|
|
|
import FlatButton from 'material-ui/FlatButton'
|
|
|
|
import getMuiTheme from 'material-ui/styles/getMuiTheme'
|
|
|
|
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'
|
|
|
|
import injectTapEventPlugin from 'react-tap-event-plugin'
|
|
|
|
|
2017-05-07 13:51:12 +00:00
|
|
|
// Make sure react-tap-event-plugin only gets injected once
|
|
|
|
// Needed for material-ui
|
|
|
|
if (!process.tapEventInjected) {
|
|
|
|
injectTapEventPlugin()
|
|
|
|
process.tapEventInjected = true
|
2017-04-22 12:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const styles = {
|
|
|
|
container: {
|
|
|
|
textAlign: 'center',
|
|
|
|
paddingTop: 200
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-07 13:51:12 +00:00
|
|
|
const muiTheme = {
|
2017-04-22 12:52:49 +00:00
|
|
|
palette: {
|
|
|
|
accent1Color: deepOrange500
|
|
|
|
}
|
2017-05-07 13:51:12 +00:00
|
|
|
}
|
2017-04-22 12:52:49 +00:00
|
|
|
|
2017-05-25 16:36:21 +00:00
|
|
|
class Index extends Component {
|
2017-04-22 12:52:49 +00:00
|
|
|
static getInitialProps ({ req }) {
|
2017-05-07 13:51:12 +00:00
|
|
|
// Ensures material-ui renders the correct css prefixes server-side
|
|
|
|
let userAgent
|
|
|
|
if (process.browser) {
|
|
|
|
userAgent = navigator.userAgent
|
|
|
|
} else {
|
|
|
|
userAgent = req.headers['user-agent']
|
|
|
|
}
|
|
|
|
|
|
|
|
return { userAgent }
|
2017-04-22 12:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor (props, context) {
|
|
|
|
super(props, context)
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
open: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleRequestClose = () => {
|
|
|
|
this.setState({
|
|
|
|
open: false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
handleTouchTap = () => {
|
|
|
|
this.setState({
|
|
|
|
open: true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2017-05-07 13:51:12 +00:00
|
|
|
const { userAgent } = this.props
|
|
|
|
|
2017-04-22 12:52:49 +00:00
|
|
|
const standardActions = (
|
|
|
|
<FlatButton
|
|
|
|
label='Ok'
|
|
|
|
primary={Boolean(true)}
|
|
|
|
onTouchTap={this.handleRequestClose}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
2017-05-07 13:51:12 +00:00
|
|
|
<MuiThemeProvider muiTheme={getMuiTheme({userAgent, ...muiTheme})}>
|
2017-04-22 12:52:49 +00:00
|
|
|
<div style={styles.container}>
|
|
|
|
<Dialog
|
|
|
|
open={this.state.open}
|
|
|
|
title='Super Secret Password'
|
|
|
|
actions={standardActions}
|
|
|
|
onRequestClose={this.handleRequestClose}
|
|
|
|
>
|
|
|
|
1-2-3-4-5
|
|
|
|
</Dialog>
|
|
|
|
<h1>Material-UI</h1>
|
|
|
|
<h2>example project</h2>
|
|
|
|
<RaisedButton
|
|
|
|
label='Super Secret Password'
|
2017-05-25 16:36:21 +00:00
|
|
|
secondary
|
2017-04-22 12:52:49 +00:00
|
|
|
onTouchTap={this.handleTouchTap}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</MuiThemeProvider>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-25 16:36:21 +00:00
|
|
|
export default Index
|