Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[name] Shorten ANS names down to a shorter name #842

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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