Skip to content

Commit f585b9d

Browse files
committed
frontend: update sidebar to use connected-keystore component
Use connected-keystore in the sidebar. The sidebar connected icon is shown without badge text. Added a prop to force rendering the badge without text so it only shows the icon.
1 parent 5973f9e commit f585b9d

File tree

3 files changed

+36
-32
lines changed

3 files changed

+36
-32
lines changed

frontends/web/src/components/keystore/connected-keystore.module.css

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
.keystore {
2-
align-items: baseline;
3-
display: flex;
42
font-size: var(--size-default);
53
gap: var(--space-quarter);
4+
word-break: break-word;
5+
}
6+
7+
.keystoreName {
8+
color: inherit;
9+
}
10+
11+
.keystore small {
12+
color: var(--color-secondary);
13+
font-size: var(--size-xsmall);
614
}
715

816
@media (min-width: 1200px) {

frontends/web/src/components/keystore/connected-keystore.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,42 @@ import style from './connected-keystore.module.css';
2323

2424
type Props = {
2525
accountsByKeystore: TAccountsByKeystore[];
26-
keystore: TKeystore;
2726
className?: string;
27+
connectedIconOnly?: boolean;
28+
keystore: TKeystore;
2829
};
2930

3031
export const ConnectedKeystore = ({
3132
accountsByKeystore,
32-
keystore,
3333
className,
34+
connectedIconOnly,
35+
keystore,
3436
}: Props) => {
3537
const { t } = useTranslation();
3638
const classNames = className ? `${style.keystore} ${className}` : style.keystore;
3739

3840
return (
3941
<span className={classNames}>
40-
{keystore.name}
42+
<span className={style.keystoreName}>{keystore.name}</span>
4143
{isAmbiguousName(keystore.name, accountsByKeystore) ? (
4244
// Disambiguate accounts group by adding the fingerprint.
4345
// The most common case where this would happen is when adding accounts from the
4446
// same seed using different passphrases.
45-
` (${keystore.rootFingerprint})`
47+
<>
48+
{' '}
49+
<small>({keystore.rootFingerprint})</small>
50+
</>
4651
) : null}
4752
{keystore.connected && (
48-
<Badge
49-
icon={props => <USBSuccess {...props} />}
50-
title={t('device.keystoreConnected')}
51-
type="success">
52-
{t('device.keystoreConnected')}
53-
</Badge>
53+
<>
54+
{' '}
55+
<Badge
56+
icon={props => <USBSuccess {...props} />}
57+
title={t('device.keystoreConnected')}
58+
type="success">
59+
{connectedIconOnly ? undefined : t('device.keystoreConnected')}
60+
</Badge>
61+
</>
5462
)}
5563
</span>
5664
);

frontends/web/src/components/sidebar/sidebar.tsx

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ import { deregisterTest } from '@/api/keystores';
2525
import { getVersion } from '@/api/bitbox02';
2626
import { debug } from '@/utils/env';
2727
import { AppLogoInverted, Logo } from '@/components/icon/logo';
28-
import { CloseXWhite, Cog, CogGray, Coins, Device, Eject, Linechart, RedDot, ShieldGray, USBSuccess } from '@/components/icon';
29-
import { getAccountsByKeystore, isAmbiguousName } from '@/routes/account/utils';
28+
import { CloseXWhite, Cog, CogGray, Coins, Device, Eject, Linechart, RedDot, ShieldGray } from '@/components/icon';
29+
import { getAccountsByKeystore } from '@/routes/account/utils';
3030
import { SkipForTesting } from '@/routes/device/components/skipfortesting';
31-
import { Badge } from '@/components/badge/badge';
3231
import { AppContext } from '@/contexts/AppContext';
3332
import { Button } from '@/components/forms';
33+
import { ConnectedKeystore } from '../keystore/connected-keystore';
3434
import style from './sidebar.module.css';
3535

3636
type SidebarProps = {
@@ -141,24 +141,12 @@ const Sidebar = ({
141141
{ accountsByKeystore.map(keystore => (
142142
<div key={`keystore-${keystore.keystore.rootFingerprint}`}>
143143
<div className={style.sidebarHeaderContainer}>
144-
<span
144+
<ConnectedKeystore
145+
accountsByKeystore={accountsByKeystore}
145146
className={style.sidebarHeader}
146-
hidden={!keystore.accounts.length}>
147-
<span className="p-right-quarter">
148-
{`${keystore.keystore.name} `}
149-
{ isAmbiguousName(keystore.keystore.name, accountsByKeystore) ? (
150-
// Disambiguate accounts group by adding the fingerprint.
151-
// The most common case where this would happen is when adding accounts from the
152-
// same seed using different passphrases.
153-
<> ({keystore.keystore.rootFingerprint})</>
154-
) : null }
155-
</span>
156-
<Badge
157-
className={keystore.keystore.connected ? style.sidebarIconVisible : style.sidebarIconHidden}
158-
icon={props => <USBSuccess {...props} />}
159-
type="success"
160-
title={t('device.keystoreConnected')} />
161-
</span>
147+
keystore={keystore.keystore}
148+
connectedIconOnly={true}
149+
/>
162150
</div>
163151
{ keystore.accounts.map(acc => (
164152
<GetAccountLink key={`account-${acc.code}`} {...acc} handleSidebarItemClick={handleSidebarItemClick} />

0 commit comments

Comments
 (0)