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(core,presets)!: update presets to use the recursive callback #1127

Merged
merged 1 commit into from Jun 25, 2022

Conversation

chu121su12
Copy link
Collaborator

@chu121su12 chu121su12 commented Jun 21, 2022

Follow up to #1126, this PR update the existing variants to use the introduced variant handler().

Closes #1104

This PR adds 2 extra properties on the handler. Variants that use selector sectioning (the one that uses $$: dark, rtl/ltr and group pseudo) are now moved into prefix so it can be modified selectively.

/**
* Rewrite the output selector. Often be used to append parents.
*/
prefix: string
/**
* Rewrite the output selector. Often be used to append pesudo classes.
*/
selector: string
/**
* Rewrite the output selector. Often be used to append pesudo elements.
*/
pseudo: string

@netlify
Copy link

netlify bot commented Jun 21, 2022

Deploy Preview for unocss ready!

Name Link
🔨 Latest commit 366a67b
🔍 Latest deploy log https://app.netlify.com/sites/unocss/deploys/62b664c1605ce4000851077c
😎 Deploy Preview https://deploy-preview-1127--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 settings.

@chu121su12 chu121su12 changed the title feat(core,presets)!: update to use the recursive callback feat(core,presets)!: update presets to use the recursive callback Jun 21, 2022
@chu121su12 chu121su12 marked this pull request as ready for review June 21, 2022 00:30
@chu121su12 chu121su12 requested a review from antfu as a code owner June 21, 2022 00:30
@chu121su12 chu121su12 marked this pull request as draft June 21, 2022 08:16
@antfu
Copy link
Member

antfu commented Jun 21, 2022

I'd suggest we only rewrite those necessary.

@chu121su12 chu121su12 force-pushed the feat/use-recursive-variant branch 2 times, most recently from 7a17ed6 to e6582c7 Compare June 21, 2022 09:20
@chu121su12 chu121su12 marked this pull request as ready for review June 21, 2022 09:21
@antfu
Copy link
Member

antfu commented Jun 24, 2022

Can you help resolving the conflicts? Thanks

@antfu antfu merged commit e3dd0eb into main Jun 25, 2022
@antfu antfu deleted the feat/use-recursive-variant branch June 25, 2022 01:44
@sibbng
Copy link
Member

sibbng commented Jun 25, 2022

@chu121su12 Thanks for your work on this. I was watching the changes in this PR and other related PRs and I was not really expecting this to be merged while snapshots are like that. This PR now removes the whole purpose of #987. I see this PR comes with some features to take more control over output. Having more features is nice, but it still seems a little bit incomplete.

Why we shouldn't fix #1104

The issue in #1104 is the consequence of the breaking change in #987. The point of #987 is applying variants in the same order as Tailwind to make migration as easy as possible. I don't understand why we are trying to fix #1104. The changes in #987 are not just about group and dark variants. Let's take a look at the example at #1104

Input:

<div class="checked:next:bg-red-50">
<div class="next:checked:bg-red-50">

Unocss output after #987 and before this PR

.checked\:next\:bg-red-50 + *:checked
.next\:checked\:bg-red-50:checked + *

Tailwind output Same as the above. I added next variant manually in config.

.checked\:next\:bg-red-50 + *:checked
.next\:checked\:bg-red-50:checked + *

Unocss output after this PR

.checked\:next\:bg-red-50:checked + *
.next\:checked\:bg-red-50 + *:checked

Now two same inputs have different outputs and behaviours between Unocss and Tailwind. We should revert this PR and suggest people to reverse their variants order.

/cc @antfu

@chu121su12
Copy link
Collaborator Author

My case for #1104 is that unocss syntax should follow the order of declaration, as in checked:next or next:checked shoud be applied in order.

@sibbng To your point, this changes is done on preset-mini. If we really want to preserve compatibility with tailwind, I think we should add override in preset-wind instead.

@chu121su12
Copy link
Collaborator Author

chu121su12 commented Jun 25, 2022

I added next variant manually in config.

Also, as this is not in the tailwind's core, I think it is on the same level as providing separate variant definition in unocss config.

@antfu
Copy link
Member

antfu commented Jun 25, 2022

I see, let's better align with Tailwind in this case. I guess having inverse behavior for wind / mini would be quite confusing. Let's revert the order. @chu121su12

antfu added a commit that referenced this pull request Jun 25, 2022
antfu added a commit that referenced this pull request Jun 25, 2022
* fix(core)!: revert variant apply order in #1127

* fix(core,presets)!: update (revert) variants

Co-authored-by: Saya <chu121su12@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

checked:next:bg-red styles are generated wrongly
3 participants