Skip to content

Commit

Permalink
fix(a11y): colors don't always have an int color channel
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Dec 13, 2024
1 parent 5d03556 commit 0116178
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/core/src/theme/_a11y.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,20 @@ $_linear-channel-values: (
// @param {Color} color - The color to check
// @returns {number} A number representing the luminance for the color.
@function _luminance($color) {
$red: list.nth($_linear-channel-values, color.channel($color, "red") + 1);
$red: list.nth(
$_linear-channel-values,
math.round(color.channel($color, "red")) + 1
);
$red-multiplier: 0.2126;
$green: list.nth($_linear-channel-values, color.channel($color, "green") + 1);
$green: list.nth(
$_linear-channel-values,
math.round(color.channel($color, "green")) + 1
);
$green-multiplier: 0.7152;
$blue: list.nth($_linear-channel-values, color.channel($color, "blue") + 1);
$blue: list.nth(
$_linear-channel-values,
math.round(color.channel($color, "blue")) + 1
);
$blue-multiplier: 0.0722;

@return ($red * $red-multiplier) + ($green * $green-multiplier) +
Expand Down

0 comments on commit 0116178

Please sign in to comment.