-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor tags to support custom colors #668
Changes from 2 commits
3926c11
f565436
aaaf335
afe6944
3d22cc2
b243e62
53c37d6
7da661f
fbc1d4f
eb01b34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,16 @@ $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; | ||
|
||
$tag-removable-selector: "&.pt-tag-removable"; | ||
|
||
// styles for a default .pt-tag | ||
@mixin tag($removable-selector: "&.pt-tag-removable") { | ||
@mixin 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 +32,51 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default; | |
} | ||
|
||
.pt-dark & { | ||
&:not([class*="pt-intent-"]) { | ||
background: $gray5; | ||
color: $pt-text-color; | ||
} | ||
} | ||
|
||
#{$removable-selector} { | ||
padding-right: $tag-height; | ||
background-color: $gray5; | ||
color: $pt-text-color; | ||
} | ||
|
||
@each $intent, $color in $pt-intent-colors { | ||
&.pt-intent-#{$intent} { | ||
background: $color; | ||
background-color: $color; | ||
color: $white; | ||
} | ||
} | ||
|
||
#{$tag-removable-selector} { | ||
padding-right: $tag-height; | ||
|
||
.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: inherit; | ||
|
||
&:hover { | ||
opacity: 0.8; | ||
background: none; | ||
text-decoration: none; | ||
} | ||
|
||
&:active { | ||
opacity: 1; | ||
} | ||
|
||
&::before { | ||
content: $pt-icon-small-cross; | ||
} | ||
} | ||
} | ||
} | ||
|
||
// updated properties for a .pt-tag.pt-large | ||
@mixin tag-large($removable-selector: "&.pt-tag-removable") { | ||
@mixin tag-large() { | ||
min-width: $tag-height-large; | ||
padding: $tag-padding-large ($tag-padding-large * 2); | ||
line-height: $pt-icon-size-large; | ||
|
@@ -59,84 +86,49 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default; | |
border-radius: $tag-height-large / 2; | ||
} | ||
|
||
#{$removable-selector} { | ||
#{$tag-removable-selector} { | ||
padding-right: $tag-height-large; | ||
|
||
.pt-tag-remove { | ||
@include pt-icon-sized($pt-icon-size-large); | ||
|
||
padding: $tag-padding-large; | ||
} | ||
} | ||
} | ||
|
||
@mixin tag-minimal() { | ||
&:not([class*="pt-intent-"]) { | ||
background: rgba($gray3, 0.2); | ||
background-color: rgba($gray3, 0.2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of scope for this PR, but whoa, didn't realize we were using a non-standard color for minimal-tag backgrounds. Reasoning for not just using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you put a |
||
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); | ||
background-color: rgba($color, 0.2); | ||
color: map-get($pt-intent-text-colors, $intent); | ||
} | ||
|
||
.pt-dark &.pt-intent-#{$intent} { | ||
background: rgba($color, 0.2); | ||
color: map-get($pt-dark-intent-text-colors, $intent); | ||
.pt-dark & { | ||
color: map-get($pt-dark-intent-text-colors, $intent); | ||
} | ||
} | ||
} | ||
} | ||
|
||
// styles for default .pt-tag-remove | ||
@mixin tag-remove() { | ||
@include pt-icon(); | ||
|
||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
opacity: 0.5; | ||
|
||
border: none; | ||
background: none; | ||
cursor: pointer; | ||
padding: $tag-padding; | ||
@mixin custom-tag($color, $dark-color, $background-color) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. call this mixin There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to do that yesterday, but it's actually not that easy because this mixin implement its own |
||
background: $background-color; | ||
color: $white; | ||
|
||
&:hover { | ||
opacity: 0.8; | ||
background: none; | ||
text-decoration: none; | ||
} | ||
|
||
&::before { | ||
content: $pt-icon-small-cross; | ||
} | ||
|
||
// 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; | ||
} | ||
} | ||
|
||
// 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; | ||
&.pt-minimal { | ||
background-color: rgba($background-color, 0.2); | ||
color: $color; | ||
|
||
@each $intent, $color in $pt-intent-colors { | ||
.pt-intent-#{$intent} & { | ||
color: $color; | ||
} | ||
|
||
.pt-dark .pt-intent-#{$intent} & { | ||
color: $color; | ||
.pt-dark & { | ||
color: $dark-color; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,8 @@ Markup: | |
.pt-intent-success - Success intent | ||
.pt-intent-warning - Warning intent | ||
.pt-intent-danger - Danger intent | ||
.pt-rose - Rose | ||
.pt-cobalt - Cobalt | ||
|
||
Styleguide components.tag.css | ||
*/ | ||
|
@@ -80,6 +82,8 @@ Styleguide components.tag.css | |
.pt-intent-success - Success intent | ||
.pt-intent-warning - Warning intent | ||
.pt-intent-danger - Danger intent | ||
.pt-rose - Rose | ||
.pt-cobalt - Cobalt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👎 these are not real modifiers; they cannot appear in the modifier table. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup that was just for showcase in the PR |
||
|
||
Styleguide components.tag.css.minimal | ||
*/ | ||
|
@@ -89,19 +93,6 @@ Styleguide components.tag.css | |
} | ||
} | ||
|
||
.pt-tag-remove { | ||
@include tag-remove(); | ||
|
||
.pt-large & { | ||
@include tag-remove-large(); | ||
} | ||
|
||
.pt-minimal & { | ||
@include tag-remove-minimal(); | ||
} | ||
} | ||
|
||
|
||
/* | ||
JavaScript API | ||
|
||
|
@@ -129,3 +120,11 @@ Blueprint class name. | |
|
||
Styleguide components.tag.js | ||
*/ | ||
|
||
.pt-tag.pt-rose { | ||
@include custom-tag($rose2, $rose4, $rose3); | ||
} | ||
|
||
.pt-tag.pt-cobalt { | ||
@include custom-tag($cobalt2, $cobalt4, $cobalt3); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for variable here cuz it can't be customized anymore. just do the normal selector thing and write it out in css below.