diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-05-28 16:30:26 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-05-28 16:30:26 +0200 |
| commit | cd32a3ca0173676ed31486b5fa4dbd8c744cdec5 (patch) | |
| tree | a9d0888c7a0e425ef8006cc9aade5889b78c074c /src/z/Component.zig | |
| parent | e749e2ccf97e6e7a2d1c124c4e5bed688e4c06f2 (diff) | |
implement frontend framework
Diffstat (limited to 'src/z/Component.zig')
| -rw-r--r-- | src/z/Component.zig | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/z/Component.zig b/src/z/Component.zig new file mode 100644 index 0000000..3211335 --- /dev/null +++ b/src/z/Component.zig @@ -0,0 +1,18 @@ +const std = @import("std"); +const html = @import("html"); +const z = @import("root.zig"); + +name: @EnumLiteral(), +body: []const u8, +style: []const u8, +script: []const u8, + +pub fn toElement(comptime self: @This()) html.Element { + return .transparent(.children(&.{ + .native(.template, .{ .id = "@" ++ @tagName(self.name) }, .children(&.{ + z.style.load(self.style), + z.body.load(self.body), + })), + z.script.load("Zenv.constructors['component__" ++ @tagName(self.name) ++ "'] = (Z) => {" ++ self.script ++ "}"), + })); +} |