Skip to content

Commit 66a09e9

Browse files
committed
Add Badge Ellipsis content boolean toggle
1 parent 002599a commit 66a09e9

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/components/Badge/Badge.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface CommonBadgeProps extends HTMLAttributes<HTMLDivElement> {
2424
type?: BadgeType;
2525
icon?: ImageName;
2626
iconDir?: HorizontalDirection;
27+
ellipsisContent?: boolean;
2728
}
2829

2930
export interface DismissibleBadge extends CommonBadgeProps {
@@ -95,6 +96,7 @@ export const Badge = ({
9596
type,
9697
dismissible,
9798
onClose,
99+
ellipsisContent = true,
98100
...props
99101
}: BadgeProps) => (
100102
<Wrapper
@@ -110,6 +112,7 @@ export const Badge = ({
110112
iconDir={iconDir}
111113
size={size}
112114
$state={state}
115+
ellipsisContent={ellipsisContent}
113116
>
114117
{text}
115118
</BadgeContent>

src/components/IconWrapper/IconWrapper.tsx

+14-9
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,27 @@ const LabelContainer = styled.div<{ $hasIcon: boolean; $iconDir: HorizontalDirec
2121
gap: ${({ theme }) => theme.click.sidebar.navigation.item.default.space.gap};
2222
`;
2323

24+
interface IconWrapperProps {
25+
icon?: IconName;
26+
iconDir?: HorizontalDirection;
27+
size?: IconSize;
28+
width?: number | string;
29+
height?: number | string;
30+
children: ReactNode;
31+
ellipsisContent?: boolean;
32+
}
33+
2434
const IconWrapper = ({
2535
icon,
2636
iconDir = "start",
2737
size = "sm",
2838
width,
2939
height,
3040
children,
41+
ellipsisContent = true,
3142
...props
32-
}: {
33-
icon?: IconName;
34-
iconDir?: HorizontalDirection;
35-
children: ReactNode;
36-
size?: IconSize;
37-
width?: number | string;
38-
height?: number | string;
39-
}) => {
43+
}: IconWrapperProps) => {
44+
const TextWrapper = ellipsisContent ? EllipsisContent : "div";
4045
return (
4146
<LabelContainer
4247
$hasIcon={typeof icon === "string"}
@@ -51,7 +56,7 @@ const IconWrapper = ({
5156
height={height}
5257
/>
5358
)}
54-
<EllipsisContent>{children}</EllipsisContent>
59+
<TextWrapper>{children}</TextWrapper>
5560
{icon && iconDir === "end" && (
5661
<Icon
5762
name={icon}

0 commit comments

Comments
 (0)