Skip to content

Commit d9ff3da

Browse files
committed
Properly handle contrast for all properties
1 parent c4f9b60 commit d9ff3da

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.changeset/little-hats-sleep.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@compai/css-gui': patch
3+
---
4+
5+
Properly handle contrast for all properties

packages/gui/src/lib/color.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,19 @@ const getColorToContrastWith = (
2323
ruleset: Record<string, any>,
2424
theme?: any
2525
) => {
26-
const valueOrPath = ruleset[CONTRAST_PROPERTY_MAP[property]]
26+
const contrastProperty = CONTRAST_PROPERTY_MAP[property]
27+
if (!contrastProperty) {
28+
return null
29+
}
30+
31+
const valueOrPath = ruleset[contrastProperty]
32+
if (!valueOrPath) {
33+
return null
34+
}
35+
2736
return themeGet({
2837
theme,
29-
path: valueOrPath.path || valueOrPath,
38+
path: valueOrPath?.path || valueOrPath,
3039
property: 'color',
3140
})
3241
}

0 commit comments

Comments
 (0)