Skip to content

Commit

Permalink
refactor(tag): move interactivity styles to close button
Browse files Browse the repository at this point in the history
  • Loading branch information
emyarod committed Mar 5, 2020
1 parent e76c0b3 commit 7422043
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions packages/components/src/components/tag/_tag.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@
// tags used for filtering
.#{$prefix}--tag--filter {
@include tag-theme($inverse-02, $inverse-01);

cursor: pointer;
padding-right: rem(2px);

&:focus,
Expand All @@ -108,28 +106,34 @@
}
}

.#{$prefix}--tag--filter > svg {
.#{$prefix}--tag__close-icon {
flex-shrink: 0;
width: rem(20px);
height: rem(20px);
margin: 0 0 0 rem(4px);
padding: rem(2px);
border: 0;
fill: $inverse-01;
background-color: transparent;
border-radius: 50%;
cursor: pointer;

&:hover {
background-color: $inverse-hover-ui;
}
}

.#{$prefix}--tag--filter:focus > svg {
.#{$prefix}--tag__close-icon svg {
fill: $inverse-01;
}

.#{$prefix}--tag__close-icon:focus {
outline: none;
box-shadow: inset 0 0 0 2px $inverse-focus-ui;
border-radius: 50%;
}

.#{$prefix}--tag--filter.#{$prefix}--tag--disabled svg:hover {
.#{$prefix}--tag--filter.#{$prefix}--tag--disabled
.#{$prefix}--tag__close-icon:hover {
background-color: transparent;
}

Expand Down
8 changes: 5 additions & 3 deletions packages/components/src/components/tag/tag.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@

<div>
{{#if filter}}
<button class="{{@root.prefix}}--tag {{@root.prefix}}--tag--filter" title="Clear filter">
<div class="{{@root.prefix}}--tag {{@root.prefix}}--tag--filter" title="Clear filter">
<span class="{{@root.prefix}}--tag__label">filter</span>
{{ carbon-icon 'Close16' }}
</button>
<button class="{{@root.prefix}}--tag__close-icon">
{{ carbon-icon 'Close16' }}
</button>
</div>
{{/if}}
</div>
8 changes: 5 additions & 3 deletions packages/react/src/components/Tag/Tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Tag = ({
onClose(event);
};
return filter ? (
<button
<div
className={tagClasses}
aria-label={
title !== undefined
Expand All @@ -58,8 +58,10 @@ const Tag = ({
<span className={`${prefix}--tag__label`}>
{children !== null && children !== undefined ? children : TYPES[type]}
</span>
<Close16 onClick={handleClose} />
</button>
<button className={`${prefix}--tag__close-icon`} onClick={handleClose}>
<Close16 />
</button>
</div>
) : (
<span className={tagClasses} {...other}>
{children !== null && children !== undefined ? children : TYPES[type]}
Expand Down

0 comments on commit 7422043

Please sign in to comment.