mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* epochs page * epoch rewards distribution * epoch election rewards * address epoch rewards * block epoch tag * add some tests * adjust epoch details for L1 epochs * support non-finalized epochs * fixes after design review * add truncation to block numbers on mobile * update epochs table layout * update timestamp hint * fix bug with subheading of first epoch * fixes of mobile view * update screenshots
36 lines
899 B
TypeScript
36 lines
899 B
TypeScript
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 <chakra.span as={ as }>{ hash }</chakra.span>;
|
|
}
|
|
|
|
const content = <chakra.span as={ as }>{ shortenString(hash, charNumber) }</chakra.span>;
|
|
|
|
if (noTooltip) {
|
|
return content;
|
|
}
|
|
|
|
return (
|
|
<Tooltip content={ hash } interactive={ tooltipInteractive }>
|
|
{ content }
|
|
</Tooltip>
|
|
);
|
|
};
|
|
|
|
export default HashStringShorten;
|