Skip to content

Commit 2fc5b9a

Browse files
committed
Add spaces after commas/colons in CSS function values
Add missing spaces after commas in color-mix(), var() fallbacks, and @supports conditions to match official Tailwind v4 output formatting. Affected patterns: - color-mix(in srgb, ..., transparent) and color-mix(in oklab, ..., transparent) - var(--tw-ease, var(...)), var(--tw-duration, var(...)) - var(--tw-ring-color, currentcolor), var(--tw-shadow-color, ...) - var(--tw-leading, var(...)), var(--tw-gradient-via-stops, var(...)) - var(--tw-drop-shadow-color, ...) - @supports (color: color-mix(in lab, red, red))
1 parent e785d06 commit 2fc5b9a

4 files changed

Lines changed: 48 additions & 48 deletions

File tree

src/color.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ pub fn resolveColorMixWithKey(alloc: Allocator, color_value: []const u8, alpha_p
355355
}
356356

357357
fn fallbackColorMix(alloc: Allocator, color_value: []const u8, alpha_percent: u8) ![]const u8 {
358-
return std.fmt.allocPrint(alloc, "color-mix(in oklab,{s} {d}%,transparent)", .{ color_value, alpha_percent });
358+
return std.fmt.allocPrint(alloc, "color-mix(in oklab, {s} {d}%, transparent)", .{ color_value, alpha_percent });
359359
}
360360

361361
/// Parse "oklch(L% C H)" where L is 0-100%, C is 0-0.4+, H is 0-360

src/compiler.zig

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ test "compile: plugin_css colors work with opacity modifiers" {
18481848
const result = try compile(alloc, &candidates, null, false, true, null, null, plugin);
18491849
defer alloc.free(result);
18501850
// Should use color-mix with the raw oklch value
1851-
try std.testing.expect(std.mem.indexOf(u8, result, "background-color:color-mix(in srgb,oklch(62.3% 0.214 259.815) 50%,transparent)") != null);
1851+
try std.testing.expect(std.mem.indexOf(u8, result, "background-color:color-mix(in srgb, oklch(62.3% 0.214 259.815) 50%, transparent)") != null);
18521852
}
18531853

