Commit 694c866b authored by tom's avatar tom

add sprite to pw tests and migrate entities components

parent d02c2244
...@@ -9,5 +9,6 @@ ...@@ -9,5 +9,6 @@
<div id="root"></div> <div id="root"></div>
<script type="module" src="/playwright/envs.js"></script> <script type="module" src="/playwright/envs.js"></script>
<script type="module" src="/playwright/index.ts"></script> <script type="module" src="/playwright/index.ts"></script>
<link rel="preload" as="image" href="/public/icons/sprite.svg"/>
</body> </body>
</html> </html>
...@@ -8,6 +8,8 @@ dotenv \ ...@@ -8,6 +8,8 @@ dotenv \
-e $config_file \ -e $config_file \
-- bash -c './deploy/scripts/make_envs_script.sh ./playwright/envs.js' -- bash -c './deploy/scripts/make_envs_script.sh ./playwright/envs.js'
yarn svg:build-sprite
dotenv \ dotenv \
-v NODE_OPTIONS=\"--max-old-space-size=4096\" \ -v NODE_OPTIONS=\"--max-old-space-size=4096\" \
-e $config_file \ -e $config_file \
......
...@@ -4,6 +4,8 @@ import React from 'react'; ...@@ -4,6 +4,8 @@ import React from 'react';
export const href = '/icons/sprite.svg'; export const href = '/icons/sprite.svg';
export { IconName };
interface Props { interface Props {
name: IconName; name: IconName;
isLoading?: boolean; isLoading?: boolean;
......
...@@ -7,9 +7,6 @@ import type { AddressParam } from 'types/api/addressParams'; ...@@ -7,9 +7,6 @@ import type { AddressParam } from 'types/api/addressParams';
import { route } from 'nextjs-routes'; import { route } from 'nextjs-routes';
import iconSafe from 'icons/brands/safe.svg';
import iconContractVerified from 'icons/contract_verified.svg';
import iconContract from 'icons/contract.svg';
import * as EntityBase from 'ui/shared/entities/base/components'; import * as EntityBase from 'ui/shared/entities/base/components';
import { getIconProps } from '../base/utils'; import { getIconProps } from '../base/utils';
...@@ -53,7 +50,7 @@ const Icon = (props: IconProps) => { ...@@ -53,7 +50,7 @@ const Icon = (props: IconProps) => {
return ( return (
<EntityBase.Icon <EntityBase.Icon
{ ...props } { ...props }
asProp={ iconSafe } name="brands/safe"
/> />
); );
} }
...@@ -64,7 +61,7 @@ const Icon = (props: IconProps) => { ...@@ -64,7 +61,7 @@ const Icon = (props: IconProps) => {
<span> <span>
<EntityBase.Icon <EntityBase.Icon
{ ...props } { ...props }
asProp={ iconContractVerified } name="contract_verified"
color="green.500" color="green.500"
borderRadius={ 0 } borderRadius={ 0 }
/> />
...@@ -78,7 +75,7 @@ const Icon = (props: IconProps) => { ...@@ -78,7 +75,7 @@ const Icon = (props: IconProps) => {
<span> <span>
<EntityBase.Icon <EntityBase.Icon
{ ...props } { ...props }
asProp={ iconContract } name="contract"
borderRadius={ 0 } borderRadius={ 0 }
/> />
</span> </span>
......
...@@ -2,11 +2,12 @@ import { Box, chakra, Flex, Skeleton, useColorModeValue } from '@chakra-ui/react ...@@ -2,11 +2,12 @@ import { Box, chakra, Flex, Skeleton, useColorModeValue } from '@chakra-ui/react
import type { As, IconProps } from '@chakra-ui/react'; import type { As, IconProps } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import IconBase from 'ui/shared/chakra/Icon';
import type { Props as CopyToClipboardProps } from 'ui/shared/CopyToClipboard'; import type { Props as CopyToClipboardProps } from 'ui/shared/CopyToClipboard';
import CopyToClipboard from 'ui/shared/CopyToClipboard'; import CopyToClipboard from 'ui/shared/CopyToClipboard';
import HashStringShorten from 'ui/shared/HashStringShorten'; import HashStringShorten from 'ui/shared/HashStringShorten';
import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic'; import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic';
import type { IconName } from 'ui/shared/IconSvg';
import IconSvg from 'ui/shared/IconSvg';
import LinkExternal from 'ui/shared/LinkExternal'; import LinkExternal from 'ui/shared/LinkExternal';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
...@@ -76,12 +77,12 @@ const Link = chakra(({ isLoading, children, isExternal, onClick, href, noLink }: ...@@ -76,12 +77,12 @@ const Link = chakra(({ isLoading, children, isExternal, onClick, href, noLink }:
}); });
export interface IconBaseProps extends Pick<EntityBaseProps, 'isLoading' | 'iconSize' | 'noIcon'> { export interface IconBaseProps extends Pick<EntityBaseProps, 'isLoading' | 'iconSize' | 'noIcon'> {
asProp: As; name: IconName;
color?: IconProps['color']; color?: IconProps['color'];
borderRadius?: IconProps['borderRadius']; borderRadius?: IconProps['borderRadius'];
} }
const Icon = ({ isLoading, iconSize, noIcon, asProp, color, borderRadius }: IconBaseProps) => { const Icon = ({ isLoading, iconSize, noIcon, name, color, borderRadius }: IconBaseProps) => {
const defaultColor = useColorModeValue('gray.500', 'gray.400'); const defaultColor = useColorModeValue('gray.500', 'gray.400');
if (noIcon) { if (noIcon) {
...@@ -91,8 +92,8 @@ const Icon = ({ isLoading, iconSize, noIcon, asProp, color, borderRadius }: Icon ...@@ -91,8 +92,8 @@ const Icon = ({ isLoading, iconSize, noIcon, asProp, color, borderRadius }: Icon
const styles = getIconProps(iconSize); const styles = getIconProps(iconSize);
return ( return (
<Box mr={ 2 } color={ color ?? defaultColor }> <Box mr={ 2 } color={ color ?? defaultColor }>
<IconBase <IconSvg
as={ asProp } name={ name }
boxSize={ styles.boxSize } boxSize={ styles.boxSize }
isLoading={ isLoading } isLoading={ isLoading }
borderRadius={ borderRadius ?? 'base' } borderRadius={ borderRadius ?? 'base' }
......
import type { As } from '@chakra-ui/react';
import { chakra } from '@chakra-ui/react'; import { chakra } from '@chakra-ui/react';
import _omit from 'lodash/omit'; import _omit from 'lodash/omit';
import React from 'react'; import React from 'react';
import { route } from 'nextjs-routes'; import { route } from 'nextjs-routes';
import blockIcon from 'icons/block_slim.svg';
import * as EntityBase from 'ui/shared/entities/base/components'; import * as EntityBase from 'ui/shared/entities/base/components';
type LinkProps = EntityBase.LinkBaseProps & Pick<EntityProps, 'hash' | 'number'>; type LinkProps = EntityBase.LinkBaseProps & Pick<EntityProps, 'hash' | 'number'>;
...@@ -24,15 +22,15 @@ const Link = chakra((props: LinkProps) => { ...@@ -24,15 +22,15 @@ const Link = chakra((props: LinkProps) => {
); );
}); });
type IconProps = Omit<EntityBase.IconBaseProps, 'asProp'> & { type IconProps = Omit<EntityBase.IconBaseProps, 'name'> & {
asProp?: As; name?: EntityBase.IconBaseProps['name'];
}; };
const Icon = (props: IconProps) => { const Icon = (props: IconProps) => {
return ( return (
<EntityBase.Icon <EntityBase.Icon
{ ...props } { ...props }
asProp={ props.asProp ?? blockIcon } name={ props.name ?? 'block_slim' }
/> />
); );
}; };
......
...@@ -3,7 +3,6 @@ import _omit from 'lodash/omit'; ...@@ -3,7 +3,6 @@ import _omit from 'lodash/omit';
import React from 'react'; import React from 'react';
import config from 'configs/app'; import config from 'configs/app';
import txBatchIcon from 'icons/txn_batches_slim.svg';
import * as BlockEntity from './BlockEntity'; import * as BlockEntity from './BlockEntity';
...@@ -19,7 +18,7 @@ const BlockEntityL2 = (props: BlockEntity.EntityProps) => { ...@@ -19,7 +18,7 @@ const BlockEntityL2 = (props: BlockEntity.EntityProps) => {
return ( return (
<BlockEntity.Container className={ props.className }> <BlockEntity.Container className={ props.className }>
<BlockEntity.Icon { ...partsProps } asProp={ txBatchIcon }/> <BlockEntity.Icon { ...partsProps } name="txn_batches_slim"/>
<BlockEntity.Link { ...linkProps }> <BlockEntity.Link { ...linkProps }>
<BlockEntity.Content { ...partsProps }/> <BlockEntity.Content { ...partsProps }/>
</BlockEntity.Link> </BlockEntity.Link>
......
...@@ -5,7 +5,6 @@ import React from 'react'; ...@@ -5,7 +5,6 @@ import React from 'react';
import { route } from 'nextjs-routes'; import { route } from 'nextjs-routes';
import config from 'configs/app'; import config from 'configs/app';
import txBatchIcon from 'icons/txn_batches_slim.svg';
import * as BlockEntity from './BlockEntity'; import * as BlockEntity from './BlockEntity';
...@@ -21,7 +20,7 @@ const ZkEvmBatchEntityL2 = (props: BlockEntity.EntityProps) => { ...@@ -21,7 +20,7 @@ const ZkEvmBatchEntityL2 = (props: BlockEntity.EntityProps) => {
return ( return (
<BlockEntity.Container className={ props.className }> <BlockEntity.Container className={ props.className }>
<BlockEntity.Icon { ...partsProps } asProp={ txBatchIcon }/> <BlockEntity.Icon { ...partsProps } name="txn_batches_slim"/>
<BlockEntity.Link <BlockEntity.Link
{ ...linkProps } { ...linkProps }
href={ route({ pathname: '/zkevm-l2-txn-batch/[number]', query: { number: props.number.toString() } }) } href={ route({ pathname: '/zkevm-l2-txn-batch/[number]', query: { number: props.number.toString() } }) }
......
import type { As } from '@chakra-ui/react';
import { chakra } from '@chakra-ui/react'; import { chakra } from '@chakra-ui/react';
import _omit from 'lodash/omit'; import _omit from 'lodash/omit';
import React from 'react'; import React from 'react';
import { route } from 'nextjs-routes'; import { route } from 'nextjs-routes';
import nftPlaceholder from 'icons/nft_shield.svg';
import * as EntityBase from 'ui/shared/entities/base/components'; import * as EntityBase from 'ui/shared/entities/base/components';
import TruncatedValue from 'ui/shared/TruncatedValue'; import TruncatedValue from 'ui/shared/TruncatedValue';
const Container = EntityBase.Container; const Container = EntityBase.Container;
type IconProps = Pick<EntityProps, 'isLoading' | 'noIcon' | 'iconSize'> & { type IconProps = Pick<EntityProps, 'isLoading' | 'noIcon' | 'iconSize'> & {
asProp?: As; name?: EntityBase.IconBaseProps['name'];
}; };
const Icon = (props: IconProps) => { const Icon = (props: IconProps) => {
...@@ -24,7 +22,7 @@ const Icon = (props: IconProps) => { ...@@ -24,7 +22,7 @@ const Icon = (props: IconProps) => {
<EntityBase.Icon <EntityBase.Icon
{ ...props } { ...props }
iconSize={ props.iconSize ?? 'lg' } iconSize={ props.iconSize ?? 'lg' }
asProp={ props.asProp ?? nftPlaceholder } name={ props.name ?? 'nft_shield' }
/> />
); );
}; };
......
import type { As, ChakraProps } from '@chakra-ui/react'; import type { ChakraProps } from '@chakra-ui/react';
import { Image, Skeleton, chakra } from '@chakra-ui/react'; import { Image, Skeleton, chakra } from '@chakra-ui/react';
import _omit from 'lodash/omit'; import _omit from 'lodash/omit';
import React from 'react'; import React from 'react';
...@@ -29,7 +29,6 @@ const Link = chakra((props: LinkProps) => { ...@@ -29,7 +29,6 @@ const Link = chakra((props: LinkProps) => {
}); });
type IconProps = Pick<EntityProps, 'token' | 'isLoading' | 'iconSize' | 'noIcon' | 'className'> & { type IconProps = Pick<EntityProps, 'token' | 'isLoading' | 'iconSize' | 'noIcon' | 'className'> & {
asProp?: As;
marginRight?: ChakraProps['marginRight']; marginRight?: ChakraProps['marginRight'];
boxSize?: ChakraProps['boxSize']; boxSize?: ChakraProps['boxSize'];
}; };
......
import type { As } from '@chakra-ui/react';
import { chakra } from '@chakra-ui/react'; import { chakra } from '@chakra-ui/react';
import _omit from 'lodash/omit'; import _omit from 'lodash/omit';
import React from 'react'; import React from 'react';
import { route } from 'nextjs-routes'; import { route } from 'nextjs-routes';
import transactionIcon from 'icons/transactions_slim.svg';
import * as EntityBase from 'ui/shared/entities/base/components'; import * as EntityBase from 'ui/shared/entities/base/components';
type LinkProps = EntityBase.LinkBaseProps & Pick<EntityProps, 'hash'>; type LinkProps = EntityBase.LinkBaseProps & Pick<EntityProps, 'hash'>;
...@@ -23,15 +21,15 @@ const Link = chakra((props: LinkProps) => { ...@@ -23,15 +21,15 @@ const Link = chakra((props: LinkProps) => {
); );
}); });
type IconProps = Omit<EntityBase.IconBaseProps, 'asProp'> & { type IconProps = Omit<EntityBase.IconBaseProps, 'name'> & {
asProp?: As; name?: EntityBase.IconBaseProps['name'];
}; };
const Icon = (props: IconProps) => { const Icon = (props: IconProps) => {
return ( return (
<EntityBase.Icon <EntityBase.Icon
{ ...props } { ...props }
asProp={ props.asProp ?? transactionIcon } name={ props.name ?? 'transactions_slim' }
/> />
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment