WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit 7eab7d0

Browse files
committed
Support arbitrary values for padding
1 parent d628fbc commit 7eab7d0

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/corePlugins/padding.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const { asLength, nameClass } = require('../pluginUtils')
1+
const { asValue, nameClass } = require('../pluginUtils')
22

33
module.exports = function ({ matchUtilities, jit: { theme } }) {
44
matchUtilities({
55
p: (modifier, { theme }) => {
6-
let value = asLength(modifier, theme['padding'])
6+
let value = asValue(modifier, theme['padding'])
77

88
if (value === undefined) {
99
return []
@@ -14,7 +14,7 @@ module.exports = function ({ matchUtilities, jit: { theme } }) {
1414
})
1515
matchUtilities({
1616
px: (modifier, { theme }) => {
17-
let value = asLength(modifier, theme['padding'])
17+
let value = asValue(modifier, theme['padding'])
1818

1919
if (value === undefined) {
2020
return []
@@ -23,7 +23,7 @@ module.exports = function ({ matchUtilities, jit: { theme } }) {
2323
return { [nameClass('px', modifier)]: { 'padding-left': value, 'padding-right': value } }
2424
},
2525
py: (modifier, { theme }) => {
26-
let value = asLength(modifier, theme['padding'])
26+
let value = asValue(modifier, theme['padding'])
2727

2828
if (value === undefined) {
2929
return []
@@ -34,7 +34,7 @@ module.exports = function ({ matchUtilities, jit: { theme } }) {
3434
})
3535
matchUtilities({
3636
pt: (modifier, { theme }) => {
37-
let value = asLength(modifier, theme['padding'])
37+
let value = asValue(modifier, theme['padding'])
3838

3939
if (value === undefined) {
4040
return []
@@ -43,7 +43,7 @@ module.exports = function ({ matchUtilities, jit: { theme } }) {
4343
return { [nameClass('pt', modifier)]: { 'padding-top': value } }
4444
},
4545
pr: (modifier, { theme }) => {
46-
let value = asLength(modifier, theme['padding'])
46+
let value = asValue(modifier, theme['padding'])
4747

4848
if (value === undefined) {
4949
return []
@@ -52,7 +52,7 @@ module.exports = function ({ matchUtilities, jit: { theme } }) {
5252
return { [nameClass('pr', modifier)]: { 'padding-right': value } }
5353
},
5454
pb: (modifier, { theme }) => {
55-
let value = asLength(modifier, theme['padding'])
55+
let value = asValue(modifier, theme['padding'])
5656

5757
if (value === undefined) {
5858
return []
@@ -61,7 +61,7 @@ module.exports = function ({ matchUtilities, jit: { theme } }) {
6161
return { [nameClass('pb', modifier)]: { 'padding-bottom': value } }
6262
},
6363
pl: (modifier, { theme }) => {
64-
let value = asLength(modifier, theme['padding'])
64+
let value = asValue(modifier, theme['padding'])
6565

6666
if (value === undefined) {
6767
return []

tests/08-arbitrary-values.test.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
.bg-opacity-\[0\.11\] {
7777
--tw-bg-opacity: 0.11;
7878
}
79+
.p-\[var\(--app-padding\)\] {
80+
padding: var(--app-padding);
81+
}
7982
.text-\[2\.23rem\] {
8083
font-size: 2.23rem;
8184
}

tests/08-arbitrary-values.test.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525
<div class="duration-[2s]"></div>
2626
<div class="mt-[clamp(30px,100px)]"></div>
2727
<div class="duration-[var(--app-duration)]"></div>
28+
<div class="p-[var(--app-padding)]"></div>
2829
</body>
2930
</html>

0 commit comments

Comments
 (0)