18541854
test "compile: plugin_css null is no-op" {
@@ -2029,37 +2029,37 @@ test "compile: bg color with opacity uses color-mix" {
20292029
const result = try compile(alloc, &candidates, null, false, true, null, null, null);
20302030
defer alloc.free(result);
20312031
// Base: color-mix in srgb with raw value
2032-
try std.testing.expect(std.mem.indexOf(u8, result, "background-color:color-mix(in srgb,#fff 10%,transparent)") != null);
2032+
try std.testing.expect(std.mem.indexOf(u8, result, "background-color:color-mix(in srgb, #fff 10%, transparent)") != null);
20332033
// Enhanced: @supports with color-mix in oklab using var()
2034-
try std.testing.expect(std.mem.indexOf(u8, result, "@supports (color:color-mix(in lab,red,red))") != null);
2035-
try std.testing.expect(std.mem.indexOf(u8, result, "background-color:color-mix(in oklab,var(--color-white) 10%,transparent)") != null);
2034+
try std.testing.expect(std.mem.indexOf(u8, result, "@supports (color: color-mix(in lab, red, red))") != null);
2035+
try std.testing.expect(std.mem.indexOf(u8, result, "background-color:color-mix(in oklab, var(--color-white) 10%, transparent)") != null);
20362036
}
20372037

20382038
test "compile: border color with opacity uses color-mix" {
20392039
const alloc = std.testing.allocator;
20402040
const candidates = [_][]const u8{"border-cyan-400/20"};
20412041
const result = try compile(alloc, &candidates, null, false, true, null, null, null);
20422042
defer alloc.free(result);
2043-
try std.testing.expect(std.mem.indexOf(u8, result, "border-color:color-mix(in srgb,") != null);
2044-
try std.testing.expect(std.mem.indexOf(u8, result, "border-color:color-mix(in oklab,var(--color-cyan-400) 20%,transparent)") != null);
2043+
try std.testing.expect(std.mem.indexOf(u8, result, "border-color:color-mix(in srgb, ") != null);
2044+
try std.testing.expect(std.mem.indexOf(u8, result, "border-color:color-mix(in oklab, var(--color-cyan-400) 20%, transparent)") != null);
20452045
}
20462046

20472047
test "compile: gradient from with opacity uses color-mix" {
20482048
const alloc = std.testing.allocator;
20492049
const candidates = [_][]const u8{"from-violet-500/10"};
20502050
const result = try compile(alloc, &candidates, null, false, true, null, null, null);
20512051
defer alloc.free(result);
2052-
try std.testing.expect(std.mem.indexOf(u8, result, "--tw-gradient-from:color-mix(in srgb,") != null);
2053-
try std.testing.expect(std.mem.indexOf(u8, result, "--tw-gradient-from:color-mix(in oklab,var(--color-violet-500) 10%,transparent)") != null);
2052+
try std.testing.expect(std.mem.indexOf(u8, result, "--tw-gradient-from:color-mix(in srgb, ") != null);
2053+
try std.testing.expect(std.mem.indexOf(u8, result, "--tw-gradient-from:color-mix(in oklab, var(--color-violet-500) 10%, transparent)") != null);
20542054
}
20552055

20562056
test "compile: ring color with opacity uses color-mix" {
20572057
const alloc = std.testing.allocator;
20582058
const candidates = [_][]const u8{"ring-white/10"};
20592059
const result = try compile(alloc, &candidates, null, false, true, null, null, null);
20602060
defer alloc.free(result);
2061-
try std.testing.expect(std.mem.indexOf(u8, result, "--tw-ring-color:color-mix(in srgb,#fff 10%,transparent)") != null);
2062-
try std.testing.expect(std.mem.indexOf(u8, result, "--tw-ring-color:color-mix(in oklab,var(--color-white) 10%,transparent)") != null);
2061+
try std.testing.expect(std.mem.indexOf(u8, result, "--tw-ring-color:color-mix(in srgb, #fff 10%, transparent)") != null);
2062+
try std.testing.expect(std.mem.indexOf(u8, result, "--tw-ring-color:color-mix(in oklab, var(--color-white) 10%, transparent)") != null);
20632063
}
20642064

20652065
test "compile: space-y uses :where() CSS nesting" {
@@ -2109,7 +2109,7 @@ test "compile: shadow-color enhanced uses --tw-shadow-alpha" {
21092109
const result = try compile(alloc, &candidates, null, false, true, null, null, null);
21102110
defer alloc.free(result);
21112111
// Enhanced value should wrap with --tw-shadow-alpha
2112-
try std.testing.expect(std.mem.indexOf(u8, result, "color-mix(in oklab,color-mix(in oklab,var(--color-black) 10%,transparent) var(--tw-shadow-alpha),transparent)") != null);
2112+
try std.testing.expect(std.mem.indexOf(u8, result, "color-mix(in oklab, color-mix(in oklab, var(--color-black) 10%, transparent) var(--tw-shadow-alpha), transparent)") != null);
21132113
}
21142114

21152115
test "compile: --font-sans and --font-mono appear in theme output with preflight" {
@@ -2362,7 +2362,7 @@ test "compile: theme() in shadow arbitrary value resolves" {
23622362
try std.testing.expect(std.mem.indexOf(u8, result, "theme(") == null);
23632363
try std.testing.expect(std.mem.indexOf(u8, result, "oklch(76.5% 0.177 163.223)") != null);
23642364
// The resolved color should be wrapped in var(--tw-shadow-color, ...)
2365-
try std.testing.expect(std.mem.indexOf(u8, result, "var(--tw-shadow-color,oklch(76.5% 0.177 163.223))") != null);
2365+
try std.testing.expect(std.mem.indexOf(u8, result, "var(--tw-shadow-color, oklch(76.5% 0.177 163.223))") != null);
23662366
}
23672367

23682368
test "compile: theme() with opacity in shadow arbitrary value wraps color in shadow-color var" {
@@ -2372,7 +2372,7 @@ test "compile: theme() with opacity in shadow arbitrary value wraps color in sha
23722372
defer alloc.free(result);
23732373
try std.testing.expect(std.mem.indexOf(u8, result, "theme(") == null);
23742374
// The color-mix result should be wrapped in var(--tw-shadow-color, ...)
2375-
try std.testing.expect(std.mem.indexOf(u8, result, "var(--tw-shadow-color,color-mix(in oklab, oklch(76.5% 0.177 163.223) 50%, transparent))") != null);
2375+
try std.testing.expect(std.mem.indexOf(u8, result, "var(--tw-shadow-color, color-mix(in oklab, oklch(76.5% 0.177 163.223) 50%, transparent))") != null);
23762376
}
23772377

23782378
// ─── Format parity tests (issues #1-7) ──────────────────────────────────────

src/emitter.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ pub const CssEmitter = struct {
527527
if (!has_any) return;
528528

529529
try self.writeNewline();
530-
try self.buf.appendSlice(self.alloc, "@supports (color:color-mix(in lab,red,red))");
530+
try self.buf.appendSlice(self.alloc, "@supports (color: color-mix(in lab, red, red))");
531531
try self.writeSpace();
532532
try self.buf.append(self.alloc, '{');
533533
self.indent += 1;

0 commit comments

Comments
 (0)