aboutsummaryrefslogtreecommitdiff
path: root/src/app/components/navbutton/root.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/components/navbutton/root.zig')
-rw-r--r--src/app/components/navbutton/root.zig21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/app/components/navbutton/root.zig b/src/app/components/navbutton/root.zig
index 0040c9d..1078924 100644
--- a/src/app/components/navbutton/root.zig
+++ b/src/app/components/navbutton/root.zig
@@ -1,3 +1,4 @@
+const std = @import("std");
const z = @import("z");
const Self = @This();
@@ -10,7 +11,25 @@ pub const component: z.Component = .{
};
element: *z.Object,
+shadow_root: *z.Object,
+button: struct {
+ classList: *z.Object,
+},
+
+pub fn init(self: *Self, element: *z.Object) !void {
+ var env: z.Env = .default;
+ defer env.deinit();
-pub fn init(self: *Self, element: *z.Object) void {
self.element = element;
+ self.shadow_root = try self.element.get(&env, "shadowRoot").await(&env, .object);
+ const button = try self.shadow_root.call(&env, "getElementById", .{"button"}).await(&env, .object);
+ defer _ = button.free(&env);
+ self.button.classList = try button.get(&env, "classList").await(&env, .object);
+}
+
+pub fn open(self: *Self) !void {
+ var env: z.Env = .default;
+ defer env.deinit();
+
+ _ = self.button.classList.call(&env, "toggle", .{"open"});
}