Skip to content

Commit 123f0e2

Browse files
committed
Enable custom spacing for inset and space-between
1 parent ff704eb commit 123f0e2

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

plugins/inset.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
const numberRegex = require("./util/numberRegex");
2+
13
module.exports = function ({ matchUtilities, theme }) {
4+
const values = theme("inset");
25
const calculatedValues = {};
6+
const keywords = ["auto"];
37

4-
for (const property in theme("inset")) {
8+
for (const property in values) {
59
if (property === "px") {
610
calculatedValues[property] = "1px";
711
} else if (property === "full") {
812
calculatedValues[property] = "100%";
9-
} else if (property === "auto") {
10-
calculatedValues[property] = "auto";
13+
} else if (
14+
keywords.includes(property) ||
15+
(!numberRegex.test(property) && values[property])
16+
) {
17+
calculatedValues[property] = values[property];
1118
} else if (property.includes("/")) {
1219
calculatedValues[property] = `calc(${property} * 100%)`;
1320
} else {

plugins/spaceBetween.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
const numberRegex = require("./util/numberRegex");
2+
13
module.exports = function ({ addUtilities, matchUtilities, theme }) {
4+
const values = theme("margin");
25
const calculatedValues = {};
36

4-
for (const property in theme("margin")) {
7+
for (const property in values) {
58
if (property === "px") {
69
calculatedValues[property] = "1px";
10+
} else if (!numberRegex.test(property) && values[property]) {
11+
calculatedValues[property] = values[property];
712
} else {
813
calculatedValues[property] = `calc(var(--spacing) * ${property})`;
914
}

0 commit comments

Comments
 (0)