-
Notifications
You must be signed in to change notification settings - Fork 418
feat(clerk-js): Update color logic utils to support CSS variable usage #6187
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
Merged
alexcarpenter
merged 98 commits into
main
from
alexcarpenter/user-2201-add-color-mix-utilities
Jul 8, 2025
Merged
Changes from 97 commits
Commits
Show all changes
98 commits
Select commit
Hold shift + click to select a range
652cfe6
refactor(clerk-js): Update color logic utils
alexcarpenter 8198e12
checkpoint
alexcarpenter 283f322
refactor color utilities
alexcarpenter 33a32dd
remove eslint-disable usage
alexcarpenter 7cb8d8a
Enhance sandbox styles and color utilities
alexcarpenter 5898f2b
Update colorOptionToHslaScale.ts
alexcarpenter 7db3449
creat unified colors interface to manage modern and legacy support
alexcarpenter 719ee2a
reorganize colors folder
alexcarpenter c1a3174
extract constants and cache
alexcarpenter df764fc
add tests
alexcarpenter 87419bd
Delete performance.ts
alexcarpenter 6f1d280
Update app.ts
alexcarpenter 18f15aa
revert sandbox changes
alexcarpenter b7dcccc
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter 8ea0357
add temp changelog
alexcarpenter 3d22bb9
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter 417d0e5
fix missing import
alexcarpenter ca6e8e4
refactor: use unknown vs any
alexcarpenter cf99453
refactor prefixAndStringifyScale types
alexcarpenter 8d60397
Update packages/clerk-js/src/ui/utils/colors/README.md
alexcarpenter f56fbd4
remove features list
alexcarpenter ccba2f5
Merge branch 'alexcarpenter/user-2201-add-color-mix-utilities' of git…
alexcarpenter 96a1456
remove perf benefits
alexcarpenter 5273a82
🔪 README
alexcarpenter da7235b
remove getCacheStats
alexcarpenter 9834559
remove duplicate file
alexcarpenter abd06ce
remove relative color support for makeTransparent as color-mix handle…
alexcarpenter 41299da
update description
alexcarpenter 0c7e07b
improve description
alexcarpenter 6e7c566
remove comment
alexcarpenter 107c583
cleanup
alexcarpenter 5fcf1ee
remove export
alexcarpenter facce98
make consistent
alexcarpenter e51268c
refactor toHSLA and toTransparent usage
alexcarpenter 8d581a9
remove
alexcarpenter a3ef27b
bring back getCacheStats
alexcarpenter 488f2b9
refactor cache and hasModernColorSupport
alexcarpenter 3189c48
use hasModernColorSupport
alexcarpenter 91a9800
use constants
alexcarpenter b31b45b
handle feedback
alexcarpenter 9b86c9e
refactor
alexcarpenter 1ae5c97
add legacy tests
alexcarpenter f200029
rename and consolidate scale generation
alexcarpenter 065445c
feedback
alexcarpenter 79ccc92
rename
alexcarpenter d21c353
extract color generation functions
alexcarpenter 441a41c
remove memoization
alexcarpenter 2a0bdd2
rename and add js doc comments
alexcarpenter 0ab897c
reduce lookups
alexcarpenter 0a6be7f
reduce lookups
alexcarpenter 7522f71
revert
alexcarpenter ad7bf32
fix adjustForLightness usage
alexcarpenter d081f27
add resolveCssVariable funtionality
alexcarpenter 20900a1
fix legacy scale generation
alexcarpenter 50eb9a1
feedback
alexcarpenter 4c1dcce
remove css var from error
alexcarpenter 1a735d2
add docs
alexcarpenter 59f007e
revert
alexcarpenter d2f01e8
refactor to support composite feature checks
alexcarpenter fe8b6de
fix spec
alexcarpenter cde9e6b
Update bundlewatch.config.json
alexcarpenter 88414a2
Update bundlewatch.config.json
alexcarpenter 8a667ad
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter aff50d2
Update packages/clerk-js/src/ui/utils/colors/README.md
alexcarpenter 9feee93
Update packages/clerk-js/src/ui/utils/colors/README.md
alexcarpenter 7faf80a
Update packages/clerk-js/src/ui/utils/colors/index.ts
alexcarpenter 709a9f7
Update packages/clerk-js/src/ui/utils/colors/modern.ts
alexcarpenter 7741bec
Update packages/clerk-js/src/ui/utils/colors/modern.ts
alexcarpenter c1af115
Update packages/clerk-js/src/ui/utils/colors/index.ts
alexcarpenter 7081c7b
handle feedback
alexcarpenter 619f2ff
fix css supports usage
alexcarpenter 97e6456
fix adjustForLightness usage
alexcarpenter ecee31a
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter 6fad410
extract CSS variable utilities
alexcarpenter e6cc63c
fix colorTextSecondary color
alexcarpenter 9ab7299
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter 5598627
refactor(clerk-js): Introduce `resolveComputedCSSProperty` to pass al…
alexcarpenter c7b82a4
feat(clerk-js): Remove CSS variables when modern color isn't supporte…
dstaley 66c5d1f
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter 1f7e79e
Update bundlewatch.config.json
alexcarpenter c2c7bf1
Update chubby-parts-try.md
alexcarpenter be92ca6
Update bundlewatch.config.json
alexcarpenter d41acfe
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter 3d73abd
handle negative margins
alexcarpenter c41b4e5
bring back 500 shade error
alexcarpenter 6fcf437
add test case
alexcarpenter 120ba37
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter b697754
Update bundlewatch.config.json
alexcarpenter 0138f04
Merge branch 'alexcarpenter/user-2201-add-color-mix-utilities' of git…
alexcarpenter 79c05ca
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter 82bd682
resolve stripe appearance
alexcarpenter f691fe5
fix stripe appearance
alexcarpenter b5484a5
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter ef6acaf
negative margin
alexcarpenter e15a0ab
Update bundlewatch.config.json
alexcarpenter 11e7dff
fix scales test
alexcarpenter 315070d
Update bundlewatch.config.json
alexcarpenter a84db2d
Update chubby-parts-try.md
alexcarpenter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@clerk/clerk-js': minor | ||
| --- | ||
|
|
||
| Add modern CSS color manipulation utilities with progressive enhancement support. This update introduces: | ||
|
|
||
| - CSS variable support in `appearance.variables` object (e.g., `colorPrimary: 'var(--brand-color)'`) | ||
| - Modern CSS features like `color-mix()` and relative color syntax when supported by browser | ||
| - Automatic fallback to legacy HSLA-based color manipulation for older browsers | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/clerk-js/src/ui/customizables/__tests__/parseVariables.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| // Mock cssSupports | ||
| vi.mock('../../utils/cssSupports', () => ({ | ||
| cssSupports: { | ||
| modernColor: vi.fn(), | ||
| }, | ||
| })); | ||
|
|
||
| import { cssSupports } from '@/ui/utils/cssSupports'; | ||
|
|
||
| import { removeInvalidValues } from '../parseVariables'; | ||
|
|
||
| const mockModernColorSupport = vi.mocked(cssSupports.modernColor); | ||
|
|
||
| describe('removeInvalidValues', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| mockModernColorSupport.mockReturnValue(false); | ||
| }); | ||
|
|
||
| it('should return the variables as-is if modern color support is present', () => { | ||
| mockModernColorSupport.mockReturnValue(true); | ||
| const variables = { | ||
| colorPrimary: 'var(--color-primary)', | ||
| }; | ||
|
|
||
| const result = removeInvalidValues(variables); | ||
| expect(result).toEqual({ colorPrimary: 'var(--color-primary)' }); | ||
| }); | ||
|
|
||
| it('should remove invalid string values if modern color support is not present', () => { | ||
| mockModernColorSupport.mockReturnValue(false); | ||
| const variables = { | ||
| colorPrimary: 'var(--color-primary)', | ||
| colorDanger: '#ff0000', | ||
| }; | ||
|
|
||
| const result = removeInvalidValues(variables); | ||
| expect(result).toEqual({ colorDanger: '#ff0000' }); | ||
| }); | ||
|
|
||
| it('should remove invalid object values if modern color support is not present', () => { | ||
| mockModernColorSupport.mockReturnValue(false); | ||
| const variables = { | ||
| colorPrimary: { | ||
| 400: 'var(--color-primary-500)', | ||
| 500: '#fff', | ||
| }, | ||
| colorDanger: { | ||
| 500: '#ff0000', | ||
| }, | ||
| }; | ||
|
|
||
| const result = removeInvalidValues(variables); | ||
| expect(result).toEqual({ colorDanger: { 500: '#ff0000' } }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.