Skip to content

Commit 486772a

Browse files
committed
fix(gradientColorStops): correctly handle color closures
1 parent 0206d06 commit 486772a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/plugins/gradientColorStops.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ export default function() {
1212

1313
const utilities = _(colors)
1414
.map((value, modifier) => {
15+
const getColorValue = (color, type) => {
16+
if (_.isFunction(color)) {
17+
return value({
18+
opacityVariable: `--gradient-${type}-opacity`,
19+
})
20+
}
21+
22+
return color
23+
}
24+
1525
const transparentTo = (() => {
1626
try {
1727
const [r, g, b] = toRgba(value)
@@ -25,21 +35,21 @@ export default function() {
2535
[
2636
`.${e(`from-${modifier}`)}`,
2737
{
28-
'--gradient-from-color': value,
38+
'--gradient-from-color': getColorValue(value, 'from'),
2939
'--gradient-color-stops': `var(--gradient-from-color), var(--gradient-to-color, ${transparentTo})`,
3040
},
3141
],
3242
[
3343
`.${e(`via-${modifier}`)}`,
3444
{
35-
'--gradient-via-color': value,
45+
'--gradient-via-color': getColorValue(value, 'via'),
3646
'--gradient-color-stops': `var(--gradient-from-color), var(--gradient-via-color), var(--gradient-to-color, ${transparentTo})`,
3747
},
3848
],
3949
[
4050
`.${e(`to-${modifier}`)}`,
4151
{
42-
'--gradient-to-color': value,
52+
'--gradient-to-color': getColorValue(value, 'to'),
4353
},
4454
],
4555
]

0 commit comments

Comments
 (0)