Skip to content

Commit 3fc76a2

Browse files
committed
chore: containers,headers, code quality
1 parent 08966e0 commit 3fc76a2

File tree

95 files changed

+831
-808
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+831
-808
lines changed

.storybook/viewports.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { breakpoints } from '@leather-wallet/tokens';
22

3-
import { POPUP_HEIGHT, POPUP_WIDTH } from '../src/app/ui/constants';
3+
// TODO import from '@leather-wallet/tokens'
4+
import { tokens } from '../theme/tokens';
45

56
export const customViewports = {
67
popup: {
78
name: 'Popup',
89
styles: {
9-
width: `${POPUP_WIDTH}px`,
10-
height: `${POPUP_HEIGHT}px`,
10+
width: tokens.sizes.popupWidth.value,
11+
height: tokens.sizes.popupHeight.value,
1112
},
1213
},
1314
sm: {

src/app/common/hooks/use-dialogs.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// import { useCallback, useEffect, useState } from 'react';
1+
import { useCallback, useEffect, useState } from 'react';
22

33
export function buildEnterKeyEvent(onClick: () => void) {
44
return (event: React.KeyboardEvent<HTMLInputElement>) => {
@@ -8,48 +8,46 @@ export function buildEnterKeyEvent(onClick: () => void) {
88
};
99
}
1010

11-
// TODO try deprecate this in favour of new settings menu https://github.com/leather-wallet/extension/pull/2732/files
12-
13-
// let timer = 0;
14-
15-
// export function useModifierKey(key: 'alt' | 'control', delay = 0) {
16-
// const [isPressed, setIsPressed] = useState(false);
17-
18-
// const keydownFn = useCallback(
19-
// (event: KeyboardEvent) => {
20-
// if (key === 'alt' && event.altKey) {
21-
// timer = window.setTimeout(() => setIsPressed(true), delay);
22-
// }
23-
// if (key === 'control' && event.ctrlKey) {
24-
// timer = window.setTimeout(() => setIsPressed(true), delay);
25-
// }
26-
// },
27-
// [delay, key]
28-
// );
29-
30-
// const keyupFn = useCallback(
31-
// (event: KeyboardEvent) => {
32-
// if (key === 'alt' && !event.altKey) {
33-
// clearTimeout(timer);
34-
// setIsPressed(false);
35-
// }
36-
// if (key === 'control' && !event.ctrlKey) {
37-
// clearTimeout(timer);
38-
// setIsPressed(false);
39-
// }
40-
// },
41-
// [key]
42-
// );
43-
44-
// useEffect(() => {
45-
// document.addEventListener('keydown', keydownFn);
46-
// document.addEventListener('keyup', keyupFn);
47-
// return () => {
48-
// clearTimeout(timer);
49-
// document.removeEventListener('keydown', keydownFn);
50-
// document.removeEventListener('keyup', keyupFn);
51-
// };
52-
// }, [keydownFn, keyupFn]);
53-
54-
// return { isPressed };
55-
// }
11+
let timer = 0;
12+
13+
export function useModifierKey(key: 'alt' | 'control', delay = 0) {
14+
const [isPressed, setIsPressed] = useState(false);
15+
16+
const keydownFn = useCallback(
17+
(event: KeyboardEvent) => {
18+
if (key === 'alt' && event.altKey) {
19+
timer = window.setTimeout(() => setIsPressed(true), delay);
20+
}
21+
if (key === 'control' && event.ctrlKey) {
22+
timer = window.setTimeout(() => setIsPressed(true), delay);
23+
}
24+
},
25+
[delay, key]
26+
);
27+
28+
const keyupFn = useCallback(
29+
(event: KeyboardEvent) => {
30+
if (key === 'alt' && !event.altKey) {
31+
clearTimeout(timer);
32+
setIsPressed(false);
33+
}
34+
if (key === 'control' && !event.ctrlKey) {
35+
clearTimeout(timer);
36+
setIsPressed(false);
37+
}
38+
},
39+
[key]
40+
);
41+
42+
useEffect(() => {
43+
document.addEventListener('keydown', keydownFn);
44+
document.addEventListener('keyup', keyupFn);
45+
return () => {
46+
clearTimeout(timer);
47+
document.removeEventListener('keydown', keydownFn);
48+
document.removeEventListener('keyup', keyupFn);
49+
};
50+
}, [keydownFn, keyupFn]);
51+
52+
return { isPressed };
53+
}

src/app/components/app-version.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ const AppVersionLabel = forwardRef<HTMLSpanElement, AppVersionLabelProps>(
1616
<styled.span
1717
ref={ref}
1818
textStyle="mono.02"
19-
marginRight="10px"
20-
mb="-4px"
21-
ml="space.02"
19+
marginTop="auto"
20+
marginBottom="space.02"
21+
mx="space.02"
2222
opacity={0.5}
2323
textDecoration={isLatestVersion ? 'none' : 'line-through'}
2424
textWrap="nowrap"
@@ -28,7 +28,7 @@ const AppVersionLabel = forwardRef<HTMLSpanElement, AppVersionLabelProps>(
2828
</styled.span>
2929
)
3030
);
31-
// TODO fix this, as its now unused but shouldn't be
31+
3232
export function AppVersion() {
3333
const { pullRequestLink, isLatestBuild } = useIsLatestPullRequestBuild();
3434

src/app/components/request-password.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { buildEnterKeyEvent } from '@app/common/hooks/use-modifier-key';
99
import { WaitingMessages, useWaitingMessage } from '@app/common/utils/use-waiting-message';
1010
import { Button } from '@app/ui/components/button/button';
1111
import { Footer } from '@app/ui/components/containers/footers/footer';
12-
import { Card } from '@app/ui/components/layout/card/card';
13-
import { Page } from '@app/ui/components/layout/page/page.layout';
12+
import { Card } from '@app/ui/layout/card/card';
13+
import { Page } from '@app/ui/layout/page/page.layout';
1414

1515
import { ErrorLabel } from './error-label';
1616

src/app/features/activity-list/components/tab-wrapper.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ export function ActivityListTabWrapper({
1010
padContent = false,
1111
}: ActivityListTabWrapperProps) {
1212
return (
13-
// Height set based on the height of the empty assets screen
14-
<Box minHeight="477px" py={padContent ? 'space.11' : undefined}>
13+
<Box minHeight="dialogContentHeight" py={padContent ? 'space.11' : undefined}>
1514
{children}
1615
</Box>
1716
);

src/app/features/add-network/add-network.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import {
2020
} from '@app/store/networks/networks.hooks';
2121
import { Button } from '@app/ui/components/button/button';
2222
import { Input } from '@app/ui/components/input/input';
23-
import { Page } from '@app/ui/components/layout/page/page.layout';
2423
import { Title } from '@app/ui/components/typography/title';
24+
import { Page } from '@app/ui/layout/page/page.layout';
2525

2626
/**
2727
* The **peer** network ID.
@@ -45,7 +45,6 @@ const addNetworkFormValues: AddNetworkFormValues = {
4545
bitcoinUrl: '',
4646
};
4747

48-
// FIXME 4370 task #11 make this look better
4948
export function AddNetwork() {
5049
const [loading, setLoading] = useState(false);
5150
const [error, setError] = useState('');

src/app/features/asset-list/asset-list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function AssetsList() {
3131
const { whenWallet } = useWalletType();
3232

3333
return (
34-
<Stack data-testid={HomePageSelectors.BalancesList} pb="space.06">
34+
<Stack data-testid={HomePageSelectors.BalancesList}>
3535
{whenWallet({
3636
software: (
3737
<CryptoCurrencyAssetItemLayout

src/app/features/collectibles/collectibles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { useConfigNftMetadataEnabled } from '@app/query/common/remote-config/rem
1313
import { AddCollectible } from './components/add-collectible';
1414
import { Ordinals } from './components/bitcoin/ordinals';
1515
import { Stamps } from './components/bitcoin/stamps';
16-
import { CollectiblesLayout } from './components/collectibes.layout';
16+
import { CollectiblesLayout } from './components/collectible.layout';
1717
import { StacksCryptoAssets } from './components/stacks/stacks-crypto-assets';
1818
import { TaprootBalanceDisplayer } from './components/taproot-balance-displayer';
1919
import { useIsFetchingCollectiblesRelatedQuery } from './hooks/use-is-fetching-collectibles';

src/app/features/collectibles/components/collectibes.layout.tsx renamed to src/app/features/collectibles/components/collectible.layout.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Flex, Grid, HStack, styled } from 'leather-styles/jsx';
2-
import { token } from 'leather-styles/tokens';
32

43
import { LoadingSpinner } from '@app/components/loading-spinner';
54
import { Spinner } from '@app/ui/components/spinner';
@@ -23,24 +22,24 @@ export function CollectiblesLayout({
2322
}: CollectiblesLayoutProps) {
2423
return (
2524
<>
26-
<Flex flexDirection="row" justifyContent="space-between" flex={1} mt="space.05">
25+
<Flex flexDirection="row" justifyContent="space-between" flex={1}>
2726
<HStack columnGap="space.02">
28-
<styled.span textStyle="label.01">{title}</styled.span>
29-
{isLoading ? (
30-
<Spinner color={token('colors.accent.text-primary')} opacity={0.5} size="16px" />
27+
<styled.span textStyle="label.01" paddingY="space.05">
28+
{title}
29+
</styled.span>
30+
{!isLoading ? (
31+
<Spinner color="text-primary" opacity={0.5} size="16px" />
3132
) : (
3233
<ReloadIcon cursor="pointer" onClick={() => onRefresh()} />
3334
)}
3435
</HStack>
3536
{subHeader}
3637
</Flex>
3738
<Grid
38-
gap="space.04"
39-
rowGap="space.06"
40-
gridTemplateColumns={[
41-
'repeat(auto-fill, minmax(164px, 1fr))',
42-
'repeat(auto-fill, minmax(184px, 1fr))',
43-
]}
39+
gridTemplateColumns={{
40+
base: 'repeat(auto-fill, minmax(164px, 1fr))',
41+
md: 'repeat(auto-fill, minmax(184px, 1fr))',
42+
}}
4443
>
4544
{children}
4645
</Grid>

0 commit comments

Comments
 (0)