Skip to content

Commit

Permalink
fix(button): truncate the label instead of wrapping it
Browse files Browse the repository at this point in the history
fix(dropdown): limit button width to allow the label to be truncated
  • Loading branch information
daenub authored May 23, 2024
1 parent 7b7402f commit 4118c0b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class LeuButton extends LitElement {
type=${this.type}
>
${this.renderIconBefore()}
<slot></slot>
<span class="label"><slot></slot></span>
${this.renderIconAfter()} ${this.renderExpandingIcon()}
</button>
`
Expand Down
13 changes: 13 additions & 0 deletions src/components/button/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@ button {
cursor: pointer;
border: 1px solid transparent;
border-radius: 2px;

max-width: 100%;
display: flex;
align-items: center;
column-gap: 8px;
}

.label {
flex: 1 1 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.icon .label {
display: none;
}

button.round {
border-radius: 50%;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class LeuDropdown extends LitElement {
autoSizePadding="8"
>
<leu-button
class="button"
slot="anchor"
icon="download"
variant="ghost"
Expand Down
4 changes: 4 additions & 0 deletions src/components/dropdown/dropdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@

margin-top: 0.5rem;
}

.button {
max-width: 100%;
}

0 comments on commit 4118c0b

Please sign in to comment.