Skip to content

Commit

Permalink
chore: replace drawer with dialog, add containers and global header f…
Browse files Browse the repository at this point in the history
…ooters, refactor onboarding, ref #4371
  • Loading branch information
pete-watters committed Jan 25, 2024
1 parent 988e23f commit 2572118
Show file tree
Hide file tree
Showing 171 changed files with 2,209 additions and 1,787 deletions.
6 changes: 6 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ const config: StorybookConfig = {
},
],
},

{
test: /\.(ts|tsx)$/,
loader: 'esbuild-loader',
options: { tsconfig: './tsconfig.json', target: 'es2020' },
},
],
},
},
Expand Down
7 changes: 7 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Preview } from '@storybook/react';

import '../src/app/index.css';
import { customViewports } from './viewports';

const preview: Preview = {
parameters: {
Expand All @@ -24,6 +25,12 @@ const preview: Preview = {
date: /Date$/i,
},
},
viewport: {
viewports: {
...customViewports,
},
},
toc: true,
},
};

Expand Down
48 changes: 48 additions & 0 deletions .storybook/viewports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { breakpoints } from '@leather-wallet/tokens';

import { POPUP_HEIGHT, POPUP_WIDTH } from '../src/shared/constants';

export const customViewports = {
extension: {
name: 'Extension Popout',
styles: {
width: `${POPUP_WIDTH}px`,
height: `${POPUP_HEIGHT}px`,
},
},
sm: {
name: 'sm',
styles: {
width: breakpoints.sm,
height: '100%',
},
},
md: {
name: 'md',
styles: {
width: breakpoints.md,
height: '100%',
},
},
lg: {
name: 'lg',
styles: {
width: breakpoints.lg,
height: '100%',
},
},
xl: {
name: 'xl',
styles: {
width: breakpoints.xl,
height: '100%',
},
},
'2xl': {
name: '2xl',
styles: {
width: breakpoints['2xl'],
height: '100%',
},
},
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"@radix-ui/react-tabs": "1.0.4",
"@radix-ui/react-tooltip": "1.0.7",
"@radix-ui/themes": "2.0.3",
"@radix-ui/react-dialog": "1.0.5",
"@reduxjs/toolkit": "1.9.6",
"@scure/base": "1.1.3",
"@scure/bip32": "1.3.2",
Expand Down
12 changes: 0 additions & 12 deletions public/html/popup-center.html

This file was deleted.

21 changes: 8 additions & 13 deletions src/app/app.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Suspense } from 'react';
import { Provider as ReduxProvider } from 'react-redux';

import { radixBaseCSS } from '@radix-ui/themes/styles.css';
import { QueryClientProvider } from '@tanstack/react-query';
import { styled } from 'leather-styles/jsx';
import { PersistGate } from 'redux-persist/integration/react';

