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

Commit bfe57b4

Browse files
committed
Fix issue with utility base styles being omitted when only variants are used
1 parent 2c72f09 commit bfe57b4

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed

src/corePlugins/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,11 @@ module.exports = {
212212
placeholderOpacity: require('./placeholderOpacity'),
213213
pointerEvents: require('./pointerEvents'),
214214
resize: require('./resize'),
215+
ringWidth: require('./ringWidth'),
216+
ringOffsetWidth: require('./ringOffsetWidth'),
215217
ringColor: require('./ringColor'),
216218
ringOffsetColor: require('./ringOffsetColor'),
217-
ringOffsetWidth: require('./ringOffsetWidth'),
218219
ringOpacity: require('./ringOpacity'),
219-
ringWidth: require('./ringWidth'),
220220
space: require('./space'),
221221
stroke: require('./stroke'),
222222
strokeWidth: require('./strokeWidth'),

src/corePlugins/ringWidth.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,25 @@ function safeCall(callback, defaultValue) {
1010
}
1111
}
1212

13-
let ringReset = ['*']
14-
1513
module.exports = function ({ jit: { theme, addUtilities } }) {
1614
let ringColorDefault = (([r, g, b]) => {
1715
return `rgba(${r}, ${g}, ${b}, ${theme.ringOpacity?.DEFAULT ?? '0.5'})`
1816
})(safeCall(() => toRgba(theme.ringOpacity?.DEFAULT), ['147', '197', '253']))
1917

20-
ringReset[1] = {
21-
'--tw-ring-inset': 'var(--tw-empty,/*!*/ /*!*/)',
22-
'--tw-ring-offset-width': theme.ringOffsetWidth?.DEFAULT ?? '0px',
23-
'--tw-ring-offset-color': theme.ringOffsetColor?.DEFAULT ?? '#fff',
24-
'--tw-ring-color': ringColorDefault,
25-
'--tw-ring-offset-shadow': '0 0 #0000',
26-
'--tw-ring-shadow': '0 0 #0000',
27-
}
18+
let ringReset = [
19+
'*',
20+
{
21+
'--tw-ring-inset': 'var(--tw-empty,/*!*/ /*!*/)',
22+
'--tw-ring-offset-width': theme.ringOffsetWidth?.DEFAULT ?? '0px',
23+
'--tw-ring-offset-color': theme.ringOffsetColor?.DEFAULT ?? '#fff',
24+
'--tw-ring-color': ringColorDefault,
25+
'--tw-ring-offset-shadow': '0 0 #0000',
26+
'--tw-ring-shadow': '0 0 #0000',
27+
},
28+
{
29+
respectVariants: false,
30+
},
31+
]
2832

2933
addUtilities({
3034
ring: [

src/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,13 @@ function applyVariant(variant, matches, { variantMap }) {
412412
let result = []
413413

414414
for (let [sort, rule] of matches) {
415+
let [, , options = {}] = rule
416+
417+
if (options.respectVariants === false) {
418+
result.push([sort, rule])
419+
continue
420+
}
421+
415422
let ruleWithVariant = applyThisVariant(rule)
416423

417424
if (ruleWithVariant === null) {

src/index.test.css

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,13 @@
170170
.font-medium {
171171
font-weight: 500;
172172
}
173-
.ring-offset-blue-500 {
174-
--tw-ring-offset-color: #3b82f6;
173+
* {
174+
--tw-ring-inset: var(--tw-empty, /*!*/ /*!*/);
175+
--tw-ring-offset-width: 0px;
176+
--tw-ring-offset-color: #fff;
177+
--tw-ring-color: rgba(147, 197, 253, 0.5);
178+
--tw-ring-offset-shadow: 0 0 #0000;
179+
--tw-ring-shadow: 0 0 #0000;
175180
}
176181
.text-center {
177182
text-align: center;
@@ -222,6 +227,17 @@
222227
.focus\:font-normal:focus {
223228
font-weight: 400;
224229
}
230+
.focus\:ring-2:focus {
231+
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width)
232+
var(--tw-ring-offset-color);
233+
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width))
234+
var(--tw-ring-color);
235+
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
236+
}
237+
.focus\:ring-blue-500:focus {
238+
--tw-ring-opacity: 1;
239+
--tw-ring-color: rgba(59, 130, 246, var(--tw-ring-opacity));
240+
}
225241
.hover\:focus\:font-light:hover:focus {
226242
font-weight: 300;
227243
}

src/index.test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<div class="focus:font-normal"></div>
1515
<div class="font-medium"></div>
1616
<div class="bg-opacity-50"></div>
17-
<div class="ring-offset-blue-500"></div>
17+
<div class="focus:ring-2 focus:ring-blue-500"></div>
1818
<div class="hover:font-bold"></div>
1919
<div class="disabled:font-bold"></div>
2020
<div class="hover:focus:font-light"></div>

0 commit comments

Comments
 (0)