import { chakra } from '@chakra-ui/react';
import React from 'react';
import shortenString from 'lib/shortenString';
import { Tooltip } from 'toolkit/chakra/tooltip';
interface Props {
hash: string;
noTooltip?: boolean;
tooltipInteractive?: boolean;
type?: 'long' | 'short';
maxSymbols?: number;
as?: React.ElementType;
}
const HashStringShorten = ({ hash, noTooltip, as = 'span', type, tooltipInteractive, maxSymbols }: Props) => {
const charNumber = maxSymbols ?? (type === 'long' ? 16 : 8);
if (hash.length <= charNumber) {
return { hash };
}
const content = { shortenString(hash, charNumber) };
if (noTooltip) {
return content;
}
return (
{ content }
);
};
export default HashStringShorten;