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

fix: long nft folder names wrapping in nft details #1146

Merged
merged 3 commits into from
May 13, 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
8 changes: 4 additions & 4 deletions packages/common/src/ui/lib/add-ellipsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export const truncate = (text: string, partOneLength: number, partTwoLength: num
return `${text.slice(0, partOneLength)}${text.slice(text.length - partTwoLength)}`;
};

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

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

const getCssStyle = (element: HTMLElement, prop: string) => window.getComputedStyle(element).getPropertyValue(prop);
Expand Down
10 changes: 7 additions & 3 deletions packages/core/src/ui/components/Nft/NftDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InlineInfoList, LabeledInfo } from '@lace/common';
import { Ellipsis, InlineInfoList, LabeledInfo } from '@lace/common';
import React, { ReactNode } from 'react';
import styles from './NftDetail.module.scss';
import { NftImage } from './NftImage';
Expand Down Expand Up @@ -74,13 +74,17 @@ export const NftDetail = ({
<FolderOutlined />
<span>Root</span>
</Breadcrumb.Item>
{folder && <Breadcrumb.Item>{folder}</Breadcrumb.Item>}
{folder && (
<Breadcrumb.Item>
<Ellipsis text={folder} beforeEllipsis={5} afterEllipsis={5} />
</Breadcrumb.Item>
)}
</Breadcrumb>
) : (
<Flex justifyContent="space-between" gap="$1">
<Box>Root</Box>
{folder && <Box px="$8">{'>'}</Box>}
{folder && <Box>{folder}</Box>}
{folder && <Ellipsis text={folder} beforeEllipsis={5} afterEllipsis={5} />}
</Flex>
)
}
Expand Down
Loading