Skip to content

Commit

Permalink
Allow <Badge /> to handle text truncation with max width
Browse files Browse the repository at this point in the history
  • Loading branch information
calebjacob committed Nov 12, 2024
1 parent c523e6e commit 7be4b1f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-pagoda/ui",
"version": "2.0.8",
"version": "2.0.9",
"description": "A React component library that implements the official NEAR design system.",
"license": "MIT",
"repository": {
Expand Down
11 changes: 11 additions & 0 deletions src/components/Badge.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
outline: none;
transition: var(--transitions);

button:has(> &) {
min-width: min-content !important;
}

&[role='button'] {
border-radius: 100px;
cursor: pointer;
Expand Down Expand Up @@ -94,6 +98,7 @@
color: var(--badge-color-icon);
width: 16px;
height: 16px;
flex-shrink: 0;

svg {
width: 100%;
Expand All @@ -102,3 +107,9 @@
stroke: currentColor;
}
}

.label {
overflow: hidden;
text-overflow: ellipsis;
min-width: 0;
}
2 changes: 1 addition & 1 deletion src/components/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Badge = forwardRef<HTMLSpanElement, Props>(
{...props}
>
{iconLeft && <span className={s.icon}>{iconLeft}</span>}
{label}
<span className={s.label}>{label}</span>
{iconRight && <span className={s.icon}>{iconRight}</span>}
</span>
);
Expand Down

0 comments on commit 7be4b1f

Please sign in to comment.