forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradientColorStops.test.js
More file actions
191 lines (185 loc) · 6.56 KB
/
Copy pathgradientColorStops.test.js
File metadata and controls
191 lines (185 loc) · 6.56 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import { crosscheck, run, html, css } from '../util/run'
crosscheck(({ stable, oxide }) => {
test('opacity variables are given to colors defined as closures', () => {
let config = {
content: [
{
raw: html`<div
class="text-primary text-secondary from-primary from-secondary via-primary via-secondary to-primary to-secondary text-opacity-50"
></div>`,
},
],
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',
},
},
}
return run('@tailwind utilities', config).then((result) => {
stable.expect(result.css).toMatchFormattedCss(css`
.from-primary {
--tw-gradient-from: #1f1f1f var(--tw-gradient-from-position);
--tw-gradient-to: #1f1f1f00 var(--tw-gradient-to-position);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.from-secondary {
--tw-gradient-from: #bf5540 var(--tw-gradient-from-position);
--tw-gradient-to: #bf554000 var(--tw-gradient-to-position);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.via-primary {
--tw-gradient-to: #1f1f1f00 var(--tw-gradient-to-position);
--tw-gradient-stops: var(--tw-gradient-from), #1f1f1f var(--tw-gradient-via-position),
var(--tw-gradient-to);
}
.via-secondary {
--tw-gradient-to: #bf554000 var(--tw-gradient-to-position);
--tw-gradient-stops: var(--tw-gradient-from), #bf5540 var(--tw-gradient-via-position),
var(--tw-gradient-to);
}
.to-primary {
--tw-gradient-to: #1f1f1f var(--tw-gradient-to-position);
}
.to-secondary {
--tw-gradient-to: #bf5540 var(--tw-gradient-to-position);
}
.text-primary {
--tw-text-opacity: 1;
color: rgba(31, 31, 31, var(--tw-text-opacity));
}
.text-secondary {
--tw-text-opacity: 1;
color: hsl(10 50% 50% / var(--tw-text-opacity));
}
.text-opacity-50 {
--tw-text-opacity: 0.5;
}
`)
oxide.expect(result.css).toMatchFormattedCss(css`
.from-primary {
--tw-gradient-from: #1f1f1f var(--tw-gradient-from-position);
--tw-gradient-to: #1f1f1f00 var(--tw-gradient-to-position);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.from-secondary {
--tw-gradient-from: #bf5540 var(--tw-gradient-from-position);
--tw-gradient-to: #bf554000 var(--tw-gradient-to-position);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.via-primary {
--tw-gradient-to: #1f1f1f00 var(--tw-gradient-to-position);
--tw-gradient-stops: var(--tw-gradient-from), #1f1f1f var(--tw-gradient-via-position),
var(--tw-gradient-to);
}
.via-secondary {
--tw-gradient-to: #bf554000 var(--tw-gradient-to-position);
--tw-gradient-stops: var(--tw-gradient-from), #bf5540 var(--tw-gradient-via-position),
var(--tw-gradient-to);
}
.to-primary {
--tw-gradient-to: #1f1f1f var(--tw-gradient-to-position);
}
.to-secondary {
--tw-gradient-to: #bf5540 var(--tw-gradient-to-position);
}
.text-primary {
color: #1f1f1f;
}
.text-secondary {
color: #bf5540;
}
`)
})
})
test('gradient color stop position', () => {
let config = {
content: [
{
raw: html`
<div>
<div
class="bg-gradient-to-r from-red-500 from-50 via-pink-500 via-75 to-violet-400 to-80"
></div>
<div class="from-10% from-[11%] from-[12px] from-[--from-value]"></div>
<div class="via-20% via-[12%] via-[123px] via-[--via-value]"></div>
<div class="to-30% to-[13%] to-[14px] to-[--to-value]"></div>
</div>
`,
},
],
theme: {},
}
return run('@tailwind utilities', config).then((result) => {
expect(result.css).toMatchFormattedCss(css`
.bg-gradient-to-r {
background-image: linear-gradient(to right, var(--tw-gradient-stops));
}
.from-\[--from-value\] {
--tw-gradient-from: var(--from-value) var(--tw-gradient-from-position);
--tw-gradient-to: #fff0 var(--tw-gradient-to-position);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.from-red-500 {
--tw-gradient-from: #ef4444 var(--tw-gradient-from-position);
--tw-gradient-to: #ef444400 var(--tw-gradient-to-position);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.from-10\% {
--tw-gradient-from-position: 10%;
}
.from-\[11\%\] {
--tw-gradient-from-position: 11%;
}
.from-\[12px\] {
--tw-gradient-from-position: 12px;
}
.via-\[--via-value\] {
--tw-gradient-to: #fff0 var(--tw-gradient-to-position);
--tw-gradient-stops: var(--tw-gradient-from),
var(--via-value) var(--tw-gradient-via-position), var(--tw-gradient-to);
}
.via-pink-500 {
--tw-gradient-to: #ec489900 var(--tw-gradient-to-position);
--tw-gradient-stops: var(--tw-gradient-from), #ec4899 var(--tw-gradient-via-position),
var(--tw-gradient-to);
}
.via-20\% {
--tw-gradient-via-position: 20%;
}
.via-\[12\%\] {
--tw-gradient-via-position: 12%;
}
.via-\[123px\] {
--tw-gradient-via-position: 123px;
}
.to-\[--to-value\] {
--tw-gradient-to: var(--to-value) var(--tw-gradient-to-position);
}
.to-violet-400 {
--tw-gradient-to: #a78bfa var(--tw-gradient-to-position);
}
.to-30\% {
--tw-gradient-to-position: 30%;
}
.to-\[13\%\] {
--tw-gradient-to-position: 13%;
}
.to-\[14px\] {
--tw-gradient-to-position: 14px;
}
`)
})
})
})