Skip to content

Commit c917148

Browse files
author
Shawn
authored
fix: long nft folder names wrapping in nft details (#1146)
* fix: long nft folder names wrapping in nft details * refactor: use ellipsis component
1 parent 4fa9095 commit c917148

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

packages/common/src/ui/lib/add-ellipsis.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ export const truncate = (text: string, partOneLength: number, partTwoLength: num
88
return `${text.slice(0, partOneLength)}${text.slice(text.length - partTwoLength)}`;
99
};
1010

11-
export const addEllipsis = (text: string, partOnelength: number, partTwoLength: number): string => {
12-
const textMinLenght = partOnelength + partTwoLength + addedLength;
13-
if (text.length <= textMinLenght) return text;
11+
export const addEllipsis = (text: string, partOneLength: number, partTwoLength: number): string => {
12+
const textMinLength = partOneLength + partTwoLength + addedLength;
13+
if (text.length <= textMinLength) return text;
1414

15-
return `${text.slice(0, partOnelength)}...${text.slice(text.length - partTwoLength)}`;
15+
return `${text.slice(0, partOneLength)}...${text.slice(text.length - partTwoLength)}`;
1616
};
1717

1818
const getCssStyle = (element: HTMLElement, prop: string) => window.getComputedStyle(element).getPropertyValue(prop);

packages/core/src/ui/components/Nft/NftDetail.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { InlineInfoList, LabeledInfo } from '@lace/common';
1+
import { Ellipsis, InlineInfoList, LabeledInfo } from '@lace/common';
22
import React, { ReactNode } from 'react';
33
import styles from './NftDetail.module.scss';
44
import { NftImage } from './NftImage';
@@ -74,13 +74,17 @@ export const NftDetail = ({
7474
<FolderOutlined />
7575
<span>Root</span>
7676
</Breadcrumb.Item>
77-
{folder && <Breadcrumb.Item>{folder}</Breadcrumb.Item>}
77+
{folder && (
78+
<Breadcrumb.Item>
79+
<Ellipsis text={folder} beforeEllipsis={5} afterEllipsis={5} />
80+
</Breadcrumb.Item>
81+
)}
7882
</Breadcrumb>
7983
) : (
8084
<Flex justifyContent="space-between" gap="$1">
8185
<Box>Root</Box>
8286
{folder && <Box px="$8">{'>'}</Box>}
83-
{folder && <Box>{folder}</Box>}
87+
{folder && <Ellipsis text={folder} beforeEllipsis={5} afterEllipsis={5} />}
8488
</Flex>
8589
)
8690
}

0 commit comments

Comments
 (0)