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

Attributify: Missing utility generation for variant states with custom properties #4378

Closed
4 tasks done
onmax opened this issue Jan 12, 2025 · 3 comments
Closed
4 tasks done

Comments

@onmax
Copy link
Contributor

onmax commented Jan 12, 2025

UnoCSS version

65.4.0

Describe the bug

When using UnoCSS with Attributify mode, certain variant states containing custom properties do not generate the expected CSS. In this example:

<div class="hover:[--a:pink]" bg="hover:[--b:pink]">
  Hello World
</div>

the second hover rule (coming from bg="hover:[--b:pink]") is missing the generated class. Only the .hover\:\[--a\:pink\]:hover { --a: pink; } rule is produced.

I am also expecting something like (not sure if the CSS is correct, but I hope you get the idea):

[bg~="[--b\:pink\"]:hover{--b:pink;}

Reproduction

https://unocss.dev/play/#html=DwEwlgbgBAxgNgQwM5ILwCIAWB7CBTAJwC4BtAWjISIAcwA7AawF10oAjAcwx32PLLY16zdAD4AUAAk8cONigB1bATghxwAPTgIooA&config=JYWwDg9gTgLgBAbwFBzgEwKYDNgDsMDCEuOA5gDQpxhQYDOGMAgjDFMAEYCuMwWAnpVQ16jAKq4IlAL5wsUCCDgByLpIDGdOsqRIMAD0ix02AIZcANvEw58REsFIAKZMNoMYdAFxwA2lTdRGAkIJwBKIVRqd0YWNk4ePn5wyIBdGTCkIA&css=PQKgBA6gTglgLgUzAYwK4Gc4HsC2YDCAyoWABYJQIA0YAhgHYAmYcUD6AZllDhWOqgAOg7nAB0YAGLcwCAB60cggDYIAXGBDAAUKDBi0mXGADe2sGC704AWgDuCGAHNScDQFYADJ4Dc5sAACtMLKAJ5gggCMLPK2ABR2pPBIcsoAlH4WAEa0yADWTlBYqEw2yFjK3Bpw5LxxAOTllVDoYpSMYgAs3vUZ2gC%2BmsBAA&options=N4IgLgTghgdgzgMwPYQLYAkyoDYgFwJTZwCmAvkA&version=65.4.0

System Info

WSL ubuntu
node 22.6.0
Vue 3

Validations

@onmax
Copy link
Contributor Author

onmax commented Jan 12, 2025

The workaround for this bug is just to use class="hover:bg-[--a:pink]" which I guess is ok, since this is a very specific scenario.

Feel free to close this issue, if the solution is over-engineer :)

@zyyv
Copy link
Member

zyyv commented Jan 13, 2025

In you case bg="hover:[--b:pink]", UnoCSS will parse bg-hover:[--b:pink] or hover:bg-[--a:pink], i think both them are error usage, don't use bg- and custom properties rule at the same time.

@zyyv zyyv closed this as not planned Won't fix, can't repro, duplicate, stale Jan 13, 2025
@onmax
Copy link
Contributor Author

onmax commented Jan 13, 2025

Yeah, sorry. Thinking thoughtfully it doesn't make sense to do what I just did. Sorry about that and thank you!

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

No branches or pull requests

2 participants