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

feat(preset-wind): add important option #3484

Merged
merged 5 commits into from
Jan 25, 2024

Conversation

xsjcTony
Copy link
Contributor

@xsjcTony xsjcTony commented Jan 2, 2024

This is the implementation for #3474

Regarding the usage of :is() selector, please read tailwindlabs/tailwindcss#10835

@xsjcTony xsjcTony requested a review from antfu as a code owner January 2, 2024 08:05
Copy link

netlify bot commented Jan 2, 2024

Deploy Preview for unocss ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 88b9c0b
🔍 Latest deploy log https://app.netlify.com/sites/unocss/deploys/65ae462177abd40008db522e
😎 Deploy Preview https://deploy-preview-3484--unocss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

return {
...presetMini(options),
name: '@unocss/preset-wind',
theme,
rules,
shortcuts,
variants: variants(options),
postprocess: postprocessors(options),
Copy link
Member

Choose a reason for hiding this comment

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

I feel it would be better to update the variant directly instead of relying on postprocess, which will affect all !important even if it's the user's explicit rule that does not come from the important variant.

Copy link
Contributor Author

@xsjcTony xsjcTony Jan 2, 2024

Choose a reason for hiding this comment

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

I don't get your point. if you mean it's better to change important:xxx variant, then it's another story. The purpose of this PR is as I described in #3474, which should and will apply to all rules (and that's what Tailwind's important global option does too). It will help users fight against those UI library's styles with higher specificity, globally.

Overall, I don't think changing the important:xxx variant is a good idea since essentially user will sometimes need to write the real !important. Changing its behavior makes no sense.

For your partially opt-in idea, I have a better (at least from my perspective) solution described in #3474 (comment), please welcome to have a look and leave your comment.

Copy link
Member

@antfu antfu Jan 3, 2024

Choose a reason for hiding this comment

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

Ok, I see. I thought it was the configuration for the important variant, but actually not. Making sense then, I think we should mention that this would affect all rules. Or maybe it's worth to have a dedicated preset for more explicit awareness and compsables with other rules.

Copy link
Contributor Author

@xsjcTony xsjcTony Jan 3, 2024

Choose a reason for hiding this comment

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

It's tailwind's functionality so I think it makes sense to include it in preset-wind. But it's up to you anyway.

If you want to proceed with that, I'll add a warning block to the doc. Otherwise you can close this and I don't mind to put it into my own preset for my own usages.

By the way what do you think about my ancestor-xxx: variant idea #3474 (comment)? it could be a potential solution for this. (scope-x:) is already doing such thing.

Copy link
Contributor Author

@xsjcTony xsjcTony Jan 3, 2024

Choose a reason for hiding this comment

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

I've updated the doc
Snipaste_2024-01-03_22-54-40

@antfu antfu added this pull request to the merge queue Jan 25, 2024
Merged via the queue into unocss:main with commit 0ba925e Jan 25, 2024
9 checks passed
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.

None yet

3 participants