From 1228c30ab5a7368bc0f97b68cdc276399592dbd5 Mon Sep 17 00:00:00 2001 From: Simeon Simeonoff Date: Mon, 11 Nov 2024 16:42:38 +0200 Subject: [PATCH] fix(color): contrast-color with palette not returning a value of type color (#356) Closes #354 --- sass/color/_functions.scss | 4 ++-- test/_color.spec.scss | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sass/color/_functions.scss b/sass/color/_functions.scss index 7ad77b91..a1c69b09 100644 --- a/sass/color/_functions.scss +++ b/sass/color/_functions.scss @@ -192,10 +192,10 @@ $_enhanced-accessibility: false; $_hsl-alpha: hsl(from $s h s l / $_alpha); $_mix-alpha: color-mix(in oklch, $s #{$_alpha * 100%}, transparent); - @if $palette and not($contrast) { + @if $palette { $s: map.get($palette, $color); $base: map.get($s, $variant); - $raw: map.get($s, #{$variant}-raw); + $raw: if($contrast, map.get($s, #{$variant}-contrast), map.get($s, #{$variant}-raw)); @return if($raw and $variant != 500, rgba($raw, $_alpha), rgba($base, $_alpha)); } diff --git a/test/_color.spec.scss b/test/_color.spec.scss index 054ac626..67875fe8 100644 --- a/test/_color.spec.scss +++ b/test/_color.spec.scss @@ -142,10 +142,11 @@ $_palette: palette( @include assert-equal($value, hsl(from (var(--ig-secondary-A400)) h s l / 1)); } - @include it('should return a contrast shade of type string w/ palette as only argument') { + @include it('should return a contrast shade of type color w/ palette as only argument') { $value: contrast-color($_palette, $opacity: .5); - $expected: color-mix(in oklch, var(--ig-primary-500-contrast) 50%, transparent); + $expected: rgba(0 0 0 / .5); + @include assert-equal(type-of($value), color); @include assert-equal($expected, $value); }