move isHexColor to color.zig

This commit is contained in:
Halil Durak
2026-01-10 14:13:09 +03:00
parent 7184a91c95
commit 6ff6232316
2 changed files with 17 additions and 19 deletions

View File

@@ -19,7 +19,23 @@
const std = @import("std"); const std = @import("std");
const Io = std.Io; const Io = std.Io;
const isHexColor = @import("webapi/css/CSSStyleDeclaration.zig").isHexColor; pub fn isHexColor(value: []const u8) bool {
if (value.len == 0) {
return false;
}
if (value[0] != '#') {
return false;
}
const hex_part = value[1..];
switch (hex_part.len) {
3, 4, 6, 8 => for (hex_part) |c| if (!std.ascii.isHex(c)) return false,
else => return false,
}
return true;
}
pub const RGBA = packed struct(u32) { pub const RGBA = packed struct(u32) {
r: u8, r: u8,

View File

@@ -246,24 +246,6 @@ fn isInlineTag(tag_name: []const u8) bool {
return false; return false;
} }
pub fn isHexColor(value: []const u8) bool {
if (value.len == 0) {
return false;
}
if (value[0] != '#') {
return false;
}
const hex_part = value[1..];
switch (hex_part.len) {
3, 4, 6, 8 => for (hex_part) |c| if (!std.ascii.isHex(c)) return false,
else => return false,
}
return true;
}
fn getDefaultColor(element: *const Element) []const u8 { fn getDefaultColor(element: *const Element) []const u8 {
switch (element._type) { switch (element._type) {
.html => |html| { .html => |html| {