diff --git a/packages/core/src/components/tag/_common.scss b/packages/core/src/components/tag/_common.scss index c9ae5c48fb5..bb3df7f8ec9 100644 --- a/packages/core/src/components/tag/_common.scss +++ b/packages/core/src/components/tag/_common.scss @@ -11,14 +11,13 @@ $tag-margin: ($pt-input-height - $tag-height) / 2 !default; $tag-height-large: $pt-grid-size * 3 !default; $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default; -// styles for a default .pt-tag -@mixin tag($removable-selector: "&.pt-tag-removable") { +@mixin pt-tag() { display: inline-block; position: relative; border: none; border-radius: $pt-border-radius; box-shadow: none; - background: $gray1; + background-color: $gray1; min-width: $tag-height; padding: $tag-padding ($tag-padding * 3); line-height: $pt-icon-size-standard; @@ -30,26 +29,16 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default; } .pt-dark & { - &:not([class*="pt-intent-"]) { - background: $gray5; - color: $pt-text-color; - } + background-color: $gray5; + color: $pt-text-color; } - #{$removable-selector} { + &.pt-tag-removable { padding-right: $tag-height; } - - @each $intent, $color in $pt-intent-colors { - &.pt-intent-#{$intent} { - background: $color; - color: $white; - } - } } -// updated properties for a .pt-tag.pt-large -@mixin tag-large($removable-selector: "&.pt-tag-removable") { +@mixin pt-tag-large() { min-width: $tag-height-large; padding: $tag-padding-large ($tag-padding-large * 2); line-height: $pt-icon-size-large; @@ -59,49 +48,49 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default; border-radius: $tag-height-large / 2; } - #{$removable-selector} { + &.pt-tag-removable { padding-right: $tag-height-large; } } -@mixin tag-minimal() { +@mixin pt-tag-intent($background-color, $text-color: $white) { + background: $background-color; + color: $text-color; +} + +@mixin pt-tag-minimal() { &:not([class*="pt-intent-"]) { - background: rgba($gray3, 0.2); + background-color: rgba($gray3, 0.2); color: $pt-text-color; .pt-dark & { - background: rgba($gray3, 0.2); color: $pt-dark-text-color; } } +} - @each $intent, $color in $pt-intent-colors { - &.pt-intent-#{$intent} { - background: rgba($color, 0.15); - color: map-get($pt-intent-text-colors, $intent); - } +@mixin pt-tag-minimal-intent($background-color, $text-color, $dark-text-color) { + background-color: rgba($background-color, 0.15); + color: $text-color; - .pt-dark &.pt-intent-#{$intent} { - background: rgba($color, 0.2); - color: map-get($pt-dark-intent-text-colors, $intent); - } + .pt-dark & { + background-color: rgba($background-color, 0.25); + color: $dark-text-color; } } -// styles for default .pt-tag-remove -@mixin tag-remove() { +@mixin pt-tag-remove() { @include pt-icon(); position: absolute; top: 0; right: 0; opacity: 0.5; - border: none; background: none; cursor: pointer; padding: $tag-padding; - color: $white; + color: inherit; &:hover { opacity: 0.8; @@ -109,34 +98,16 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default; text-decoration: none; } - &::before { - content: $pt-icon-small-cross; + &:active { + opacity: 1; } - // standard (non-minimal) tags have a unique text color in dark theme. - // intent tags don't change in the dark theme. - .pt-dark .pt-tag:not(.pt-minimal):not([class*="pt-intent-"]) & { - color: $pt-text-color; + &::before { + content: $pt-icon-small-cross; } -} -// updated properties for .pt-tag.pt-large .pt-tag-remove -@mixin tag-remove-large() { - @include pt-icon-sized($pt-icon-size-large); - margin-left: $pt-grid-size / 2; - padding: $tag-padding-large; -} - -@mixin tag-remove-minimal() { - color: inherit; - - @each $intent, $color in $pt-intent-colors { - .pt-intent-#{$intent} & { - color: $color; - } - - .pt-dark .pt-intent-#{$intent} & { - color: $color; - } + .pt-large & { + @include pt-icon-sized($pt-icon-size-large); + padding: $tag-padding-large; } } diff --git a/packages/core/src/components/tag/_tag.scss b/packages/core/src/components/tag/_tag.scss index 2f5d0420298..4ae25d5eab8 100644 --- a/packages/core/src/components/tag/_tag.scss +++ b/packages/core/src/components/tag/_tag.scss @@ -53,11 +53,17 @@ Styleguide components.tag.css */ .pt-tag { - @include tag(); + @include pt-tag(); &.pt-large, .pt-large & { - @include tag-large(); + @include pt-tag-large(); + } + + @each $intent, $color in $pt-intent-colors { + &.pt-intent-#{$intent} { + @include pt-tag-intent($color); + } } /* @@ -85,23 +91,24 @@ Styleguide components.tag.css */ &.pt-minimal { - @include tag-minimal(); + @include pt-tag-minimal(); + + @each $intent, $color in $pt-intent-colors { + &.pt-intent-#{$intent} { + @include pt-tag-minimal-intent( + $color, + map-get($pt-intent-text-colors, $intent), + map-get($pt-dark-intent-text-colors, $intent) + ); + } + } } } .pt-tag-remove { - @include tag-remove(); - - .pt-large & { - @include tag-remove-large(); - } - - .pt-minimal & { - @include tag-remove-minimal(); - } + @include pt-tag-remove(); } - /* JavaScript API