Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Commit

Permalink
Support CSS variables in arbitrary values
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Mar 19, 2021
1 parent 798eb2a commit d628fbc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lib/generateRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ function getClassNameFromSelector(selector) {
// ['ring-offset', 'blue-100']
// ['ring', 'offset-blue-100']
function* candidatePermutations(prefix, modifier = '') {
let dashIdx = prefix.lastIndexOf('-')
if (dashIdx === -1) {
let dashIdx

if (modifier.endsWith(']')) {
dashIdx = prefix.lastIndexOf('[') - 1
} else {
dashIdx = prefix.lastIndexOf('-')
}

if (dashIdx < 0) {
return
}

Expand Down
3 changes: 3 additions & 0 deletions tests/08-arbitrary-values.test.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
.duration-\[2s\] {
transition-duration: 2s;
}
.duration-\[var\(--app-duration\)\] {
transition-duration: var(--app-duration);
}
@media (min-width: 1024px) {
.lg\:grid-cols-\[200px\2c repeat\(auto-fill\2c minmax\(15\%\2c 100px\)\)\2c 300px\] {
grid-template-columns: 200px repeat(auto-fill, minmax(15%, 100px)) 300px;
Expand Down
1 change: 1 addition & 0 deletions tests/08-arbitrary-values.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
<div class="text-[2.23rem]"></div>
<div class="duration-[2s]"></div>
<div class="mt-[clamp(30px,100px)]"></div>
<div class="duration-[var(--app-duration)]"></div>
</body>
</html>

0 comments on commit d628fbc

Please sign in to comment.