Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
jgerigmeyer committed Mar 3, 2025
1 parent 0ed2b45 commit 4337ce3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/lib/components/ratio/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
import { RATIOS } from '$lib/constants';
import { bg, fg } from '$lib/stores';
let fgPremultiplied = $derived.by(() => {
if ($fg.alpha === 1 || $bg.alpha !== 1) return null;
return mix($bg, $fg, $fg.alpha, {
space: 'srgb',
premultiplied: false,
});
let ratio = $derived.by(() => {
let fgPremultiplied = $fg;
if ($fg.alpha !== 1 && $bg.alpha === 1) {
fgPremultiplied = mix($bg, $fg, $fg.alpha, {
space: 'srgb',
premultiplied: false,
});
}
return contrast($bg, fgPremultiplied, 'WCAG21');
});
let ratio = $derived(contrast($bg, fgPremultiplied ?? $fg, 'WCAG21'));
let displayRatio = $derived(Math.round((ratio + Number.EPSILON) * 100) / 100);
let pass = $derived(ratio >= RATIOS.AA.Normal);
let alphaWarning = $derived.by(() => {
Expand Down

0 comments on commit 4337ce3

Please sign in to comment.