aboutsummaryrefslogtreecommitdiff
path: root/src/z/root.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/z/root.zig')
-rw-r--r--src/z/root.zig52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/z/root.zig b/src/z/root.zig
new file mode 100644
index 0000000..26bbffc
--- /dev/null
+++ b/src/z/root.zig
@@ -0,0 +1,52 @@
+const std = @import("std");
+
+pub const Minifier = @import("Minifier.zig");
+pub const Component = @import("Component.zig");
+pub const File = @import("File.zig");
+
+const Element = @import("html").Element;
+
+pub const script: File = .{
+ .tag = .script,
+ .minifier = .js,
+};
+pub const style: File = .{
+ .tag = .style,
+ .minifier = .css,
+};
+pub const body: File = .{
+ .tag = .body,
+ .minifier = .html,
+};
+
+pub const html: File = .{
+ .tag = null,
+ .minifier = .html,
+};
+
+pub fn env(comptime components: []const Component) Element {
+ var children: []const Element = &.{script.load(@embedFile("z.js"))};
+
+ inline for (components) |c| {
+ const child: []const Element = &.{c.toElement()};
+ children = children ++ child;
+ }
+
+ return .transparent(.children(children));
+}
+
+pub fn component(kind: @EnumLiteral(), attrs: anytype, content: Element.Content) Element {
+ var element: Element = .native(.@"z-component", attrs, content);
+
+ const type_attr: []const Element.Attribute = &.{.{
+ .name = "type",
+ .value = @tagName(kind),
+ }};
+ element.attributes = type_attr ++ element.attributes;
+
+ return element;
+}
+
+test {
+ _ = std.testing.refAllDecls(@This());
+}