Return align function!

This commit is contained in:
Mira
2026-04-29 02:05:45 +03:00
parent 0a25911ba9
commit 2ce7a39c1a
+36 -19
View File
@@ -8,14 +8,8 @@ import type {
} from "tailwindcss/plugin"; } from "tailwindcss/plugin";
import flattenColorPalette from "tailwindcss/lib/util/flattenColorPalette"; import flattenColorPalette from "tailwindcss/lib/util/flattenColorPalette";
const DASH_ARRAY = "var(--tw-dashed-border-length) var(--tw-dashed-border-gap)";
const INSET = "calc(var(--tw-dashed-border-width) / 2)";
const INNER_SIZE = "calc(100% - var(--tw-dashed-border-width))";
const ADJUSTED_RADIUS =
"max(0px, calc(var(--tw-dashed-border-radius) - (var(--tw-dashed-border-width) / 2)))";
const ALL_TRANSITION_PROPERTIES = const ALL_TRANSITION_PROPERTIES =
"stroke-dasharray, stroke-dashoffset, stroke-width, stroke, rx"; "stroke-dasharray, stroke-dashoffset, stroke-width, stroke, rx, x, y, width, height";
const COLOR_TRANSITION_PROPERTIES = "stroke"; const COLOR_TRANSITION_PROPERTIES = "stroke";
const TRANSITION_DURATION = const TRANSITION_DURATION =
"var(--tw-duration, var(--default-transition-duration))"; "var(--tw-duration, var(--default-transition-duration))";
@@ -197,29 +191,34 @@ const dashedBorderPlugin: ReturnType<typeof plugin> = plugin(
addBase({ addBase({
"@property --tw-dashed-border-gap": { "@property --tw-dashed-border-gap": {
syntax: "<length>", syntax: "\"<length>\"",
inherits: "true", inherits: "true",
"initial-value": DEFAULT_GAP, "initial-value": "8px",
}, },
"@property --tw-dashed-border-length": { "@property --tw-dashed-border-length": {
syntax: "<length>", syntax: "\"<length>\"",
inherits: "true", inherits: "true",
"initial-value": DEFAULT_LENGTH, "initial-value": "10px",
}, },
"@property --tw-dashed-border-offset": { "@property --tw-dashed-border-offset": {
syntax: "<length>", syntax: "\"<length>\"",
inherits: "true", inherits: "true",
"initial-value": DEFAULT_OFFSET, "initial-value": "0px",
}, },
"@property --tw-dashed-border-width": { "@property --tw-dashed-border-width": {
syntax: "<length>", syntax: "\"<length>\"",
inherits: "true", inherits: "true",
"initial-value": "1px", "initial-value": "1px",
}, },
"@property --tw-dashed-border-radius": { "@property --tw-dashed-border-radius": {
syntax: "<length>", syntax: "\"<length>\"",
inherits: "true", inherits: "true",
"initial-value": DEFAULT_RADIUS, "initial-value": "currentColor",
},
"@property --tw-dashed-border-alignment": {
syntax: "\"<number>\"",
inherits: "true",
"initial-value": "0",
}, },
".dashed-border": { ".dashed-border": {
position: "relative", position: "relative",
@@ -237,11 +236,19 @@ const dashedBorderPlugin: ReturnType<typeof plugin> = plugin(
height: "100%", height: "100%",
"pointer-events": "none", "pointer-events": "none",
}, },
".dashed-border-rect": { });
const INSET = "calc((0.5 - var(--tw-dashed-border-alignment)) * var(--tw-dashed-border-width))";
const INNER_SIZE = "calc(100% + var(--tw-dashed-border-width) * (2 * var(--tw-dashed-border-alignment) - 1))";
const ADJUSTED_RADIUS =
"max(0px, calc(var(--tw-dashed-border-radius) - (0.5 - var(--tw-dashed-border-alignment)) * var(--tw-dashed-border-width)))";
addBase({".dashed-border-rect": {
fill: "none", fill: "none",
stroke: "var(--tw-dashed-border-color)", stroke: "var(--tw-dashed-border-color)",
"stroke-width": "var(--tw-dashed-border-width)", "stroke-width": "var(--tw-dashed-border-width)",
"stroke-dasharray": DASH_ARRAY, "stroke-dasharray": "var(--tw-dashed-border-length) var(--tw-dashed-border-gap)",
"stroke-dashoffset": "var(--tw-dashed-border-offset)", "stroke-dashoffset": "var(--tw-dashed-border-offset)",
"vector-effect": "non-scaling-stroke", "vector-effect": "non-scaling-stroke",
x: INSET, x: INSET,
@@ -250,7 +257,7 @@ const dashedBorderPlugin: ReturnType<typeof plugin> = plugin(
height: INNER_SIZE, height: INNER_SIZE,
rx: ADJUSTED_RADIUS, rx: ADJUSTED_RADIUS,
}, },
}); })
const spacingRawValues = theme("spacing") as const spacingRawValues = theme("spacing") as
| ConfigValuesTree<string> | ConfigValuesTree<string>
@@ -278,6 +285,16 @@ const dashedBorderPlugin: ReturnType<typeof plugin> = plugin(
utilityName: "dashed-border-offset", utilityName: "dashed-border-offset",
supportsNegativeValues: true, supportsNegativeValues: true,
}), }),
{
utilityName: "dashed-border-align",
arbitraryValueResolver: toCssVariable("--tw-dashed-border-alignment"),
defaultValues: {
inside: "0",
edge: "0.5",
outside: "1",
},
type: "number",
},
{ {
utilityName: "dashed-border-width", utilityName: "dashed-border-width",
arbitraryValueResolver: toCssVariable("--tw-dashed-border-width"), arbitraryValueResolver: toCssVariable("--tw-dashed-border-width"),