Skip to content

Fiddle: change color calculations#234

Merged
krishan711 merged 1 commit into
mainfrom
fixcol
Dec 5, 2025
Merged

Fiddle: change color calculations#234
krishan711 merged 1 commit into
mainfrom
fixcol

Conversation

@krishan711
Copy link
Copy Markdown
Contributor

Description

Screenshots:

Checklist:

  • I have updated the CHANGELOG with a summary of my changes
  • I have updated the documentation accordingly

Copilot AI review requested due to automatic review settings December 5, 2025 09:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the SCSS color manipulation system by introducing three new helper functions (lighten, darken, transparentize) and expanding the color variant palette with additional shades (75%, 80%, 90%, 95%, 99%).

Key changes:

  • Introduces three new SCSS functions to encapsulate color-mix logic
  • Adds additional color variants at 75%, 80%, 90%, 95%, and 99% levels for all light, dark, and clear variations
  • Updates backwards compatibility aliases to include new variants

Comment thread src/styles/_mixins.scss
// Using sRGB for linear color mixing that produces predictable results.

@function lighten($color, $amount) {
@return color-mix(in srgb, #{$color}, white #{$amount});
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The lighten function 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% white

New behavior:

  • light10 = color-mix(in srgb, var(--color), white 10%) = 90% original + 10% white (slightly lighter)
  • light50 = 50% original + 50% white

The 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 darken and transparentize functions work correctly because their semantics were already inverted in the previous implementation.

Suggested change
@return color-mix(in srgb, #{$color}, white #{$amount});
@return color-mix(in srgb, #{$color} #{$amount}, white);

Copilot uses AI. Check for mistakes.
Comment thread src/styles/_mixins.scss
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
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The comment description is now incorrect for light variants.

The comment states lightXX = lighten color by XX% (mix XX% white), which implies mixing XX% white with (100-XX)% of the original color.

However, due to the bug in the lighten() function, the actual result is:

  • light10 produces 90% original + 10% white (only slightly lighter)
  • light50 produces 50% original + 50% white (moderately lighter)

The previous implementation had:

  • light10 = 10% original + 90% white (very light)
  • light50 = 50% original + 50% white (moderately lighter)

The comments should accurately describe what the code does, or the code should be fixed to match the comments.

Suggested change
// 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)

Copilot uses AI. Check for mistakes.
@krishan711 krishan711 merged commit 8b1de3b into main Dec 5, 2025
10 checks passed
@krishan711 krishan711 deleted the fixcol branch December 5, 2025 09:58
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.

2 participants