Skip to content

Commit

Permalink
fix(tag): add support for ellipses when width is constrained (#4518)
Browse files Browse the repository at this point in the history
* fix: tag not using elipses when width constrained

* fix: also fix standard tag

* chore: review update
  • Loading branch information
lee-chase authored and joshblack committed Dec 5, 2019
1 parent c41ff2a commit 3118b69
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
20 changes: 19 additions & 1 deletion packages/components/src/components/tag/_tag.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
@mixin tags {
.#{$prefix}--tag {
@include type-style('label-01');

display: inline-flex;
position: relative;
align-items: center;
padding: 0 $carbon--spacing-03;
height: 1.5rem;
max-width: 100%; // restricts size of contained elements
margin: $carbon--spacing-02;
border-radius: rem(15px);

Expand Down Expand Up @@ -81,14 +84,28 @@
}
}

.#{$prefix}--tag__label {
max-width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}

// tags used for filtering
.#{$prefix}--tag--filter {
@include tag-theme($inverse-02, $inverse-01);

cursor: pointer;
padding-right: rem(2px); // Align with hover circle of X button
padding-right: calc(
#{$carbon--spacing-06} + #{rem(2px)}
); // icon width + 2px space from right edge
}

.#{$prefix}--tag--filter > svg {
position: absolute;
right: rem(2px);
top: 50%;
transform: translateY(-50%);
fill: $inverse-01;
margin-left: rem(4px);
padding: rem(2px);
Expand All @@ -114,6 +131,7 @@
// Skeleton state
.#{$prefix}--tag.#{$prefix}--skeleton {
@include skeleton;

width: rem(60px);
overflow: hidden;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/components/src/components/tag/tag.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

<div role="list">
{{#each tags}}
<span class="{{@root.prefix}}--tag {{@root.prefix}}--tag--{{type}}" role="listitem">{{label}}</span>
<span class="{{@root.prefix}}--tag {{@root.prefix}}--tag--{{type}}" role="listitem">
<span class="{{@root.prefix}}--tag__label">{{label}}</span>
</span>
{{/each}}
</div>

<div role="list">
{{#if filter}}
<span class="{{@root.prefix}}--tag {{@root.prefix}}--tag--filter" title="Clear filter" tabindex="0" role="listitem">
filter
<span class="{{@root.prefix}}--tag__label">filter</span>
{{ carbon-icon 'Close16' aria-label='Clear filter' }}
</span>
{{/if}}
Expand Down

0 comments on commit 3118b69

Please sign in to comment.