Skip to content

Commit 2e55a5d

Browse files
committed
add dedicated color stop position tests
1 parent 54c153c commit 2e55a5d

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

tests/plugins/gradientColorStops.test.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,77 @@ crosscheck(({ stable, oxide }) => {
127127
`)
128128
})
129129
})
130+
131+
test('gradient color stop position', () => {
132+
let config = {
133+
content: [
134+
{
135+
raw: html`
136+
<div>
137+
<div
138+
class="bg-gradient-to-r from-red-500 from-50 via-pink-500 via-75 to-violet-400 to-80"
139+
></div>
140+
<div class="from-10 from-[14%]"></div>
141+
<div class="via-10 via-[14%]"></div>
142+
<div class="to-10 to-[14%]"></div>
143+
</div>
144+
`,
145+
},
146+
],
147+
theme: {},
148+
}
149+
150+
return run('@tailwind utilities', config).then((result) => {
151+
expect(result.css).toMatchFormattedCss(css`
152+
.bg-gradient-to-r {
153+
background-image: linear-gradient(to right, var(--tw-gradient-stops));
154+
}
155+
.from-red-500 {
156+
--tw-gradient-from: #ef4444 var(--tw-gradient-from-position);
157+
--tw-gradient-from-position: ;
158+
--tw-gradient-to: #ef444400 var(--tw-gradient-from-position);
159+
--tw-gradient-to-position: ;
160+
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
161+
}
162+
.from-10 {
163+
--tw-gradient-from-position: 10%;
164+
}
165+
.from-50 {
166+
--tw-gradient-from-position: 50%;
167+
}
168+
.from-\[14\%\] {
169+
--tw-gradient-from-position: 14%;
170+
}
171+
.via-pink-500 {
172+
--tw-gradient-via-position: ;
173+
--tw-gradient-to: #ec489900 var(--tw-gradient-to-position);
174+
--tw-gradient-to-position: ;
175+
--tw-gradient-stops: var(--tw-gradient-from), #ec4899 var(--tw-gradient-via-position),
176+
var(--tw-gradient-to);
177+
}
178+
.via-10 {
179+
--tw-gradient-via-position: 10%;
180+
}
181+
.via-75 {
182+
--tw-gradient-via-position: 75%;
183+
}
184+
.via-\[14\%\] {
185+
--tw-gradient-via-position: 14%;
186+
}
187+
.to-violet-400 {
188+
--tw-gradient-to: #a78bfa var(--tw-gradient-to-position);
189+
--tw-gradient-to-position: ;
190+
}
191+
.to-10 {
192+
--tw-gradient-to-position: 10%;
193+
}
194+
.to-80 {
195+
--tw-gradient-to-position: 80%;
196+
}
197+
.to-\[14\%\] {
198+
--tw-gradient-to-position: 14%;
199+
}
200+
`)
201+
})
202+
})
130203
})

0 commit comments

Comments
 (0)