Skip to content

Commit 694c866

Browse files
committed
add sprite to pw tests and migrate entities components
1 parent d02c224 commit 694c866

File tree

11 files changed

+25
-31
lines changed

11 files changed

+25
-31
lines changed

playwright/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
<div id="root"></div>
1010
<script type="module" src="/playwright/envs.js"></script>
1111
<script type="module" src="/playwright/index.ts"></script>
12+
<link rel="preload" as="image" href="/public/icons/sprite.svg"/>
1213
</body>
1314
</html>

tools/scripts/pw.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ dotenv \
88
-e $config_file \
99
-- bash -c './deploy/scripts/make_envs_script.sh ./playwright/envs.js'
1010

11+
yarn svg:build-sprite
12+
1113
dotenv \
1214
-v NODE_OPTIONS=\"--max-old-space-size=4096\" \
1315
-e $config_file \

ui/shared/IconSvg.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import React from 'react';
44

55
export const href = '/icons/sprite.svg';
66

7+
export { IconName };
8+
79
interface Props {
810
name: IconName;
911
isLoading?: boolean;

ui/shared/entities/address/AddressEntity.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import type { AddressParam } from 'types/api/addressParams';
77

88
import { route } from 'nextjs-routes';
99

10-
import iconSafe from 'icons/brands/safe.svg';
11-
import iconContractVerified from 'icons/contract_verified.svg';
12-
import iconContract from 'icons/contract.svg';
1310
import * as EntityBase from 'ui/shared/entities/base/components';
1411

1512
import { getIconProps } from '../base/utils';
@@ -53,7 +50,7 @@ const Icon = (props: IconProps) => {
5350
return (
5451
<EntityBase.Icon
5552
{ ...props }
56-
asProp={ iconSafe }
53+
name="brands/safe"
5754
/>
5855
);
5956
}
@@ -64,7 +61,7 @@ const Icon = (props: IconProps) => {
6461
<span>
6562
<EntityBase.Icon
6663
{ ...props }
67-
asProp={ iconContractVerified }
64+
name="contract_verified"
6865
color="green.500"
6966
borderRadius={ 0 }
7067
/>
@@ -78,7 +75,7 @@ const Icon = (props: IconProps) => {
7875
<span>
7976
<EntityBase.Icon
8077
{ ...props }
81-
asProp={ iconContract }
78+
name="contract"
8279
borderRadius={ 0 }
8380
/>
8481
</span>

ui/shared/entities/base/components.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { Box, chakra, Flex, Skeleton, useColorModeValue } from '@chakra-ui/react
22
import type { As, IconProps } from '@chakra-ui/react';
33
import React from 'react';
44

5-
import IconBase from 'ui/shared/chakra/Icon';
65
import type { Props as CopyToClipboardProps } from 'ui/shared/CopyToClipboard';
76
import CopyToClipboard from 'ui/shared/CopyToClipboard';
87
import HashStringShorten from 'ui/shared/HashStringShorten';
98
import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic';
9+
import type { IconName } from 'ui/shared/IconSvg';
10+
import IconSvg from 'ui/shared/IconSvg';
1011
import LinkExternal from 'ui/shared/LinkExternal';
1112
import LinkInternal from 'ui/shared/LinkInternal';
1213

@@ -76,12 +77,12 @@ const Link = chakra(({ isLoading, children, isExternal, onClick, href, noLink }:
7677
});
7778

7879
export interface IconBaseProps extends Pick<EntityBaseProps, 'isLoading' | 'iconSize' | 'noIcon'> {
79-
asProp: As;
80+
name: IconName;
8081
color?: IconProps['color'];
8182
borderRadius?: IconProps['borderRadius'];
8283
}
8384

84-
const Icon = ({ isLoading, iconSize, noIcon, asProp, color, borderRadius }: IconBaseProps) => {
85+
const Icon = ({ isLoading, iconSize, noIcon, name, color, borderRadius }: IconBaseProps) => {
8586
const defaultColor = useColorModeValue('gray.500', 'gray.400');
8687

8788
if (noIcon) {
@@ -91,8 +92,8 @@ const Icon = ({ isLoading, iconSize, noIcon, asProp, color, borderRadius }: Icon
9192
const styles = getIconProps(iconSize);
9293
return (
9394
<Box mr={ 2 } color={ color ?? defaultColor }>
94-
<IconBase
95-
as={ asProp }
95+
<IconSvg
96+
name={ name }
9697
boxSize={ styles.boxSize }
9798
isLoading={ isLoading }
9899
borderRadius={ borderRadius ?? 'base' }

ui/shared/entities/block/BlockEntity.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { As } from '@chakra-ui/react';
21
import { chakra } from '@chakra-ui/react';
32
import _omit from 'lodash/omit';
43
import React from 'react';
54

65
import { route } from 'nextjs-routes';
76

8-
import blockIcon from 'icons/block_slim.svg';
97
import * as EntityBase from 'ui/shared/entities/base/components';
108

119
type LinkProps = EntityBase.LinkBaseProps & Pick<EntityProps, 'hash' | 'number'>;
@@ -24,15 +22,15 @@ const Link = chakra((props: LinkProps) => {
2422
);
2523
});
2624

27-
type IconProps = Omit<EntityBase.IconBaseProps, 'asProp'> & {
28-
asProp?: As;
25+
type IconProps = Omit<EntityBase.IconBaseProps, 'name'> & {
26+
name?: EntityBase.IconBaseProps['name'];
2927
};
3028

3129
const Icon = (props: IconProps) => {
3230
return (
3331
<EntityBase.Icon
3432
{ ...props }
35-
asProp={ props.asProp ?? blockIcon }
33+
name={ props.name ?? 'block_slim' }
3634
/>
3735
);
3836
};

ui/shared/entities/block/BlockEntityL2.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import _omit from 'lodash/omit';
33
import React from 'react';
44

55
import config from 'configs/app';
6-
import txBatchIcon from 'icons/txn_batches_slim.svg';
76

87
import * as BlockEntity from './BlockEntity';
98

@@ -19,7 +18,7 @@ const BlockEntityL2 = (props: BlockEntity.EntityProps) => {
1918

2019
return (
2120
<BlockEntity.Container className={ props.className }>
22-
<BlockEntity.Icon { ...partsProps } asProp={ txBatchIcon }/>
21+
<BlockEntity.Icon { ...partsProps } name="txn_batches_slim"/>
2322
<BlockEntity.Link { ...linkProps }>
2423
<BlockEntity.Content { ...partsProps }/>
2524
</BlockEntity.Link>

ui/shared/entities/block/ZkEvmBatchEntityL2.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import React from 'react';
55
import { route } from 'nextjs-routes';
66

77
import config from 'configs/app';
8-
import txBatchIcon from 'icons/txn_batches_slim.svg';
98

109
import * as BlockEntity from './BlockEntity';
1110

@@ -21,7 +20,7 @@ const ZkEvmBatchEntityL2 = (props: BlockEntity.EntityProps) => {
2120

2221
return (
2322
<BlockEntity.Container className={ props.className }>
24-
<BlockEntity.Icon { ...partsProps } asProp={ txBatchIcon }/>
23+
<BlockEntity.Icon { ...partsProps } name="txn_batches_slim"/>
2524
<BlockEntity.Link
2625
{ ...linkProps }
2726
href={ route({ pathname: '/zkevm-l2-txn-batch/[number]', query: { number: props.number.toString() } }) }

ui/shared/entities/nft/NftEntity.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import type { As } from '@chakra-ui/react';
21
import { chakra } from '@chakra-ui/react';
32
import _omit from 'lodash/omit';
43
import React from 'react';
54

65
import { route } from 'nextjs-routes';
76

8-
import nftPlaceholder from 'icons/nft_shield.svg';
97
import * as EntityBase from 'ui/shared/entities/base/components';
108
import TruncatedValue from 'ui/shared/TruncatedValue';
119

1210
const Container = EntityBase.Container;
1311

1412
type IconProps = Pick<EntityProps, 'isLoading' | 'noIcon' | 'iconSize'> & {
15-
asProp?: As;
13+
name?: EntityBase.IconBaseProps['name'];
1614
};
1715

1816
const Icon = (props: IconProps) => {
@@ -24,7 +22,7 @@ const Icon = (props: IconProps) => {
2422
<EntityBase.Icon
2523
{ ...props }
2624
iconSize={ props.iconSize ?? 'lg' }
27-
asProp={ props.asProp ?? nftPlaceholder }
25+
name={ props.name ?? 'nft_shield' }
2826
/>
2927
);
3028
};

ui/shared/entities/token/TokenEntity.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { As, ChakraProps } from '@chakra-ui/react';
1+
import type { ChakraProps } from '@chakra-ui/react';
22
import { Image, Skeleton, chakra } from '@chakra-ui/react';
33
import _omit from 'lodash/omit';
44
import React from 'react';
@@ -29,7 +29,6 @@ const Link = chakra((props: LinkProps) => {
2929
});
3030

3131
type IconProps = Pick<EntityProps, 'token' | 'isLoading' | 'iconSize' | 'noIcon' | 'className'> & {
32-
asProp?: As;
3332
marginRight?: ChakraProps['marginRight'];
3433
boxSize?: ChakraProps['boxSize'];
3534
};

ui/shared/entities/tx/TxEntity.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { As } from '@chakra-ui/react';
21
import { chakra } from '@chakra-ui/react';
32
import _omit from 'lodash/omit';
43
import React from 'react';
54

65
import { route } from 'nextjs-routes';
76

8-
import transactionIcon from 'icons/transactions_slim.svg';
97
import * as EntityBase from 'ui/shared/entities/base/components';
108

119
type LinkProps = EntityBase.LinkBaseProps & Pick<EntityProps, 'hash'>;
@@ -23,15 +21,15 @@ const Link = chakra((props: LinkProps) => {
2321
);
2422
});
2523

26-
type IconProps = Omit<EntityBase.IconBaseProps, 'asProp'> & {
27-
asProp?: As;
24+
type IconProps = Omit<EntityBase.IconBaseProps, 'name'> & {
25+
name?: EntityBase.IconBaseProps['name'];
2826
};
2927

3028
const Icon = (props: IconProps) => {
3129
return (
3230
<EntityBase.Icon
3331
{ ...props }
34-
asProp={ props.asProp ?? transactionIcon }
32+
name={ props.name ?? 'transactions_slim' }
3533
/>
3634
);
3735
};

0 commit comments

Comments
 (0)