aboutsummaryrefslogtreecommitdiff
path: root/src/app/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/components')
-rw-r--r--src/app/components/hello/index.css12
-rw-r--r--src/app/components/hello/index.html2
-rw-r--r--src/app/components/hello/root.zig15
3 files changed, 27 insertions, 2 deletions
diff --git a/src/app/components/hello/index.css b/src/app/components/hello/index.css
index e69de29..7b316cb 100644
--- a/src/app/components/hello/index.css
+++ b/src/app/components/hello/index.css
@@ -0,0 +1,12 @@
+div {
+ font-family: 'sans-serif';
+ cursor: pointer;
+ user-select: none;
+ background: var(--background);
+ color: var(--color);
+ display: block;
+ width: fit-content;
+ padding: 10px 10px;
+ border-radius: 4px;
+ margin: 4px;
+}
diff --git a/src/app/components/hello/index.html b/src/app/components/hello/index.html
index e69de29..8b6b6a4 100644
--- a/src/app/components/hello/index.html
+++ b/src/app/components/hello/index.html
@@ -0,0 +1,2 @@
+<div onclick="@clicked">
+</div>
diff --git a/src/app/components/hello/root.zig b/src/app/components/hello/root.zig
index 6f68550..55bf2e6 100644
--- a/src/app/components/hello/root.zig
+++ b/src/app/components/hello/root.zig
@@ -1,6 +1,8 @@
const std = @import("std");
const z = @import("z");
+const Self = @This();
+
pub const component: z.Component = .{
.name = "hello",
.html = .native(
@@ -12,6 +14,15 @@ pub const component: z.Component = .{
.link = @This(),
};
-pub fn clicked() void {
- z.log.js.debug("hi");
+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});
}