-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathgradientColorStops.test.js
82 lines (70 loc) · 2.1 KB
/
gradientColorStops.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import postcss from 'postcss'
import tailwind from '../../src/index'
test('opacity variables are given to colors defined as closures', () => {
return postcss([
tailwind({
theme: {
colors: {
primary: ({ opacityVariable, opacityValue }) => {
if (opacityValue !== undefined) {
return `rgba(31,31,31,${opacityValue})`
}
if (opacityVariable !== undefined) {
return `rgba(31,31,31,var(${opacityVariable},1))`
}
return `rgb(31,31,31)`
},
secondary: 'hsl(10, 50%, 50%)',
},
opacity: {
50: '0.5',
},
},
variants: {
textColor: [],
textOpacity: [],
gradientColorStops: [],
},
corePlugins: ['textColor', 'textOpacity', 'gradientColorStops'],
}),
])
.process('@tailwind utilities', { from: undefined })
.then((result) => {
const expected = `
.from-primary {
--tw-gradient-from: rgb(31, 31, 31);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(31, 31, 31, 0));
}
.from-secondary {
--tw-gradient-from: hsl(10, 50%, 50%);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, hsla(10, 50%, 50%, 0));
}
.via-primary {
--tw-gradient-stops: var(--tw-gradient-from), rgb(31, 31, 31),
var(--tw-gradient-to, rgba(31, 31, 31, 0));
}
.via-secondary {
--tw-gradient-stops: var(--tw-gradient-from), hsl(10, 50%, 50%),
var(--tw-gradient-to, hsla(10, 50%, 50%, 0));
}
.to-primary {
--tw-gradient-to: rgb(31, 31, 31);
}
.to-secondary {
--tw-gradient-to: hsl(10, 50%, 50%);
}
.text-primary {
--tw-text-opacity: 1;
color: rgba(31, 31, 31, var(--tw-text-opacity));
}
.text-secondary {
--tw-text-opacity: 1;
color: hsla(10, 50%, 50%, var(--tw-text-opacity));
}
.text-opacity-50 {
--tw-text-opacity: 0.5;
}
`
expect(result.css).toMatchCss(expected)
})
})