Files
explore/ui/shared/HashStringShorten.tsx
T
tom goriunovandGitHub 4563b9fe75 components for Block and Tx entities (#1108)
* base implementation of entity

* refactor other components to make use of BlockEntity

* tests

* migrate entities w/o icon + L2 blocks

* base implementation of tx entity

* delet TransactionSnippet

* remove type="transaction" from AddressLink

* tests for TxEntity

* make EntityBase components

* common styles for icon color and spacing to text

* update icon color in tests

* update icons to slime format

* Address entity
2023-08-23 18:08:01 -04:00

26 lines
619 B
TypeScript

import { Tooltip, chakra } from '@chakra-ui/react';
import type { As } from '@chakra-ui/react';
import React from 'react';
import shortenString from 'lib/shortenString';
interface Props {
hash: string;
isTooltipDisabled?: boolean;
as?: As;
}
const HashStringShorten = ({ hash, isTooltipDisabled, as = 'span' }: Props) => {
if (hash.length <= 8) {
return <chakra.span as={ as }>{ hash }</chakra.span>;
}
return (
<Tooltip label={ hash } isDisabled={ isTooltipDisabled }>
<chakra.span as={ as }>{ shortenString(hash) }</chakra.span>
</Tooltip>
);
};
export default HashStringShorten;