mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* move nav icons to separate directory * remove unnecessary "slim" suffix from some icon names * fix screenshots
94 lines
2.3 KiB
TypeScript
94 lines
2.3 KiB
TypeScript
import { chakra } from '@chakra-ui/react';
|
|
import React from 'react';
|
|
|
|
import { route } from 'nextjs/routes';
|
|
|
|
import { useMultichainContext } from 'lib/contexts/multichain';
|
|
import * as EntityBase from 'ui/shared/entities/base/components';
|
|
import getChainTooltipText from 'ui/shared/externalChains/getChainTooltipText';
|
|
|
|
import { distributeEntityProps } from '../base/utils';
|
|
|
|
type LinkProps = EntityBase.LinkBaseProps & Pick<EntityProps, 'hash'>;
|
|
|
|
const Link = chakra((props: LinkProps) => {
|
|
const defaultHref = route(
|
|
{ pathname: '/op/[hash]', query: { hash: props.hash } },
|
|
{ chain: props.chain, external: props.external },
|
|
);
|
|
|
|
return (
|
|
<EntityBase.Link
|
|
{ ...props }
|
|
href={ props.href ?? defaultHref }
|
|
>
|
|
{ props.children }
|
|
</EntityBase.Link>
|
|
);
|
|
});
|
|
|
|
const Icon = (props: EntityBase.IconBaseProps) => {
|
|
return (
|
|
<EntityBase.Icon
|
|
{ ...props }
|
|
name={ 'name' in props ? props.name : 'user_op' }
|
|
shield={ props.shield ?? (props.chain ? { src: props.chain.logo } : undefined) }
|
|
hint={ props.chain && props.shield !== false ? getChainTooltipText(props.chain, 'User operation on ') : undefined }
|
|
/>
|
|
);
|
|
};
|
|
|
|
type ContentProps = Omit<EntityBase.ContentBaseProps, 'text'> & Pick<EntityProps, 'hash'>;
|
|
|
|
const Content = chakra((props: ContentProps) => {
|
|
return (
|
|
<EntityBase.Content
|
|
{ ...props }
|
|
text={ props.hash }
|
|
/>
|
|
);
|
|
});
|
|
|
|
type CopyProps = Omit<EntityBase.CopyBaseProps, 'text'> & Pick<EntityProps, 'hash'>;
|
|
|
|
const Copy = (props: CopyProps) => {
|
|
return (
|
|
<EntityBase.Copy
|
|
{ ...props }
|
|
text={ props.hash }
|
|
noCopy={ props.noCopy }
|
|
/>
|
|
);
|
|
};
|
|
|
|
const Container = EntityBase.Container;
|
|
|
|
export interface EntityProps extends EntityBase.EntityBaseProps {
|
|
hash: string;
|
|
}
|
|
|
|
const UserOpEntity = (props: EntityProps) => {
|
|
const multichainContext = useMultichainContext();
|
|
const partsProps = distributeEntityProps(props, multichainContext);
|
|
|
|
const content = <Content { ...partsProps.content }/>;
|
|
|
|
return (
|
|
<Container { ...partsProps.container }>
|
|
<Icon { ...partsProps.icon }/>
|
|
{ props.noLink ? content : <Link { ...partsProps.link }>{ content }</Link> }
|
|
<Copy { ...partsProps.copy }/>
|
|
</Container>
|
|
);
|
|
};
|
|
|
|
export default React.memo(chakra(UserOpEntity));
|
|
|
|
export {
|
|
Container,
|
|
Link,
|
|
Icon,
|
|
Content,
|
|
Copy,
|
|
};
|