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(tokens)!: Extract RGB color values into their own custom properties [CSS-383] #1590

Merged
merged 1 commit into from
Apr 3, 2023

Conversation

Rajdeepc
Copy link
Collaborator

@Rajdeepc Rajdeepc commented Jan 20, 2023

Description

To solve our problem of needing to decouple the rgb values from their opacities in order to utilize them in our CSS while also continuing to support the existing values, this PR adds a new postcss plugin called postcss-rgb-mapping.

This is a custom written plugin for this purpose but published separately: https://github.com/castastrophe/postcss-rgb-mapping

This plugin turns this:

.spectrum--lightest {
  --spectrum-seafoam-100: rgba(206, 247, 243);
  --spectrum-seafoam-200: rgba(170, 241, 234, 0.5);
}

Into this:

.spectrum--lightest {
  --spectrum-seafoam-100-rgb: 206, 247, 243;
  --spectrum-seafoam-100: rgba(var(--spectrum-seafoam-100-rgb));
  --spectrum-seafoam-200-rgb: 170, 241, 234;
  --spectrum-seafoam-200-opacity: 0.5;
  --spectrum-seafoam-200: rgba(var(--spectrum-seafoam-200-rgb), var(--spectrum-seafoam-200-opacity));
}

To maintain the existing codebase and add the rgb tokens, this parser separates out the rgb and opacity values and updates the old token to point to these new values. This approach maintains a single-source-of-truth while allowing for backwards compatibility.

To-do list

  • If my change impacts other components, I have tested to make sure they don't break.
  • If my change impacts documentation, I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • This pull request is ready to merge.

References

  • fastmod A possible option for shipping a tool to downstream users making it easier for them to make this update.

@Rajdeepc Rajdeepc added the bug Results from a bug in the CSS implementation label Jan 20, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2023

🚀 Deployed on https://pr-1590--spectrum-css.netlify.app

@github-actions github-actions bot temporarily deployed to pull request January 20, 2023 07:00 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 25, 2023 21:06 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 25, 2023 21:26 Inactive
@castastrophe
Copy link
Collaborator

@Rajdeepc @pfulton and @GarthDB, I've updated the excellent work Rajdeep did to match the solution you & I had discussed Garth. This version updates all rgb or rgba values to their raw formats (255, 255, 255 rather than rgb(255,255,255)) and shows how the CSS needs to be updated.

@castastrophe castastrophe force-pushed the bugfix/CSS-383 branch 6 times, most recently from 55d9aad to 6b653ae Compare January 26, 2023 14:59
@castastrophe castastrophe added breaking change Results in a breaking API change blocked See description and comments for what is blocking this issue labels Jan 26, 2023
@castastrophe castastrophe force-pushed the bugfix/CSS-383 branch 2 times, most recently from 553dc5b to 60a2fef Compare January 26, 2023 15:49
@github-actions github-actions bot temporarily deployed to pull request January 26, 2023 15:56 Inactive
@pfulton pfulton removed the blocked See description and comments for what is blocking this issue label Jan 30, 2023
@github-actions github-actions bot temporarily deployed to pull request February 14, 2023 14:38 Inactive
@castastrophe castastrophe force-pushed the bugfix/CSS-383 branch 2 times, most recently from a62f7d5 to 5666e3b Compare February 21, 2023 20:51
@github-actions github-actions bot temporarily deployed to pull request February 21, 2023 20:57 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 21, 2023 22:42 Inactive
@castastrophe castastrophe added the run_vrt For use on PRs looking to kick off VRT label Mar 31, 2023
@castastrophe castastrophe added run_vrt For use on PRs looking to kick off VRT and removed run_vrt For use on PRs looking to kick off VRT labels Mar 31, 2023
@github-actions github-actions bot temporarily deployed to pull request March 31, 2023 20:26 Inactive
Copy link
Collaborator

@pfulton pfulton left a comment

Choose a reason for hiding this comment

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

oh my goodness, let's ship it!

@github-actions github-actions bot temporarily deployed to pull request April 3, 2023 15:16 Inactive
@github-actions github-actions bot temporarily deployed to pull request April 3, 2023 15:29 Inactive
@github-actions github-actions bot temporarily deployed to pull request April 3, 2023 15:39 Inactive
@castastrophe castastrophe force-pushed the bugfix/CSS-383 branch 2 times, most recently from 2c73461 to fadf7bb Compare April 3, 2023 16:54
@github-actions github-actions bot temporarily deployed to pull request April 3, 2023 17:02 Inactive
@github-actions github-actions bot temporarily deployed to pull request April 3, 2023 17:20 Inactive
@github-actions github-actions bot temporarily deployed to pull request April 3, 2023 18:27 Inactive
@pfulton pfulton merged commit b714db4 into main Apr 3, 2023
@pfulton pfulton deleted the bugfix/CSS-383 branch April 3, 2023 19:21
castastrophe added a commit that referenced this pull request Apr 3, 2023
…es (#1590)

BREAKING CHANGE: transforms color tokens to split out their `rgb` values

Co-authored-by: castastrophe <[email protected]>
castastrophe added a commit that referenced this pull request Apr 3, 2023
…es (#1590)

BREAKING CHANGE: transforms color tokens to split out their `rgb` values

Co-authored-by: castastrophe <[email protected]>
castastrophe added a commit that referenced this pull request Apr 3, 2023
…es (#1590)

BREAKING CHANGE: transforms color tokens to split out their `rgb` values

Co-authored-by: castastrophe <[email protected]>
castastrophe added a commit that referenced this pull request Apr 3, 2023
…es (#1590)

BREAKING CHANGE: transforms color tokens to split out their `rgb` values

Co-authored-by: castastrophe <[email protected]>
castastrophe added a commit that referenced this pull request Apr 4, 2023
…es (#1590)

BREAKING CHANGE: transforms color tokens to split out their `rgb` values

Co-authored-by: castastrophe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Results in a breaking API change bug Results from a bug in the CSS implementation run_vrt For use on PRs looking to kick off VRT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants