1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 19:10:22 +01:00
metamask-extension/ui/app/welcome-screen.js

84 lines
2.0 KiB
JavaScript
Raw Normal View History

import EventEmitter from 'events'
import h from 'react-hyperscript'
import { Component } from 'react'
import PropTypes from 'prop-types'
import {connect} from 'react-redux'
2018-04-02 11:59:49 +02:00
import { withRouter } from 'react-router-dom'
import { compose } from 'recompose'
import {closeWelcomeScreen} from './actions'
import Mascot from './components/mascot'
2018-04-02 11:59:49 +02:00
import { INITIALIZE_CREATE_PASSWORD_ROUTE } from './routes'
class WelcomeScreen extends Component {
static propTypes = {
closeWelcomeScreen: PropTypes.func.isRequired,
2018-04-03 01:24:37 +02:00
welcomeScreenSeen: PropTypes.bool,
history: PropTypes.object,
2018-06-06 20:38:57 +02:00
t: PropTypes.func,
}
static contextTypes = {
t: PropTypes.func,
}
constructor (props) {
super(props)
this.animationEventEmitter = new EventEmitter()
}
2018-04-02 11:59:49 +02:00
componentWillMount () {
const { history, welcomeScreenSeen } = this.props
if (welcomeScreenSeen) {
history.push(INITIALIZE_CREATE_PASSWORD_ROUTE)
}
}
initiateAccountCreation = () => {
this.props.closeWelcomeScreen()
2018-04-02 11:59:49 +02:00
this.props.history.push(INITIALIZE_CREATE_PASSWORD_ROUTE)
}
render () {
return h('div.welcome-screen', [
h('div.welcome-screen__info', [
h(Mascot, {
animationEventEmitter: this.animationEventEmitter,
width: '225',
height: '225',
}),
2018-06-06 20:38:57 +02:00
h('div.welcome-screen__info__header', this.context.t('welcomeBeta')),
2018-06-06 20:38:57 +02:00
h('div.welcome-screen__info__copy', this.context.t('metamaskDescription')),
2018-06-06 20:38:57 +02:00
h('div.welcome-screen__info__copy', this.context.t('holdEther')),
h('button.welcome-screen__button', {
onClick: this.initiateAccountCreation,
2018-06-06 20:38:57 +02:00
}, this.context.t('continue')),
]),
])
}
}
2018-04-02 11:59:49 +02:00
const mapStateToProps = ({ metamask: { welcomeScreenSeen } }) => {
return {
welcomeScreenSeen,
}
}
export default compose(
withRouter,
connect(
mapStateToProps,
dispatch => ({
closeWelcomeScreen: () => dispatch(closeWelcomeScreen()),
})
)
)(WelcomeScreen)