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

[Feature request] Tailwind 1.4.0 support - new color opacity utilities #21

Closed
AndrewBogdanovTSS opened this issue Apr 30, 2020 · 8 comments
Labels
enhancement New feature or request
Milestone

Comments

@AndrewBogdanovTSS
Copy link

After TailwindCSS introduced new color opacity utilities current approach of opacity and colors generation became not inlined with the official way colors are generated in tailwindCSS.
As a result classes such as bg-opacity-25, text-opacity-25 makes no difference to the opacity level.

@hawezo I actually have mixed feelings about 1.4.0 color utilities and I like how you implemented it - more, but what can we do here? I guess when using tailwind-theming we should still have an access to full list of tailwind features. But what is really great about your approach with colors is that it's fully polyfillable for IE11 and 1.4.0 colors - are not. So maybe let's discuss what is the best thing that should be done here

@innocenzi
Copy link
Owner

innocenzi commented May 1, 2020

So, this if fixable with a change on Tailwind's core, but that would be a bit hacky, not sure if Adam would be open to this. I asked him on the Discord and tagged you.

If it's not possible to do that, the best bet would be to disable Tailwind's opacity utilities' implementation.


EDIT - Actually I've found a better solution and I think Adam would like it better. Same principle but different implementation.

@innocenzi innocenzi added this to the v3.0 milestone May 1, 2020
@innocenzi innocenzi added enhancement New feature or request help wanted Extra attention is needed labels May 1, 2020
@innocenzi
Copy link
Owner

innocenzi commented May 1, 2020

tailwindlabs/tailwindcss#1676 (comment)


@AndrewBogdanovTSS Answering there, because the PR wasn't the place.

Normally, that would eventually be polyfillable, since I plan on generating that type of utility:

.text-primary-75 {
  color: rgba(32, 32, 32, var(--text-opacity, 0.75));
}

Where --text-opacity is used by Tailwind's opacity utilities, and .75 is the default value, defined by the plugin's variant.

Ran through postcss-custom-properties, it gives the following CSS:

.text-primary-75 {
  color: rgba(32, 32, 32, 0.75);
  color: rgba(32, 32, 32, var(--text-opacity, 0.75));
}

If I need to use a CSS variable instead of a hard-coded value for some reason, I can have a double fallback which polyfills the same:

/* Generated */
.text-primary {
  color: rgba(32, 32, 32, var(--text-opacity, var(--color-primary-opacity-variant, 0.75)));
}

/* Polyfilled */
.text-primary-75 {
  color: rgba(32, 32, 32, 0.75);
  color: rgba(32, 32, 32, var(--text-opacity, var(--color-primary-opacity-variant, 0.75)));
}

Basically, we can do text-primary-75, which will work as expected, and things like text-primary-75 text-opacity-100 which will have an opacity of 1 on modern browsers but will fallback to 75 on IE.

Does that answer your concerns?

@AndrewBogdanovTSS
Copy link
Author

Ok, so in order to have IE11 support we will have to stick to using utilities such as .text-primary-75 instead of .text-primary text-opacity-75 right?

@innocenzi
Copy link
Owner

Exactly.

@innocenzi innocenzi removed the help wanted Extra attention is needed label May 1, 2020
@AndrewBogdanovTSS
Copy link
Author

AndrewBogdanovTSS commented May 1, 2020

I can live with that 😄

@MrMacStripe
Copy link

Hey @innocenzi
do you still need help on this feature?

@innocenzi
Copy link
Owner

Hey, it's in stand-by right now because I don't have time for this, unfortunately. Even if you PR'd it, I would probably not have the time to review and test it either... I hope to be able to get back to this project in the coming months, I need to tag @next to @latest as well. In the meantime, sorry, you'll have to do without this feature or use one of the other theming plugins :(

@MrMacStripe
Copy link

Thanks for the quick answer. I love the approach of your plugin and don't plan to ditch it. I'll have a look and let you know if I can provide a solution down the road.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants