aboutsummaryrefslogtreecommitdiff
path: root/src/app/components/hello/root.zig
blob: 55bf2e60f9e42fe903250fd6ee24c9a43c16e804 (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
25
26
27
28
const std = @import("std");
const z = @import("z");

const Self = @This();

pub const component: z.Component = .{
    .name = "hello",
    .html = .native(
        .div,
        .{ .onclick = "@clicked" },
        .content("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});
}