Skip to content

Commit 7b62576

Browse files
committed
frontend: styled keystoreconnectpromp component
1 parent 99faf26 commit 7b62576

File tree

3 files changed

+91
-18
lines changed

3 files changed

+91
-18
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.bitboxContainer {
2+
margin-top: calc(var(--space-default) + var(--space-quarter));
3+
margin-bottom: calc(var(--space-default) + var(--space-quarter));
4+
}
5+
6+
.bitboxContainer > div img {
7+
width: 198px;
8+
height: 115px;
9+
margin-right: var(--space-default);
10+
}
11+
12+
.bitboxContainer > div svg {
13+
width: 20px;
14+
height: 20px;
15+
}
16+
17+
18+
.bitboxContainer.failed {
19+
align-items: center;
20+
display: flex;
21+
flex-direction: column;
22+
}
23+
24+
.bitboxImage {
25+
width: 198px;
26+
height: 115px;
27+
}
28+
29+
.cancelIcon {
30+
margin-right: 16px;
31+
width: 48px;
32+
width: 48px;
33+
}
34+
35+
.text {
36+
font-size: 16px;
37+
}
38+
39+
@media (max-width: 768px) {
40+
.text {
41+
font-size: var(--size-default);
42+
}
43+
}

frontends/web/src/components/keystoreconnectprompt.tsx

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,68 @@ import { useTranslation } from 'react-i18next';
1818
import { Button } from './forms';
1919
import { cancelConnectKeystore, syncConnectKeystore } from '../api/backend';
2020
import { useSubscribeReset } from '../hooks/api';
21+
import { Dialog, DialogButtons } from './dialog/dialog';
22+
import { BitBox02StylizedDark, BitBox02StylizedLight, Cancel, PointToBitBox02 } from './icon';
23+
import { useDarkmode } from '../hooks/darkmode';
2124
import { SkipForTesting } from '../routes/device/components/skipfortesting';
25+
import styles from './keystoreconnectprompt.module.css';
2226

2327
export function KeystoreConnectPrompt() {
2428
const { t } = useTranslation();
29+
const { isDarkMode } = useDarkmode();
2530

2631
const [data, reset] = useSubscribeReset(syncConnectKeystore());
2732
if (!data) {
2833
return null;
2934
}
3035
switch (data.typ) {
3136
case 'connect':
32-
// TODO: make this look nice.
3337
return (
34-
<>
35-
{ data.keystoreName === '' ?
38+
<Dialog title={t('welcome.connect')} medium open>
39+
<p className={styles.text}>{ data.keystoreName === '' ?
3640
t('connectKeystore.promptNoName') :
3741
t('connectKeystore.promptWithName', { name: data.keystoreName })
38-
}
39-
{/* Software keystore is unlocked from the app, so we add the button here.
40-
The BitBox02 unlock is triggered by inserting it using the globally mounted BitBox02Wizard.
41-
Te BitBox01 is ignored - BitBox01 users will simply need to unlock before being prompted.
42+
}.
43+
</p>
44+
<div className={styles.bitboxContainer}>
45+
{/*
46+
Software keystore is unlocked from the app, so we add the SkipForTesting button here (only for development).
47+
The BitBox02 unlock is triggered by inserting it using the globally mounted BitBox02Wizard.
48+
The BitBox01 is ignored - BitBox01 users will simply need to unlock before being prompted.
4249
*/}
43-
<SkipForTesting />
44-
<Button primary onClick={() => cancelConnectKeystore()}>{t('dialog.cancel')}</Button>
45-
</>
50+
<PointToBitBox02 />
51+
<SkipForTesting />
52+
</div>
53+
<DialogButtons>
54+
<Button secondary onClick={() => cancelConnectKeystore()}>{t('dialog.cancel')}</Button>
55+
</DialogButtons>
56+
</Dialog>
4657
);
4758
case 'error':
4859
return (
49-
<>
50-
{ data.errorCode === 'wrongKeystore' ? t('error.wrongKeystore') : data.errorMessage }
51-
<Button primary onClick={() => reset()}>{t('button.dismiss')}</Button>
52-
</>
60+
<Dialog title={t('welcome.connect')} medium open>
61+
<p className={styles.text}>
62+
{data.errorCode === 'wrongKeystore' ?
63+
<>
64+
{t('error.wrongKeystore')}
65+
<br />
66+
<br />
67+
{t('error.wrongKeystore2')}
68+
</> : data.errorMessage}
69+
</p>
70+
<div className={`${styles.bitboxContainer} ${styles.failed}`}>
71+
<Cancel className={styles.cancelIcon} />
72+
{isDarkMode ?
73+
<BitBox02StylizedLight className={styles.bitboxImage} /> :
74+
<BitBox02StylizedDark className={styles.bitboxImage} />
75+
}
76+
</div>
77+
<DialogButtons>
78+
<Button secondary onClick={() => reset()}>{t('dialog.cancel')}</Button>
79+
</DialogButtons>
80+
</Dialog>
5381
);
5482
default:
5583
return null;
5684
}
57-
}
85+
}

frontends/web/src/locales/en/app.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,8 @@
488488
},
489489
"confirmOnDevice": "Please confirm on your device.",
490490
"connectKeystore": {
491-
"promptNoName": "Please connect your BitBox02",
492-
"promptWithName": "Please connect your BitBox02 named \"{{name}}\""
491+
"promptNoName": "Please connect your BitBox02 to continue",
492+
"promptWithName": "Please connect your BitBox02 named \"{{name}}\" to continue"
493493
},
494494
"darkmode": {
495495
"toggle": "Dark mode"
@@ -611,7 +611,8 @@
611611
"aoppUnsupportedFormat": "There are no available accounts that support the requested address format.",
612612
"aoppUnsupportedKeystore": "The connected device cannot sign messages for this asset.",
613613
"aoppVersion": "Unknown version.",
614-
"wrongKeystore": "Wrong wallet connected - please make sure to insert the correct device matching this account. If you use the optional passphrase, make sure to use the passphrase matching this account."
614+
"wrongKeystore": "Wrong wallet connected. Please make sure to insert the correct device matching this account.",
615+
"wrongKeystore2": " If you are using the optional passphrase, make sure you have entered the correct passphrase for the account."
615616
},
616617
"fiat": {
617618
"default": "default",
@@ -1551,6 +1552,7 @@
15511552
"sendPairing": "Please pair the BitBox to securely verify transaction details. Go to 'Manage device' in the sidebar."
15521553
},
15531554
"welcome": {
1555+
"connect": "Connect BitBox02",
15541556
"getStarted": "Let's get started by installing firmware on your BitBox02.",
15551557
"insertBitBox02": "For the BitBox02, please tap the device to continue.",
15561558
"insertDevice": "Please connect your device to get started",

0 commit comments

Comments
 (0)