Skip to content

Commit f3893d1

Browse files
authored
Set color opacity variable when colors are defined as functions (#2515)
* Always set color opacity variable, even if color cannot be parsed * Only set color opacity when it might be used
1 parent 2f9e669 commit f3893d1

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

__tests__/plugins/gradientColorStops.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ test('opacity variables are given to colors defined as closures', () => {
3434
.then(result => {
3535
const expected = `
3636
.text-primary {
37+
--text-opacity: 1;
3738
color: rgba(31,31,31,var(--text-opacity,1))
3839
}
3940
.text-opacity-50 {

__tests__/withAlphaVariable.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ test('it allows a closure to be passed', () => {
104104
variable: '--bg-opacity',
105105
})
106106
).toEqual({
107+
'--bg-opacity': '1',
107108
'background-color': 'rgba(0, 0, 0, var(--bg-opacity))',
108109
})
109110
})

src/util/withAlphaVariable.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export function toRgba(color) {
2121
export default function withAlphaVariable({ color, property, variable }) {
2222
if (_.isFunction(color)) {
2323
return {
24+
[variable]: '1',
2425
[property]: color({ opacityVariable: variable }),
2526
}
2627
}

0 commit comments

Comments
 (0)