Skip to content

fix(color)!: keep hsla and rgba consistent with tailwindcss#3221

Merged
antfu merged 7 commits intounocss:mainfrom
Simon-He95:hsl
Oct 23, 2023
Merged

fix(color)!: keep hsla and rgba consistent with tailwindcss#3221
antfu merged 7 commits intounocss:mainfrom
Simon-He95:hsl

Conversation

@Simon-He95
Copy link
Member

@Simon-He95 Simon-He95 commented Oct 11, 2023

@Simon-He95 Simon-He95 requested a review from antfu as a code owner October 11, 2023 12:26
@netlify
Copy link

netlify bot commented Oct 11, 2023

Deploy Preview for unocss ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f1bb5e2
🔍 Latest deploy log https://app.netlify.com/sites/unocss/deploys/6533d0923af9100008c6e295
😎 Deploy Preview https://deploy-preview-3221--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.

@chu121su12
Copy link
Member

Theres more to update. Please see https://github.com/chu121su12/unocss/tree/space-color-syntax

@antfu antfu changed the title chore(color): keep hsla and rgba consistent with tailwindcss fix(color): keep hsla and rgba consistent with tailwindcss Oct 11, 2023
@Simon-He95
Copy link
Member Author

if (['hsla', 'hsl', 'rgba', 'rgb'].includes(type))
return `${type.replace('a', '')}a(${components.join(',')}${alpha == null ? '' : `,${alpha}`})`
if (['hsla', 'rgba'].includes(type))
return `${type}(${components.join(' ')}${alpha == null ? '' : ` / ${alpha}`})`
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we clearly agreed that we are going to align with Tailwind, I think this should use COMMA-SEPARATED syntax instead of SPACE-SEPARATED syntax.

Tailwind uses SPACE for rgb and hsl, but COMMA for rgba and hsla.

I can see that through out the MR we are changing everything to SPACE syntax, as well as rgba and hsla. This will work in the browser but that's not aligned with Tailwind.

Copy link
Contributor

Choose a reason for hiding this comment

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

This will break for those who uses COMMA syntax with rgba and hsla (It makes sense to use legacy color function with legacy syntax? 🤣)

Copy link
Member Author

Choose a reason for hiding this comment

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

I misunderstood it at first. I used tailwind play to check the output results and made adjustments.

@antfu antfu changed the title fix(color): keep hsla and rgba consistent with tailwindcss fix(color)!: keep hsla and rgba consistent with tailwindcss Oct 23, 2023
@antfu antfu merged commit 5c3d02d into unocss:main Oct 23, 2023
@Simon-He95 Simon-He95 deleted the hsl branch October 23, 2023 02:36
justmoon added a commit to justmoon/dassie that referenced this pull request Nov 7, 2023
UnoCSS used to differ from Tailwind which required us to have a different format for our color variables. This is no longer the case, so we can use the regular Tailwind color variables.

See: unocss/unocss#3221
@shellscape
Copy link

@antfu @Simon-He95 Gmail explicitly doesn't support space separated color function values, so when using uno tomgenerate cas for HTML used in email, we get undesirable rendering. What's the solution (if any) tomrevert to comma separated?

timozander added a commit to timozander/unocss that referenced this pull request Dec 31, 2023
@antfu antfu mentioned this pull request Jan 1, 2024
2 tasks
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.

[🐞color]: hsl and rgb is opinionated to the legacy comma-separated syntax

5 participants