Skip to content

Commit

Permalink
[name] Shorten ANS names down to a shorter name (#842)
Browse files Browse the repository at this point in the history
* [name] Shorten ANS names down to a shorter name

* address comments
  • Loading branch information
gregnazario authored Oct 24, 2024
1 parent 59ebadd commit 47ac11a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/components/HashButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from "../themes/colors/aptosColorPalette";
import ChevronRightRoundedIcon from "@mui/icons-material/ChevronRightRounded";
import ChevronLeftRoundedIcon from "@mui/icons-material/ChevronLeftRounded";
import {truncateAddress, truncateAddressMiddle} from "../pages/utils";
import {truncate, truncateAddress, truncateAddressMiddle} from "../pages/utils";
import {assertNever} from "../utils";
import {useGetNameFromAddress} from "../api/hooks/useGetANS";
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
Expand Down Expand Up @@ -157,8 +157,8 @@ function AccountHashButtonInner({
textDecoration: "none",
}}
>
<Tooltip title={hash} enterDelay={500} enterNextDelay={500}>
<span>{name ?? truncateHash}</span>
<Tooltip title={name ?? hash} enterDelay={500} enterNextDelay={500}>
<span>{name ? truncate(name, 9, 11, "…") : truncateHash}</span>
</Tooltip>
<Tooltip title="Copied" open={copyTooltipOpen}>
<Button
Expand Down
2 changes: 1 addition & 1 deletion src/pages/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function timestampDisplay(timestamp: moment.Moment): TimestampDisplay {
};
}

function truncate(
export function truncate(
str: string,
frontLen: number,
backLen: number,
Expand Down

0 comments on commit 47ac11a

Please sign in to comment.