-
Notifications
You must be signed in to change notification settings - Fork 3
Fiddle: change color calculations #234
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,41 +1,68 @@ | ||||||||||||||
| // ============================================================================= | ||||||||||||||
| // Color Functions | ||||||||||||||
| // ============================================================================= | ||||||||||||||
| // These functions provide consistent color manipulation across the library. | ||||||||||||||
| // Using sRGB for linear color mixing that produces predictable results. | ||||||||||||||
|
|
||||||||||||||
| @function lighten($color, $amount) { | ||||||||||||||
| @return color-mix(in srgb, #{$color}, white #{$amount}); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| @function darken($color, $amount) { | ||||||||||||||
| @return color-mix(in srgb, #{$color}, black #{$amount}); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| @function transparentize($color, $amount) { | ||||||||||||||
| @return color-mix(in srgb, #{$color}, transparent #{$amount}); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // ============================================================================= | ||||||||||||||
| // Color Variant Generator | ||||||||||||||
| // ============================================================================= | ||||||||||||||
| // This mixin generates light, dark, and transparency variants for any base color. | ||||||||||||||
| // Variants are computed dynamically using color-mix(), so they update automatically | ||||||||||||||
| // when the base color is overridden. | ||||||||||||||
| // lightXX = lighten color by XX% (mix XX% white) | ||||||||||||||
| // darkXX = darken color by XX% (mix XX% black) | ||||||||||||||
| // clearXX = make color XX% transparent | ||||||||||||||
|
Comment on lines
+23
to
+25
|
||||||||||||||
| // lightXX = lighten color by XX% (mix XX% white) | |
| // darkXX = darken color by XX% (mix XX% black) | |
| // clearXX = make color XX% transparent | |
| // lightXX = mix XX% white with (100-XX)% color (slightly lighter for small XX) | |
| // darkXX = mix XX% black with (100-XX)% color (slightly darker for small XX) | |
| // clearXX = mix XX% transparent with (100-XX)% color (slightly more transparent for small XX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
lightenfunction produces opposite results from the previous implementation.Previous behavior:
light10=color-mix(in srgb, var(--color) 10%, white)= 10% original + 90% white (very light)light50= 50% original + 50% whiteNew behavior:
light10=color-mix(in srgb, var(--color), white 10%)= 90% original + 10% white (slightly lighter)light50= 50% original + 50% whiteThe new implementation makes light variants much more subtle (only 10% lighter instead of 90% lighter for
light10). This is a breaking visual change that will affect all components using light color variants.The
darkenandtransparentizefunctions work correctly because their semantics were already inverted in the previous implementation.