From dde39e82b5723ba8056b73f0f823d40c3e702a99 Mon Sep 17 00:00:00 2001 From: Alexander Tseung Date: Mon, 4 Dec 2017 01:24:30 -0500 Subject: Add routes for mascara --- mascara/src/app/first-time/backup-phrase-screen.js | 79 ++++++----- .../src/app/first-time/create-password-screen.js | 144 +++++++++++---------- mascara/src/app/first-time/index.css | 5 +- mascara/src/app/first-time/notice-screen.js | 87 +++++++------ 4 files changed, 173 insertions(+), 142 deletions(-) (limited to 'mascara/src') diff --git a/mascara/src/app/first-time/backup-phrase-screen.js b/mascara/src/app/first-time/backup-phrase-screen.js index c68dacea2..266a82cdb 100644 --- a/mascara/src/app/first-time/backup-phrase-screen.js +++ b/mascara/src/app/first-time/backup-phrase-screen.js @@ -1,5 +1,6 @@ -import React, {Component, PropTypes} from 'react' -import {connect} from 'react-redux'; +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import {connect} from 'react-redux' import classnames from 'classnames' import shuffle from 'lodash.shuffle' import {compose, onlyUpdateForPropTypes} from 'recompose' @@ -7,6 +8,7 @@ import Identicon from '../../../../ui/app/components/identicon' import {confirmSeedWords} from '../../../../ui/app/actions' import Breadcrumbs from './breadcrumbs' import LoadingScreen from './loading-screen' +import { DEFAULT_ROUTE } from '../../../../ui/app/routes' const LockIcon = props => ( ( /> -); +) class BackupPhraseScreen extends Component { static propTypes = { isLoading: PropTypes.bool.isRequired, address: PropTypes.string.isRequired, - seedWords: PropTypes.string.isRequired, - next: PropTypes.func.isRequired, + seedWords: PropTypes.string, confirmSeedWords: PropTypes.func.isRequired, + history: PropTypes.object, }; static defaultProps = { - seedWords: '' - }; + seedWords: '', + } static PAGE = { SECRET: 'secret', - CONFIRM: 'confirm' - }; + CONFIRM: 'confirm', + } - constructor(props) { + constructor (props) { const {seedWords} = props super(props) this.state = { @@ -66,13 +68,20 @@ class BackupPhraseScreen extends Component { } } + componentWillMount () { + const { seedWords, history } = this.props + if (!seedWords) { + history.push(DEFAULT_ROUTE) + } + } + renderSecretWordsContainer () { const { isShowingSecret } = this.state return (
{this.props.seedWords}
@@ -88,10 +97,10 @@ class BackupPhraseScreen extends Component {
)} - ); + ) } - renderSecretScreen() { + renderSecretScreen () { const { isShowingSecret } = this.state return ( @@ -109,7 +118,7 @@ class BackupPhraseScreen extends Component { className="first-time-flow__button" onClick={() => isShowingSecret && this.setState({ isShowingSecret: false, - page: BackupPhraseScreen.PAGE.CONFIRM + page: BackupPhraseScreen.PAGE.CONFIRM, })} disabled={!isShowingSecret} > @@ -133,9 +142,9 @@ class BackupPhraseScreen extends Component { ) } - renderConfirmationScreen() { - const { seedWords, confirmSeedWords, next } = this.props; - const { selectedSeeds, shuffledSeeds } = this.state; + renderConfirmationScreen () { + const { seedWords, confirmSeedWords, history } = this.props + const { selectedSeeds, shuffledSeeds } = this.state const isValid = seedWords === selectedSeeds.map(([_, seed]) => seed).join(' ') return ( @@ -165,17 +174,17 @@ class BackupPhraseScreen extends Component { - ) + ) } renderBack () { @@ -205,7 +214,7 @@ class BackupPhraseScreen extends Component { onClick={e => { e.preventDefault() this.setState({ - page: BackupPhraseScreen.PAGE.SECRET + page: BackupPhraseScreen.PAGE.SECRET, }) }} href="#" @@ -227,15 +236,21 @@ class BackupPhraseScreen extends Component { } render () { - return this.props.isLoading - ? - : ( -
- {this.renderBack()} - - {this.renderContent()} -
- ) + return ( +
+ { + this.props.isLoading + ? + : ( +
+ {this.renderBack()} + + {this.renderContent()} +
+ ) + } +
+ ) } } diff --git a/mascara/src/app/first-time/create-password-screen.js b/mascara/src/app/first-time/create-password-screen.js index 2f4b81e7c..102d8a7c3 100644 --- a/mascara/src/app/first-time/create-password-screen.js +++ b/mascara/src/app/first-time/create-password-screen.js @@ -1,103 +1,109 @@ -import React, {Component, PropTypes} from 'react' -import {connect} from 'react-redux'; -import {createNewVaultAndKeychain} from '../../../../ui/app/actions' +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import {connect} from 'react-redux' +import { createNewVaultAndKeychain } from '../../../../ui/app/actions' import LoadingScreen from './loading-screen' import Breadcrumbs from './breadcrumbs' +import { DEFAULT_ROUTE, IMPORT_ACCOUNT_ROUTE } from '../../../../ui/app/routes' class CreatePasswordScreen extends Component { static propTypes = { isLoading: PropTypes.bool.isRequired, createAccount: PropTypes.func.isRequired, - goToImportWithSeedPhrase: PropTypes.func.isRequired, - goToImportAccount: PropTypes.func.isRequired, - next: PropTypes.func.isRequired + history: PropTypes.object.isRequired, } state = { password: '', - confirmPassword: '' + confirmPassword: '', } - isValid() { - const {password, confirmPassword} = this.state; + isValid () { + const { password, confirmPassword } = this.state if (!password || !confirmPassword) { - return false; + return false } if (password.length < 8) { - return false; + return false } - return password === confirmPassword; + return password === confirmPassword } createAccount = () => { if (!this.isValid()) { - return; + return } - const {password} = this.state; - const {createAccount, next} = this.props; + const { password } = this.state + const { createAccount, history } = this.props createAccount(password) - .then(next); + .then(() => history.push(DEFAULT_ROUTE)) } - render() { - const { isLoading, goToImportAccount, goToImportWithSeedPhrase } = this.props + render () { + const { isLoading } = this.props - return isLoading - ? - : ( -
-
- Create Password -
- this.setState({password: e.target.value})} - /> - this.setState({confirmPassword: e.target.value})} - /> - - { - e.preventDefault() - goToImportWithSeedPhrase() - }} - > - Import with seed phrase - - { /* } - { - e.preventDefault() - goToImportAccount() - }} - > - Import an account - - { */ } - -
- ) + return ( +
+ { + isLoading + ? + : ( +
+
+ Create Password +
+ this.setState({password: e.target.value})} + /> + this.setState({confirmPassword: e.target.value})} + /> + + { + e.preventDefault() + history.push(IMPORT_ACCOUNT_ROUTE) + }} + > + Import with seed phrase + + { /* } + { + e.preventDefault() + goToImportAccount() + }} + > + Import an account + + { */ } + +
+ ) + } +
+ ) } } diff --git a/mascara/src/app/first-time/index.css b/mascara/src/app/first-time/index.css index 28aa3060a..157989d07 100644 --- a/mascara/src/app/first-time/index.css +++ b/mascara/src/app/first-time/index.css @@ -75,7 +75,7 @@ .backup-phrase__tips { margin: 40px 0 !important; - width: initial !important; + width: initial !important; } .backup-phrase__confirm-secret, @@ -337,7 +337,7 @@ button.backup-phrase__confirm-seed-option:hover { padding: 14px 21px; appearance: none; -webkit-appearance: none; - -moz-appearance: none; + -moz-appearance: none; cursor: pointer; } @@ -540,6 +540,7 @@ button.backup-phrase__confirm-seed-option:hover { text-transform: uppercase; margin: 35px 0 14px; transition: 200ms ease-in-out; + background: #f7861c; } button.first-time-flow__button[disabled] { diff --git a/mascara/src/app/first-time/notice-screen.js b/mascara/src/app/first-time/notice-screen.js index d09070a95..be54b9fc0 100644 --- a/mascara/src/app/first-time/notice-screen.js +++ b/mascara/src/app/first-time/notice-screen.js @@ -1,10 +1,12 @@ -import React, {Component, PropTypes} from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import Markdown from 'react-markdown' -import {connect} from 'react-redux' +import { connect } from 'react-redux' import debounce from 'lodash.debounce' -import {markNoticeRead} from '../../../../ui/app/actions' +import { markNoticeRead } from '../../../../ui/app/actions' import Identicon from '../../../../ui/app/components/identicon' import Breadcrumbs from './breadcrumbs' +import { DEFAULT_ROUTE } from '../../../../ui/app/routes' class NoticeScreen extends Component { static propTypes = { @@ -12,70 +14,77 @@ class NoticeScreen extends Component { lastUnreadNotice: PropTypes.shape({ title: PropTypes.string, date: PropTypes.string, - body: PropTypes.string + body: PropTypes.string, }), - next: PropTypes.func.isRequired + location: PropTypes.shape({ + state: PropTypes.shape({ + next: PropTypes.func.isRequired, + }), + }), + markNoticeRead: PropTypes.func, + history: PropTypes.object, }; static defaultProps = { - lastUnreadNotice: {} + lastUnreadNotice: {}, }; state = { atBottom: false, } - componentDidMount() { + componentDidMount () { this.onScroll() } acceptTerms = () => { - const { markNoticeRead, lastUnreadNotice, next } = this.props; - const defer = markNoticeRead(lastUnreadNotice) - .then(() => this.setState({ atBottom: false })) - - if ((/terms/gi).test(lastUnreadNotice.title)) { - defer.then(next) - } + const { markNoticeRead, lastUnreadNotice, history } = this.props + markNoticeRead(lastUnreadNotice) + .then(() => { + history.push(DEFAULT_ROUTE) + this.setState({ atBottom: false }) + }) } onScroll = debounce(() => { if (this.state.atBottom) return const target = document.querySelector('.tou__body') - const {scrollTop, offsetHeight, scrollHeight} = target; - const atBottom = scrollTop + offsetHeight >= scrollHeight; + const {scrollTop, offsetHeight, scrollHeight} = target + const atBottom = scrollTop + offsetHeight >= scrollHeight this.setState({atBottom: atBottom}) }, 25) - render() { + render () { const { address, - lastUnreadNotice: { title, body } - } = this.props; + lastUnreadNotice: { title, body }, + } = this.props const { atBottom } = this.state return ( -
- -
{title}
- - - + +
{title}
+ + + +
) } @@ -84,9 +93,9 @@ class NoticeScreen extends Component { export default connect( ({ metamask: { selectedAddress, lastUnreadNotice } }) => ({ lastUnreadNotice, - address: selectedAddress + address: selectedAddress, }), dispatch => ({ - markNoticeRead: notice => dispatch(markNoticeRead(notice)) + markNoticeRead: notice => dispatch(markNoticeRead(notice)), }) )(NoticeScreen) -- cgit