Skip to content

Commit d628fbc

Browse files
committed
Support CSS variables in arbitrary values
1 parent 798eb2a commit d628fbc

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/lib/generateRules.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ function getClassNameFromSelector(selector) {
1717
// ['ring-offset', 'blue-100']
1818
// ['ring', 'offset-blue-100']
1919
function* candidatePermutations(prefix, modifier = '') {
20-
let dashIdx = prefix.lastIndexOf('-')
21-
if (dashIdx === -1) {
20+
let dashIdx
21+
22+
if (modifier.endsWith(']')) {
23+
dashIdx = prefix.lastIndexOf('[') - 1
24+
} else {
25+
dashIdx = prefix.lastIndexOf('-')
26+
}
27+
28+
if (dashIdx < 0) {
2229
return
2330
}
2431

tests/08-arbitrary-values.test.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
8282
.duration-\[2s\] {
8383
transition-duration: 2s;
8484
}
85+
.duration-\[var\(--app-duration\)\] {
86+
transition-duration: var(--app-duration);
87+
}
8588
@media (min-width: 1024px) {
8689
.lg\:grid-cols-\[200px\2c repeat\(auto-fill\2c minmax\(15\%\2c 100px\)\)\2c 300px\] {
8790
grid-template-columns: 200px repeat(auto-fill, minmax(15%, 100px)) 300px;

tests/08-arbitrary-values.test.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
<div class="text-[2.23rem]"></div>
2525
<div class="duration-[2s]"></div>
2626
<div class="mt-[clamp(30px,100px)]"></div>
27+
<div class="duration-[var(--app-duration)]"></div>
2728
</body>
2829
</html>

0 commit comments

Comments
 (0)