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

Commit 6a076ea

Browse files
authored
Merge pull request #114 from bimspot/fix-negative-prefix
Fixed issue with negative classes not being generated when used with a prefix.
2 parents abc850e + f4bf0dd commit 6a076ea

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/lib/generateRules.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,11 @@ function* resolveMatchedPlugins(classCandidate, context) {
140140
let candidatePrefix = classCandidate
141141
let negative = false
142142

143-
if (candidatePrefix[0] === '-') {
143+
const twConfigPrefix = context.tailwindConfig.prefix || ''
144+
const twConfigPrefixLen = twConfigPrefix.length
145+
if (candidatePrefix[twConfigPrefixLen] === '-') {
144146
negative = true
145-
candidatePrefix = candidatePrefix.slice(1)
147+
candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1)
146148
}
147149

148150
for (let [prefix, modifier] of candidatePermutations(candidatePrefix)) {

tests/05-prefix.test.css

+9
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
.tw-dark .tw-group:hover .custom-component {
4848
font-weight: 400;
4949
}
50+
.tw--ml-4 {
51+
margin-left: -1rem;
52+
}
5053
.tw-font-bold {
5154
font-weight: 700;
5255
}
@@ -71,6 +74,12 @@
7174
text-align: left;
7275
}
7376
@media (min-width: 768px) {
77+
.md\:tw--ml-5 {
78+
margin-left: -1.25rem;
79+
}
80+
.md\:hover\:tw--ml-6:hover {
81+
margin-left: -1.5rem;
82+
}
7483
.md\:hover\:tw-text-right:hover {
7584
text-align: right;
7685
}

tests/05-prefix.test.html

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
<div class="tw--ml-4"></div>
2+
<div class="md:tw--ml-5"></div>
3+
<div class="md:hover:tw--ml-6"></div>
14
<div class="tw-container"></div>
25
<div class="btn-no-prefix"></div>
36
<div class="tw-btn-prefix"></div>

0 commit comments

Comments
 (0)