Skip to content

Commit f6fc963

Browse files
committed
test(gradientColorStops): ensure opacity variables are generated
1 parent 486772a commit f6fc963

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import postcss from 'postcss'
2+
import tailwind from '../../src/index'
3+
4+
test('opacity variables are given to colors defined as closures', () => {
5+
return postcss([
6+
tailwind({
7+
theme: {
8+
colors: {
9+
primary: ({ opacityVariable }) => `rgba(31,31,31,var(${opacityVariable},1))`,
10+
},
11+
},
12+
variants: {
13+
gradientColorStops: [],
14+
},
15+
corePlugins: ['gradientColorStops'],
16+
}),
17+
])
18+
.process('@tailwind utilities', { from: undefined })
19+
.then(result => {
20+
const expected = `
21+
.from-primary {
22+
--gradient-from-color: rgba(31,31,31,var(--gradient-from-opacity,1));
23+
--gradient-color-stops: var(--gradient-from-color), var(--gradient-to-color, rgba(255, 255, 255, 0))
24+
}
25+
26+
.via-primary {
27+
--gradient-via-color: rgba(31,31,31,var(--gradient-via-opacity,1));
28+
--gradient-color-stops: var(--gradient-from-color), var(--gradient-via-color), var(--gradient-to-color, rgba(255, 255, 255, 0))
29+
}
30+
31+
.to-primary {
32+
--gradient-to-color: rgba(31,31,31,var(--gradient-to-opacity,1))
33+
}
34+
`
35+
36+
expect(result.css).toMatchCss(expected)
37+
})
38+
})

0 commit comments

Comments
 (0)