on master help sign in
- More styling touches on invite flow
commit1ec514b11ea3f47e856d66fafceab674296cf307 authorChris Johnson <chris@cjohnson.io> dateMon 22 Apr 2019, 04:49 (8 years ago) parent4c52e05
5 files changed+104−69
src/bridge/components/Passport.js+45−44 src/bridge/lib/invite.js+18−1 src/bridge/style/button.css+4 src/bridge/style/extend.css+4−1 src/bridge/views/InviteLogin.js+33−23
src/bridge/components/Passport.js+45−44
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types'
66import PaperCollateralRenderer from 'PaperCollateralRenderer'
77import { Button } from './Base'
88
9+import { WALLET_STATES } from '../lib/invite'
910import { downloadWallet } from '../lib/invite'
1011
1112class Passport extends React.Component {
@@ -58,8 +59,6 @@ class Passport extends React.Component {
5859 }
5960
6061 getWalletStates() {
61− console.log('walletStates = ', this.props.walletStates)
62−
6362 let stateElems = this.props.walletStates.map(state => {
6463 return (
6564 <div className="flex justify-between">
@@ -106,57 +105,59 @@ class Passport extends React.Component {
106105
107106 let currentDate = this.getCurrentDate()
108107 let walletStates = this.getWalletStates()
108+ let paperReady = this.state.paper && this.props.walletStates.includes(WALLET_STATES.PAPER_READY)
109+ let downloadColor = paperReady ? 'green' : 'black'
109110
110111 return (
111112 <div>
112− <div className={`passport ${wallet && 'passport-filled'}`}>
113− <div className="flex">
114− <div className="passport-sigil">
115− {sigil}
113+ <div className="passport-border">
114+ <div className={`passport ${paperReady && 'passport-filled'}`}>
115+ <div className="flex">
116+ <div className="passport-sigil">
117+ {sigil}
118+ </div>
119+ <div className="passport-metadata ml-4">
120+ <div className="passport-label text-mono">Point</div>
121+ <div className="text-mono">{patp || '-'}</div>
122+
123+ <div className="passport-label gray-50 mt-6">Created on</div>
124+ <div className="passport-value">{patp ? currentDate : '-' }</div>
125+
126+ <div className="passport-label gray-50 mt-2">Invited by</div>
127+ <div className="passport-value">{this.props.invitedBy || '-'}</div>
128+ </div>
116129 </div>
117− <div className="passport-metadata ml-4">
118− <div className="passport-label text-mono">Point</div>
119− <div className="text-mono">{patp || '-'}</div>
120130
121− <div className="passport-label gray-50 mt-6">Created on</div>
122− <div className="passport-value">{patp ? currentDate : '-' }</div>
131+ <div className="mt-8">
132+ <div className="passport-label text-mono">Ethereum Address</div>
133+ <div className="passport-value">{ownershipAddress || 'Ungenerated'}</div>
134+
135+ <div className="passport-label gray-50 mt-3">Master Ticket</div>
136+ <div className="passport-value">{ownershipAddress ? this.masterScreen : 'Ungenerated'}</div>
123137
124− <div className="passport-label gray-50 mt-2">Invited by</div>
125− <div className="passport-value">{this.props.invitedBy || '-'}</div>
138+ <div className="passport-label gray-50 mt-5">Managment Seed</div>
139+ <div className="passport-value">{ownershipAddress ? this.managementScreen : 'Ungenerated'}</div>
126140 </div>
127− </div>
128141
129− <div className="mt-8">
130− <div className="passport-label text-mono">Ethereum Address</div>
131− <div className="passport-value">{ownershipAddress || 'Ungenerated'}</div>
132−
133− <div className="passport-label gray-50 mt-3">Master Ticket</div>
134− <div className="passport-value">{ownershipAddress ? this.masterScreen : 'Ungenerated'}</div>
135−
136− <div className="passport-label gray-50 mt-5">Managment Seed</div>
137− <div className="passport-value">{ownershipAddress ? this.managementScreen : 'Ungenerated'}</div>
138−
139− <Button
140− disabled={ !this.state.paper }
141− className={ 'mt-8' }
142− prop-size={ 'lg wide' }
143− prop-color={ 'green' }
144− onClick={ this.download }
145− >
146− { 'Download' }
147− </Button>
142+ {wallet &&
143+ <PaperCollateralRenderer
144+ wallet={{[this.props.point.value]: wallet}}
145+ className={'extremely-hidden'}
146+ callback={data => {
147+ this.setState({paper: data})
148+ this.props.pushWalletState(WALLET_STATES.PAPER_READY)
149+ }}
150+ mode={'REGISTRATION'} />
151+ }
148152 </div>
149−
150− {wallet &&
151− <PaperCollateralRenderer
152− wallet={{[this.props.point.value]: wallet}}
153− className={'extremely-hidden'}
154− callback={data => {
155− console.log('paper wallet generated')
156− this.setState({paper: data})
157− }}
158− mode={'REGISTRATION'} />
159− }
153+ <Button
154+ disabled={ !paperReady }
155+ prop-size={ 'lg wide' }
156+ prop-color={ downloadColor }
157+ onClick={ this.download }
158+ >
159+ { 'Download' }
160+ </Button>
160161 </div>
161162 <div className="passport-wallet-states mt-3">
162163 {walletStates}
src/bridge/lib/invite.js+18−1
@@ -14,6 +14,21 @@ import saveAs from 'file-saver'
1414const NEXT_STEP_NUM = 6;
1515const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8
1616
17+const INVITE_STAGES = {
18+ INVITE_LOGIN: "invite login",
19+ INVITE_WALLET: "invite wallet",
20+ INVITE_VERIFY: "invite verify",
21+ INVITE_TRANSACTIONS: "invite transactions"
22+}
23+
24+const WALLET_STATES = {
25+ UNLOCKING: "Unlocking invite wallet",
26+ GENERATING: "Generating your wallet",
27+ GENERATED: "Wallet generation complete",
28+ PAPER_READY: "Paper collateral generated",
29+ DOWNLOADED: "Wallet downloaded"
30+}
31+
1732async function generateWallet(point) {
1833 const makeTicket = point => {
1934
@@ -104,5 +119,7 @@ async function downloadWallet(paper) {
104119
105120export {
106121 generateWallet,
107− downloadWallet
122+ downloadWallet,
123+ INVITE_STAGES,
124+ WALLET_STATES
108125}
src/bridge/style/button.css+4
@@ -54,6 +54,10 @@ button[prop-type='solid'][prop-color='green']:focus {
5454 box-shadow: 0 0 0 3px #C5FBE7;
5555}
5656
57+button[prop-type='solid'][prop-color='green']:disabled {
58+ background-color: #C5FBE7;
59+}
60+
5761button[prop-type='solid'][prop-color='yellow'] {
5862 background-color: #F8C134;
5963 border-color: #F8C134;
src/bridge/style/extend.css+4−1
@@ -499,7 +499,6 @@ code {
499499**/
500500
501501.passport {
502− border: 1px solid #C5FBE7;
503502 padding: 24px;
504503}
505504
@@ -512,6 +511,10 @@ code {
512511 background-color: #C5FBE7;
513512}
514513
514+.passport-border {
515+ border: 1px solid #C5FBE7;
516+}
517+
515518.passport-block {
516519 width: 8px;
517520 height: 8px;
src/bridge/views/InviteLogin.js+33−23
@@ -10,6 +10,7 @@ import { ROUTE_NAMES } from '../lib/router'
1010import { DEFAULT_HD_PATH, urbitWalletFromTicket,
1111 walletFromMnemonic, addressFromSecp256k1Public } from '../lib/wallet'
1212import { BRIDGE_ERROR } from '../lib/error'
13+import { INVITE_STAGES, WALLET_STATES } from '../lib/invite'
1314import { generateWallet } from '../lib/invite'
1415
1516const placeholder = (len) => {
@@ -21,20 +22,6 @@ const placeholder = (len) => {
2122 return ob.hex2patq(hex)
2223}
2324
24−const INVITE_STAGES = {
25− INVITE_LOGIN: "invite login",
26− INVITE_WALLET: "invite wallet",
27− INVITE_VERIFY: "invite verify",
28− INVITE_TRANSACTIONS: "invite transactions"
29−}
30−
31−const WALLET_STATES = {
32− UNLOCKING: "Unlocking invite wallet",
33− GENERATING: "Generating your wallet",
34− GENERATED: "Wallet generation complete",
35− DOWNLOADED: "Wallet downloaded"
36−}
37−
3825class InviteLogin extends React.Component {
3926
4027 constructor(props) {
@@ -46,7 +33,6 @@ class InviteLogin extends React.Component {
4633 realPoint: Nothing(),
4734 realWallet: Nothing(),
4835 walletReady: false,
49− continueReady: true,
5036 stage: INVITE_STAGES.INVITE_LOGIN,
5137 walletStates: []
5238 }
@@ -57,9 +43,16 @@ class InviteLogin extends React.Component {
5743 this.handleInviteTicketInput = this.handleInviteTicketInput.bind(this)
5844 this.handleVerifyTicketInput = this.handleVerifyTicketInput.bind(this)
5945 this.confirmWalletDownload = this.confirmWalletDownload.bind(this)
46+ this.pushWalletState = this.pushWalletState.bind(this)
6047 this.navigateLogin = this.navigateLogin.bind(this)
6148 }
6249
50+ pushWalletState(walletState) {
51+ this.setState({
52+ walletStates: this.state.walletStates.concat(walletState)
53+ })
54+ }
55+
6356 navigateLogin() {
6457 this.props.popRoute()
6558 this.props.pushRoute(ROUTE_NAMES.NETWORK)
@@ -75,13 +68,12 @@ class InviteLogin extends React.Component {
7568
7669 confirmWalletDownload() {
7770 this.setState({
78− continueReady: true
71+ walletStates: this.state.walletStates.concat(WALLET_STATES.DOWNLOADED),
7972 })
8073 }
8174
8275 async unlockInviteWallet(inviteTicket) {
8376 this.setState({
84− continueReady: false,
8577 walletStates: this.state.walletStates.concat(WALLET_STATES.UNLOCKING),
8678 stage: INVITE_STAGES.INVITE_WALLET
8779 });
@@ -172,12 +164,20 @@ class InviteLogin extends React.Component {
172164 case INVITE_STAGES.INVITE_WALLET:
173165 return (
174166 <div>
175− <h1 className="fs-6 lh-8">Welcome</h1>
167+ <h1 className="fs-6 lh-8 mb-3">Passport</h1>
176168 <p>A passport is your digital identity. You will use your passport to access your true computer, send payments, and administer your identity. So naturally, you must keep this secure.</p>
177169 <p>After you’ve downloaded your passport, back up the ticket manually or store on a trusted device.</p>
178170 </div>
179171 )
180172 break
173+ case INVITE_STAGES.INVITE_VERIFY:
174+ return (
175+ <div>
176+ <h1 className="fs-6 lh-8 mb-3">Verify Passport</h1>
177+ <p>Afer you download your passport, verify your custody. Your passport should be a folder of image files. One of them is your Master Ticket. Open it and enter the 4 word phrase below (with hyphens).</p>
178+ </div>
179+ )
180+ break
181181 }
182182 }
183183
@@ -185,18 +185,27 @@ class InviteLogin extends React.Component {
185185 if (this.state.stage === INVITE_STAGES.INVITE_TRANSACTIONS) return null
186186
187187 let clickHandler
188− let btnColor
188+ let btnColor = this.state.walletStates.includes(WALLET_STATES.PAPER_READY)
189+ ? 'green'
190+ : 'black'
191+ let continueReady
189192
190193 switch(this.state.stage) {
191194 case INVITE_STAGES.INVITE_LOGIN:
192195 clickHandler = () => {
193196 this.unlockInviteWallet(this.state.inviteTicket)
194197 }
195− btnColor = "black"
198+ continueReady = true
196199 break
197− case INVITE_STAGES.INVITE_VERIFY:
198200 case INVITE_STAGES.INVITE_WALLET:
199− btnColor = "green"
201+ clickHandler = () => {
202+ this.setState({
203+ stage: INVITE_STAGES.INVITE_VERIFY
204+ })
205+ }
206+ continueReady = this.state.walletStates.includes(WALLET_STATES.DOWNLOADED)
207+ break
208+ case INVITE_STAGES.INVITE_VERIFY:
200209 break
201210 }
202211
@@ -205,7 +214,7 @@ class InviteLogin extends React.Component {
205214 className={'mt-4'}
206215 prop-size={'lg'}
207216 prop-color={btnColor}
208− disabled={!this.state.continueReady}
217+ disabled={!continueReady}
209218 onClick={clickHandler}
210219 >
211220 { 'Continue →' }
@@ -258,6 +267,7 @@ class InviteLogin extends React.Component {
258267 point={this.state.realPoint}
259268 wallet={this.state.realWallet}
260269 walletStates={this.state.walletStates}
270+ pushWalletState={this.pushWalletState}
261271 confirmWalletDownload={this.confirmWalletDownload}
262272 />
263273 </Col>