forked from leather-io/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.ts
38 lines (28 loc) · 1.12 KB
/
ui.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { atomFamily, atomWithStorage } from 'jotai/utils';
import { atom } from 'jotai';
export enum AccountStep {
Switch = 'switch',
Create = 'create',
Username = 'username',
}
export const tabState = atomFamily<string, number, number>(param => {
const anAtom = atomWithStorage<number>(`TABS__${param}`, 0);
anAtom.debugLabel = `TABS__${param}`;
return anAtom;
});
type LoadingState = 'idle' | 'loading';
export const loadingState = atomFamily<string, LoadingState, LoadingState>(_param => {
const anAtom = atom<LoadingState>('idle');
anAtom.debugLabel = `loading-atom/${_param}`;
return anAtom;
});
export const accountDrawerStep = atom<AccountStep>(AccountStep.Switch);
// TODO: refactor into atom family
export const showAccountsStore = atom(false);
export const showNetworksStore = atom(false);
export const showSettingsStore = atom(false);
export const errorStackTraceState = atom<string | null>(null);
accountDrawerStep.debugLabel = 'accountDrawerStep';
showAccountsStore.debugLabel = 'showAccountsStore';
showNetworksStore.debugLabel = 'showNetworksStore';
showSettingsStore.debugLabel = 'showSettingsStore';