Skip to content
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

Merged
merged 10 commits into from
Feb 24, 2017
Merged

Refactor tags to support custom colors #668

merged 10 commits into from
Feb 24, 2017

Conversation

llorca
Copy link
Contributor

@llorca llorca commented Feb 10, 2017

Fixes #606

Changes proposed in this pull request:

  • Refactor tag mixins significantly:
    • they're all called pt-tag[-*]() now to indicate that they're sort-of public.
    • this rename is a Sass API break but we don't semver that so it's ok.
    • make -intent and -minimal-intent mixins for custom coloring, and use them to generate our own intent styles.
.pt-tag.custom-rose-tag {
  // background, text-color (defaults to $white)
  @include pt-tag-intent($rose3);

  &.pt-minimal {
    // background, text, dark text
    @include pt-tag-minimal-intent($rose3, $rose2, $rose5);
  }
}

@llorca llorca requested a review from giladgray February 10, 2017 18:56
@blueprint-bot
Copy link

Add rose and cobalt class examples

Preview: docs
Coverage: core | datetime

@llorca llorca requested a review from cmslewis February 10, 2017 19:23
Copy link
Contributor

@giladgray giladgray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a really nice potential css refactor in here with this mixin, let's see if we can get there.

@@ -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";
Copy link
Contributor

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.

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎 these are not real modifiers; they cannot appear in the modifier table.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup that was just for showcase in the PR

background: none;
cursor: pointer;
padding: $tag-padding;
@mixin custom-tag($color, $dark-color, $background-color) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call this mixin tag-colors() and use it to implement intents above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 pt-minimal and pt-dark which would conflict with other usages above

@blueprint-bot
Copy link

Remove mock modifiers

Preview: docs
Coverage: core | datetime

@blueprint-bot
Copy link

Remove mock modifiers bis

Preview: docs
Coverage: core | datetime

@blueprint-bot
Copy link

Merge branch 'al/tag-mixin' of github.com:palantir/blueprint into al/tag-mixin

Preview: docs
Coverage: core | datetime

- they're all pt-tag-* now to indicate that they're somewhat public.
- this is a Sass API break but those are unsupported so it's chill.
- intent coloring has been pulled out to mixins--they don't come for free with the base mixin and that's ok.
@blueprint-bot
Copy link

big refactor of tag mixins

Preview: docs | table
Coverage: core | datetime

&:not([class*="pt-intent-"]) {
background: rgba($gray3, 0.2);
background-color: rgba($gray3, 0.2);
Copy link
Contributor

Choose a reason for hiding this comment

The 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 $light-gray4?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you put a $light-gray4 tag on top of a $light-gray4 background, you end up with a problem 🎩 Transparency keeps this safe no matter what the background color

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if I want an exact color for the background (e.g. some really light color from my style guide's color palette)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, but not a recommended practice for the same reasoning than above

Copy link
Contributor

@cmslewis cmslewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh I'll go ahead and approve. Looks good overall, just had a couple of questions. See above.

@giladgray giladgray merged commit 62d14c6 into master Feb 24, 2017
@giladgray giladgray deleted the al/tag-mixin branch February 24, 2017 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants