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

UnoCss does not generate pseudo rule #2371

Closed
4 tasks done
ThinhVu opened this issue Mar 19, 2023 · 7 comments
Closed
4 tasks done

UnoCss does not generate pseudo rule #2371

ThinhVu opened this issue Mar 19, 2023 · 7 comments
Labels

Comments

@ThinhVu
Copy link

ThinhVu commented Mar 19, 2023

UnoCSS version

0.50.6

Describe the bug

UnoCss failed to resolve rules. For example:

Rules:

[ 'hide-scroll-bar', {
     '-ms-overflow-style': 'none', /* IE and Edge */ 
     'scrollbar-width': 'none'  /* Firefox */
}],
['hide-scroll-bar::-webkit-scrollbar', {display: 'none'}], /* Chrome, Safari and Opera */

Expected output:
.hide-scroll-bar and .hide-scroll-bar::-webkit-scrollbar should be created.

Actual:
Only .hide-scroll-bar was created.

Reproduction

hide-scroll-bar.mp4

System Info

No response

Validations

@zyyv
Copy link
Member

zyyv commented Mar 19, 2023

We temporarily close this due to the lack of enough information.
Please provide a minimal reproduction to reopen the issue.
Thanks.

Why reproduction is required

@zyyv zyyv closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2023
@sibbng
Copy link
Member

sibbng commented Mar 19, 2023

This is not how rules option work. I was wondering how we could generate multiple CSS rules in a single rule definition. In Tailwind addUtilities and addVariant make this super easy.

I got it working in this Playground. But it's super weird and verbose.

/cc @chu121su12 @antfu

@sibbng sibbng reopened this Mar 19, 2023
@antfu
Copy link
Member

antfu commented Mar 19, 2023

You can return an array to provide multiple rules: Playground

For pesudo selector it's indeed a bit tricky but for UnoCSS take more static approach for performance. No plan to have runtime utils like addUtilities or addVariant that alter the generator's behavior.

@sibbng
Copy link
Member

sibbng commented Mar 20, 2023

This is cool, but it has some issues: Playground

  1. It won't work as expected when we use variants.
<div class="hover:hide-scroll-bar"></div>
  1. It won't be processed by postprocess hook (rem to px etc).

In my first Playground these are not an issue.

No plan to have runtime utils like addUtilities or addVariant that alter the generator's behavior.

I don't propose having these utilities on UnoCSS core, but if we can come up with a more structured format for this uses cases we can provide a high level utility in preset-mini for end-users, similar to variantMatcher.

@chu121su12
Copy link
Collaborator

Depending on the pseudo usage afterwards, for multiple matching, one workaround I could think is by using shortcut

@sibbng
Copy link
Member

sibbng commented Mar 20, 2023

@chu121su12 Good one, but hover variant placed on wrong side in your workaround. This is a regression caused by #2190. Maybe we should bring back movePseudoElementsEnd or find an alternative solution for this case.

@stale
Copy link

stale bot commented May 19, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 19, 2023
@ThinhVu ThinhVu closed this as completed May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants