Skip to content

Commit

Permalink
feat: add leading and trailing chars to pubkey component
Browse files Browse the repository at this point in the history
  • Loading branch information
Aerilym committed Jul 1, 2024
1 parent 1dcd8b1 commit 27975d4
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions apps/staking/components/PubKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,31 @@ import { HTMLAttributes, forwardRef, useCallback, useEffect, useMemo, useState }

type PubKeyType = HTMLAttributes<HTMLDivElement> & {
pubKey: string;
leadingChars?: number;
trailingChars?: number;
expandOnHover?: boolean;
alwaysShowCopyButton?: boolean;
};

const PubKey = forwardRef<HTMLDivElement, PubKeyType>(
({ className, pubKey, expandOnHover, alwaysShowCopyButton, ...props }, ref) => {
(
{
className,
pubKey,
leadingChars,
trailingChars,
expandOnHover,
alwaysShowCopyButton,
...props
},
ref
) => {
const dictionary = useTranslations('clipboard');
const [isSelected, setIsSelected] = useState(false);
const collapsedPubKey = useMemo(() => collapseString(pubKey, 6, 6), [pubKey]);
const collapsedPubKey = useMemo(
() => collapseString(pubKey, leadingChars ?? 6, trailingChars ?? 6),
[pubKey]
);

const handleSelectionChange = useCallback(() => {
const selection = window.getSelection();
Expand Down

0 comments on commit 27975d4

Please sign in to comment.