import { queryClient } from '@app/common/persistence';
Expand All @@ -24,18 +22,15 @@ export function App() {
<ReduxProvider store={store}>
<PersistGate loading={<FullPageLoadingSpinner />} persistor={persistor}>
<HeadProvider />
{/* TODO: this works but investigate importing radixBaseCSS in panda layer config */}
<ThemeSwitcherProvider>
<styled.div css={radixBaseCSS}>
<QueryClientProvider client={queryClient}>
<Suspense fallback={<FullPageLoadingSpinner />}>
<AppErrorBoundary>
<AppRoutes />
</AppErrorBoundary>
{reactQueryDevToolsEnabled && <Devtools />}
</Suspense>
</QueryClientProvider>
</styled.div>
<QueryClientProvider client={queryClient}>
<Suspense fallback={<FullPageLoadingSpinner />}>
<AppErrorBoundary>
<AppRoutes />
</AppErrorBoundary>
{reactQueryDevToolsEnabled && <Devtools />}
</Suspense>
</QueryClientProvider>
</ThemeSwitcherProvider>
</PersistGate>
</ReduxProvider>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import {
useShowHighFeeConfirmationState,
useShowSettingsStore,
useShowSwitchAccountsState,
useShowTxSettingsCallback,
} from '@app/store/ui/ui.hooks';

export function useDrawers() {
// TODO move this to features/dialogs?
export function useDialogs() {
const [isShowingAccounts, setIsShowingSwitchAccountsState] = useShowSwitchAccountsState();
const [isShowingHighFeeConfirmation, setIsShowingHighFeeConfirmation] =
useShowHighFeeConfirmationState();

const [isShowingSettings, setIsShowingSettings] = useShowSettingsStore();
const [isShowingTxSettingsCallback, setIsShowingTxSettingsCallback] = useShowTxSettingsCallback();

return {
isShowingAccounts,
setIsShowingSwitchAccountsState,
isShowingHighFeeConfirmation,
setIsShowingHighFeeConfirmation,
isShowingSettings,
setIsShowingSettings,
isShowingTxSettingsCallback,
setIsShowingTxSettingsCallback,
};
Expand Down
74 changes: 0 additions & 74 deletions src/app/common/hooks/use-event-listener.ts

This file was deleted.

17 changes: 0 additions & 17 deletions src/app/common/hooks/use-latest-ref.ts

This file was deleted.

90 changes: 46 additions & 44 deletions src/app/common/hooks/use-modifier-key.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useState } from 'react';
// import { useCallback, useEffect, useState } from 'react';

export function buildEnterKeyEvent(onClick: () => void) {
return (event: React.KeyboardEvent<HTMLInputElement>) => {
Expand All @@ -8,46 +8,48 @@ export function buildEnterKeyEvent(onClick: () => void) {
};
}

let timer = 0;

export function useModifierKey(key: 'alt' | 'control', delay = 0) {
const [isPressed, setIsPressed] = useState(false);

const keydownFn = useCallback(
(event: KeyboardEvent) => {
if (key === 'alt' && event.altKey) {
timer = window.setTimeout(() => setIsPressed(true), delay);
}
if (key === 'control' && event.ctrlKey) {
timer = window.setTimeout(() => setIsPressed(true), delay);
}
},
[delay, key]
);

const keyupFn = useCallback(
(event: KeyboardEvent) => {
if (key === 'alt' && !event.altKey) {
clearTimeout(timer);
setIsPressed(false);
}
if (key === 'control' && !event.ctrlKey) {
clearTimeout(timer);
setIsPressed(false);
}
},
[key]
);

useEffect(() => {
document.addEventListener('keydown', keydownFn);
document.addEventListener('keyup', keyupFn);
return () => {
clearTimeout(timer);
document.removeEventListener('keydown', keydownFn);
document.removeEventListener('keyup', keyupFn);
};
}, [keydownFn, keyupFn]);

return { isPressed };
}
// TODO try deprecate this in favour of new settings menu https://github.com/leather-wallet/extension/pull/2732/files

// let timer = 0;

// export function useModifierKey(key: 'alt' | 'control', delay = 0) {
// const [isPressed, setIsPressed] = useState(false);

// const keydownFn = useCallback(
// (event: KeyboardEvent) => {
// if (key === 'alt' && event.altKey) {
// timer = window.setTimeout(() => setIsPressed(true), delay);
// }
// if (key === 'control' && event.ctrlKey) {
// timer = window.setTimeout(() => setIsPressed(true), delay);
// }
// },
// [delay, key]
// );

// const keyupFn = useCallback(
// (event: KeyboardEvent) => {
// if (key === 'alt' && !event.altKey) {
// clearTimeout(timer);
// setIsPressed(false);
// }
// if (key === 'control' && !event.ctrlKey) {
// clearTimeout(timer);
// setIsPressed(false);
// }
// },
// [key]
// );

// useEffect(() => {
// document.addEventListener('keydown', keydownFn);
// document.addEventListener('keyup', keyupFn);
// return () => {
// clearTimeout(timer);
// document.removeEventListener('keydown', keydownFn);
// document.removeEventListener('keyup', keyupFn);
// };
// }, [keydownFn, keyupFn]);

// return { isPressed };
// }
16 changes: 0 additions & 16 deletions src/app/common/hooks/use-route-header.ts

This file was deleted.

Loading

0 comments on commit 2572118

Please sign in to comment.