aboutsummaryrefslogtreecommitdiff
path: root/src/app/components/hello/root.zig
blob: c4a7732c8d03fb7259a4f07b7db494635e708aec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const std = @import("std");
const z = @import("z");

const Self = @This();

pub const component: z.Component = .{
    .name = "hello",
    .html = .node("div", .{ .onclick = "@clicked" }, &.{.text("click me")}),
    .css = @embedFile("index.css"),
    .link = @This(),
};

element: *z.Object,
counter: usize,

pub fn init(self: *Self, element: *z.Object) void {
    self.element = element;
    self.counter = 0;
}

pub fn clicked(self: *Self) void {
    self.counter += 1;
    std.log.info("clicked {} times", .{self.counter});
}