Skip to content

Commit ea756e0

Browse files
author
Tadashi Jeffrey Okazaki
committed
frontend: hide sidebar during setup
1 parent bc18124 commit ea756e0

File tree

8 files changed

+56
-30
lines changed

8 files changed

+56
-30
lines changed

frontends/web/src/components/backups/backups.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
.listContainer {
1111
margin-top: var(--space-default);
12-
max-height: 480px;
12+
max-height: 380px;
1313
overflow: scroll;
1414
}
1515

frontends/web/src/components/devices/bitbox02/bitbox02.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { store as panelStore } from '../../guide/guide';
3434
import { SwissMadeOpenSource } from '../../icon/logo';
3535
import { Footer } from '../../layout/footer';
3636
import { Header } from '../../layout/header';
37-
import { toggleForceHide } from '../../sidebar/sidebar';
37+
import { setSidebarStatus } from '../../sidebar/sidebar';
3838
import Status from '../../status/status';
3939
import WaitDialog from '../../wait-dialog/wait-dialog';
4040
import { BackupsV2 } from './backups';
@@ -108,8 +108,9 @@ class BitBox02 extends Component<Props, State> {
108108
private unsubscribe!: () => void;
109109

110110
public componentWillMount() {
111-
if (!panelStore.state.forceHiddenSidebar) {
112-
toggleForceHide();
111+
const { sidebarStatus } = panelStore.state;
112+
if (['', 'forceCollapsed'].includes(sidebarStatus)) {
113+
setSidebarStatus('forceHidden');
113114
}
114115
}
115116

@@ -156,12 +157,13 @@ class BitBox02 extends Component<Props, State> {
156157
}
157158

158159
private onStatusChanged = () => {
159-
const { showWizard, unlockOnly } = this.state;
160+
const { showWizard, unlockOnly, appStatus } = this.state;
161+
const { sidebarStatus } = panelStore.state;
160162
apiGet(this.apiPrefix() + '/status').then(status => {
161-
if (status !== 'initialized' && !panelStore.state.forceHiddenSidebar) {
162-
toggleForceHide();
163-
} else if (status === 'initialized' && panelStore.state.forceHiddenSidebar) {
164-
toggleForceHide();
163+
if (status !== 'initialized' && ['', 'forceCollapsed'].includes(sidebarStatus)) {
164+
setSidebarStatus('forceHidden');
165+
} else if (status === 'initialized' && !['createWallet', 'restoreBackup'].includes(appStatus) && sidebarStatus !== '') {
166+
setSidebarStatus('');
165167
}
166168
if (!showWizard && ['connected', 'unpaired', 'pairingFailed', 'uninitialized', 'seeded'].includes(status)) {
167169
this.setState({ showWizard: true });
@@ -183,8 +185,9 @@ class BitBox02 extends Component<Props, State> {
183185
}
184186

185187
public componentWillUnmount() {
186-
if (this.state.status === 'initialized' && panelStore.state.forceHiddenSidebar) {
187-
toggleForceHide();
188+
const { sidebarStatus } = panelStore.state;
189+
if (this.state.status === 'initialized' && ['forceHidden', 'forceCollapsed'].includes(sidebarStatus)) {
190+
setSidebarStatus('');
188191
}
189192
this.unsubscribe();
190193
}
@@ -514,7 +517,7 @@ class BitBox02 extends Component<Props, State> {
514517
Continue
515518
</Button>
516519
<Button
517-
secondary
520+
transparent
518521
onClick={() => this.setState({ appStatus: '' })}>
519522
Go Back
520523
</Button>

frontends/web/src/components/guide/guide.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ import * as style from './guide.css';
2626
export interface SharedProps {
2727
shown: boolean;
2828
activeSidebar: boolean;
29-
forceHiddenSidebar: boolean;
29+
sidebarStatus: string;
3030
guideExists: boolean;
3131
}
3232

3333
export const store = new Store<SharedProps>({
3434
shown: false,
3535
activeSidebar: false,
36-
forceHiddenSidebar: false,
36+
sidebarStatus: '',
3737
guideExists: false,
3838
});
3939

frontends/web/src/components/layout/header.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@
8282
width: 20px;
8383
}
8484

85+
.forceHidden .sidebarToggler {
86+
display: none !important;
87+
}
88+
8589
.guideIconContainer {
8690
margin-left: var(--space-half);
8791
}

frontends/web/src/components/layout/header.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ interface HeaderProps {
2929
type Props = HeaderProps & SharedPanelProps;
3030

3131
function Header(
32-
{ title, narrow, children, guideExists, shown }: RenderableProps<Props>,
32+
{ title, narrow, children, guideExists, shown, sidebarStatus }: RenderableProps<Props>,
3333
): JSX.Element {
3434
const hasChildren = Array.isArray(children) && children.length > 0;
35-
const forceCollapsed = panelStore.state.forceHiddenSidebar;
3635
return (
37-
<div className={[style.container, forceCollapsed ? style.forceCollapsed : ''].join(' ')}>
36+
<div className={[style.container, sidebarStatus ? style[sidebarStatus] : ''].join(' ')}>
3837
<div className={[style.header, narrow ? style.narrow : ''].join(' ')}>
3938
<div className={style.sidebarToggler} onClick={toggleSidebar}>
4039
<img src={MenuIcon} />
@@ -46,14 +45,31 @@ function Header(
4645
guideExists && (
4746
shown ? (
4847
<a href="#" onClick={toggleGuide} className={style.guideIconContainer}>
49-
<svg className={style.guideIcon} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
48+
<svg
49+
className={style.guideIcon}
50+
xmlns="http://www.w3.org/2000/svg"
51+
width="24"
52+
height="24"
53+
viewBox="0 0 24 24"
54+
fill="none"
55+
stroke="currentColor"
56+
stroke-width="2"
57+
stroke-linecap="round"
58+
stroke-linejoin="round">
5059
<path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"></path>
5160
<path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"></path>
5261
</svg>
5362
</a>
5463
) : (
5564
<a href="#" onClick={toggleGuide} className={style.guideIconContainer}>
56-
<svg className={style.guideIcon} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
65+
<svg
66+
className={style.guideIcon}
67+
xmlns="http://www.w3.org/2000/svg"
68+
width="24"
69+
height="24"
70+
viewBox="0 0 24 24"
71+
fill="none"
72+
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
5773
<path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"></path>
5874
<path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"></path>
5975
</svg>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ export function toggleSidebar() {
5050
panelStore.setState({ activeSidebar: toggled });
5151
}
5252

53-
export function toggleForceHide() {
54-
const toggleHide = !panelStore.state.forceHiddenSidebar;
55-
panelStore.setState({ forceHiddenSidebar: toggleHide });
53+
export function setSidebarStatus(status: string) {
54+
panelStore.setState({ sidebarStatus: status });
5655
}
5756

5857
class Sidebar extends Component<Props> {
@@ -152,11 +151,12 @@ class Sidebar extends Component<Props> {
152151
accountsInitialized,
153152
shown,
154153
activeSidebar,
154+
sidebarStatus,
155155
}: RenderableProps<Props>,
156156
) {
157-
const forceHide = panelStore.state.forceHiddenSidebar;
157+
const hidden = ['forceHidden', 'forceCollapsed'].includes(sidebarStatus);
158158
return (
159-
<div className={['sidebarContainer', forceHide ? 'forceHide' : ''].join(' ')}>
159+
<div className={['sidebarContainer', hidden ? 'forceHide' : ''].join(' ')}>
160160
<div className={['sidebarOverlay', activeSidebar ? 'active' : ''].join(' ')} onClick={toggleSidebar}></div>
161161
<nav className={['sidebar', activeSidebar ? 'forceShow' : '', shown ? 'withGuide' : ''].join(' ')}>
162162
<div className="sidebarLogoContainer">

frontends/web/src/routes/device/device.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import SeedRestore from './setup/seed-restore';
2929
import { Initialize } from './setup/initialize';
3030
import Success from './setup/success';
3131
import Settings from './settings/settings';
32-
import { store as panelStore } from '../../components/guide/guide';
32+
import { setSidebarStatus } from '../../components/sidebar/sidebar';
3333

3434
const DeviceStatus = Object.freeze({
3535
BOOTLOADER: 'bootloader',
@@ -100,10 +100,12 @@ export default class Device extends Component {
100100
onDeviceStatusChanged = () => {
101101
if (this.state.deviceRegistered) {
102102
apiGet('devices/' + this.props.deviceID + '/status').then(deviceStatus => {
103-
this.setState({ deviceStatus });
104103
if (deviceStatus === 'seeded') {
105-
panelStore.setState({ forceHiddenSidebar: false });
104+
setSidebarStatus('');
105+
} else {
106+
setSidebarStatus('forceHidden');
106107
}
108+
this.setState({ deviceStatus });
107109
});
108110
}
109111
}

frontends/web/src/routes/device/waiting.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Guide } from '../../components/guide/guide';
2020
import { store as panelStore } from '../../components/guide/guide';
2121
import { AppLogo, SwissMadeOpenSource } from '../../components/icon/logo';
2222
import { Footer, Header } from '../../components/layout';
23-
import { toggleForceHide } from '../../components/sidebar/sidebar';
23+
import { setSidebarStatus } from '../../components/sidebar/sidebar';
2424
import { load } from '../../decorators/load';
2525
import { translate, TranslateProps } from '../../decorators/translate';
2626
import { debug } from '../../utils/env';
@@ -35,8 +35,9 @@ type WaitingProps = TestingProps & TranslateProps;
3535

3636
class Waiting extends Component<WaitingProps> {
3737
public componentWillMount() {
38-
if (!panelStore.state.forceHiddenSidebar) {
39-
toggleForceHide();
38+
const { sidebarStatus } = panelStore.state;
39+
if (sidebarStatus === '') {
40+
setSidebarStatus('forceCollapsed');
4041
}
4142
}
4243

0 commit comments

Comments
 (0)