Skip to content

Commit 0aaf967

Browse files
committed
Call alpha instead of opacity because colors default to black for invalid color strings
1 parent 86e48f8 commit 0aaf967

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/components/color/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,15 @@ const contrast = (cstr, lightAmount, darkAmount) => {
9696
return newColor.rgb().string();
9797
};
9898

99-
const stroke = (s, cstr) => s.style({ stroke: rgb(cstr), 'stroke-opacity': opacity(cstr) });
99+
const stroke = (s, cstr) => {
100+
const c = color(cstr);
101+
s.style({ stroke: rgb(cstr), 'stroke-opacity': c.alpha() });
102+
};
100103

101-
const fill = (s, cstr) => s.style({ fill: rgb(cstr), 'fill-opacity': opacity(cstr) });
104+
const fill = (s, cstr) => {
105+
const c = color(cstr);
106+
s.style({ fill: rgb(cstr), 'fill-opacity': c.alpha() });
107+
};
102108

103109
// search container for colors with the deprecated rgb(fractions) format
104110
// and convert them to rgb(0-255 values)

0 commit comments

Comments
 (0)