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

Gradient end color becomes transparent #2522

Closed
4 tasks done
shamokit opened this issue Apr 20, 2023 · 4 comments · Fixed by #2526
Closed
4 tasks done

Gradient end color becomes transparent #2522

shamokit opened this issue Apr 20, 2023 · 4 comments · Fixed by #2526

Comments

@shamokit
Copy link

UnoCSS version

0.51.5

Describe the bug

When using a gradient class for the class attribute, the color at the end of the gradient becomes transparent.

Since the second argument of colorToString in the bgGradientToValue function is 0, to-{toColor} of bg-gradient-to-r from-{startColor} via-{viaColor} to-{toColor} will be displayed transparently.

Reproduction

NG(with class attributes)

https://uno.antfu.me/play/?html=DwEwlgbgBAFgtAMwK4BsVQC4FMAeG4DGWAdtgE5QIq5QDOW1B%2BxA9sVlAIZoBcGZnYrTAYwbOABYADFIB8AKChRQkKAFtOCpUpXQqNAFZJaohAE9CJclu07w0AO5wATFNgu3AIwDmcbwPArOAwWOAoEMhY1OFoAawsIqKgIME4Y%2BLgUzkxQuIsQ2WAAensbW10oAhROWloAXgAiJ1d3Fp8-ALAgkLDKSOi8xH7k1PSLLJyx4JYGwpLIMuV5iBti0vk1haA&config=JYWwDg9gTgLgBAbwFBzgEwKYDNgDsMDCEuOA5gDQpxhQYDOGMAgjDFMAEYCuMwWAnpVQ16jAJIBjYnSHVaDGAFVcESgF84WKBBBwA5FxUS6dPUiQYAHpFjpsAQy4AbeJhz4iJYKQAUyVHQAFtAwEjx0AFyIVKh6YXQwOgC0QSFhMHpRejBWMElOpHA5lnnQ9rikGHDBAG4YUBHFeTn2TmaoarIiCpFwANoxcqJKKj4AlLLC8owsbJw8fPzjsgC6sjCBGCAYUf6ocFJO0L3IAJDnp3QA1vy7SBfnWjpZAMQALBj2EhIYepQPpxqwHsrwA7FgOABmNAADj%2B9weiVeHBRoLQACYzA9OoM1FQ8WoxkggA&css=Q&options=N4IgLgTghgdgzgMwPYQLYgFwKgGzgUwF8g

OK(no class attributes)

https://uno.antfu.me/play/?html=DwEwlgbgBAFgtAMwK4BsVQC4FMAeG4DGWAdtgE5QIq5QDOW1B%2BxA9sVlAIZoBcGZnYrTAYwbOABYADFIB8AKChRQkKAFtOCpUpXQqNAFZJaohAE9CJclu07w0AO5wATFNgu3AIwDmcbwPArOAwWOAoEMhY1OFoAawsIqKgIME4Y%2BLgUzkxQuIsQ2WAAensbW10oJ1d3ap8-ALAgkLDKSOi8xDbk1PSLLJze4JZCksgy5VGIG2LS%2BRmxoA&config=JYWwDg9gTgLgBAbwFBzgEwKYDNgDsMDCEuOA5gDQpxhQYDOGMAgjDFMAEYCuMwWAnpVQ16jAJIBjYnSHVaDGAFVcESgF84WKBBBwA5FxUS6dPUiQYAHpFjpsAQy4AbeJhz4iJYKQAUyVHQAFtAwEjx0AFyIVKh6YXQwOgC0QSFhMHpRejBWMElOpHA5lnnQ9rikGHDBAG4YUBHFeTn2TmaoarIiCpFwANoxcqJKKj4AlLLC8owsbJw8fPzjsgC6sjCBGCAYUf6ocFJO0L3IAJDnp3QA1vy7SBfnWjpZAMQALBj2EhIYepQPpxqwHsrwA7FgOABmNAADj%2B9weiVeHBRoLQACYzA9OoM1FQ8WoxkggA&css=Q&options=N4IgLgTghgdgzgMwPYQLYgFwKgGzgUwF8g

System Info

  • macOS 13.3.1(22E261)
  • Google Chrome 112.0.5615.121

Validations

@antfu
Copy link
Member

antfu commented Apr 20, 2023

Would you mind sending a PR to fix it? Thanks!

@sibbng
Copy link
Member

sibbng commented Apr 20, 2023

@antfu The source of the problem is these two lines:

|| a[1]?.localeCompare(b[1] || '') // selector
|| a[2]?.localeCompare(b[2] || '') // body

They ruin a lot of things already. I'm going to nuke all localeCompares in #1973, but it's not ready yet and needs more testing.

As a quick fix, we can separate the following rule into 3 rules to fix this issue.

[/^(?:bg-gradient-)?(from|via|to)-(.+)$/, bgGradientColorResolver()],

/cc @chu121su12 I wanted to mention you in this conversation since most of these lines are written by you. Maybe you could come up with a better solution.

@antfu
Copy link
Member

antfu commented Apr 20, 2023

Yeah I think we should separate the rules of the order matters to them.

@shamokit
Copy link
Author

This is my first time making a pull request, so I apologize if there are any mistakes.

Please check.
#2525

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 a pull request may close this issue.

3 participants