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

Fixed issue with negative classes not being generated when used with a prefix. #114

Merged
merged 1 commit into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/lib/generateRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@ function* resolveMatchedPlugins(classCandidate, context) {
let candidatePrefix = classCandidate
let negative = false

if (candidatePrefix[0] === '-') {
const twConfigPrefix = context.tailwindConfig.prefix || ''
const twConfigPrefixLen = twConfigPrefix.length
if (candidatePrefix[twConfigPrefixLen] === '-') {
negative = true
candidatePrefix = candidatePrefix.slice(1)
candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1)
}

for (let [prefix, modifier] of candidatePermutations(candidatePrefix)) {
Expand Down
9 changes: 9 additions & 0 deletions tests/05-prefix.test.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
.tw-dark .tw-group:hover .custom-component {
font-weight: 400;
}
.tw--ml-4 {
margin-left: -1rem;
}
.tw-font-bold {
font-weight: 700;
}
Expand All @@ -71,6 +74,12 @@
text-align: left;
}
@media (min-width: 768px) {
.md\:tw--ml-5 {
margin-left: -1.25rem;
}
.md\:hover\:tw--ml-6:hover {
margin-left: -1.5rem;
}
.md\:hover\:tw-text-right:hover {
text-align: right;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/05-prefix.test.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<div class="tw--ml-4"></div>
<div class="md:tw--ml-5"></div>
<div class="md:hover:tw--ml-6"></div>
<div class="tw-container"></div>
<div class="btn-no-prefix"></div>
<div class="tw-btn-prefix"></div>
Expand Down