From 4e86e3e18e9b43e442a35361ac82b30dd6c0103a Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Wed, 7 Oct 2026 00:09:34 +0200 Subject: wasm implement components --- src/z/App/root.zig | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/z/App/root.zig') diff --git a/src/z/App/root.zig b/src/z/App/root.zig index 326f3c0..a3d0916 100644 --- a/src/z/App/root.zig +++ b/src/z/App/root.zig @@ -1,10 +1,13 @@ const builtin = @import("builtin"); const std = @import("std"); -const h = @import("html"); +const h = @import("../html.zig"); +const Component = @import("../root.zig").Component; pub const Options = struct { name: []const u8, globals: []const Global, + components: []const Component, + body: h.Element, pub const Global = struct { name: []const u8, @@ -37,6 +40,12 @@ pub fn App(comptime options: Options) type { }, pub const init: @This() = .{}; + + comptime { + for (options.components) |component| { + component.exportLinks(); + } + } }; } else { return struct { @@ -63,6 +72,17 @@ pub fn App(comptime options: Options) type { break :reg register_code; })), .native(.script, .{}, .content(@embedFile("main.js"))), + .transparent(.children(comp: { + var cs: []const h.Element = &.{}; + + for (options.components) |component| { + const c: []const h.Element = &.{component.toElement()}; + cs = cs ++ c; + } + + break :comp cs; + })), + options.body, })), })).toDocument(), -- cgit v1.2.3-70-g09d2