Skip to content

Commit

Permalink
feat(tag): increase icon size and add ellipsis
Browse files Browse the repository at this point in the history
  • Loading branch information
dpellier committed Jul 29, 2024
1 parent 0de4440 commit 44de498
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import '../../../../../style/font';
@import '../../../../../style/tag';

:host(.ods-tag) {
Expand Down Expand Up @@ -77,10 +78,24 @@

&--md {
@include ods-tag-size('md');

& #{$tag}__close,
& #{$tag}__icon {
font-size: 1rem;
}
}

&--lg {
@include ods-tag-size('lg');

& #{$tag}__close,
& #{$tag}__icon {
font-size: 1.25rem;
}
}

&__label {
@include ellipsis();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,19 @@ export class OdsTag {
tabindex={ this.isDisabled ? -1 : 0 }>
{
!!this.icon &&
<ods-icon name={ this.icon }>
<ods-icon
class="ods-tag__tag__icon"
name={ this.icon }>
</ods-icon>
}

{ this.label }
<span class="ods-tag__tag__label">
{ this.label }
</span>

<ods-icon name={ ODS_ICON_NAME.cross }>
<ods-icon
class="ods-tag__tag__close"
name={ ODS_ICON_NAME.cross }>
</ods-icon>
</div>
</Host>
Expand Down
4 changes: 4 additions & 0 deletions packages/ods/src/components/tag/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
<ods-tag label="SM tag" size="sm"></ods-tag>
<ods-tag label="MD tag" size="md"></ods-tag>
<ods-tag label="LG tag" size="lg"></ods-tag>
<br /><br />
<ods-tag icon="star" label="SM tag" size="sm"></ods-tag>
<ods-tag icon="star" label="MD tag" size="md"></ods-tag>
<ods-tag icon="star" label="LG tag" size="lg"></ods-tag>

<p>Variant</p>
<ods-tag label="Default tag" variant="default"></ods-tag>
Expand Down
15 changes: 15 additions & 0 deletions packages/ods/src/style/_font.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@use 'sass:math';

/**
* Transform a px value to its rem equivalent
* ex: px-to-rem(14px) => return 0.875rem
*/
@function px-to-rem($size, $font-size: 16px) {
@return math.div($size, $font-size) * 1rem;
}

@mixin ellipsis() {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
1 change: 1 addition & 0 deletions packages/ods/src/style/index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@forward 'button';
@forward 'focus';
@forward 'font';
@forward 'link';
@forward 'skeleton';
@forward 'tag';
Expand Down

0 comments on commit 44de498

Please sign in to comment.