aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-10-08 06:22:41 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-10-08 06:22:41 +0200
commit0a2f6f8cc48258fca60df2f193790b2d94a9d0f6 (patch)
treeebc38d94f1e4d9e5c2cb30a26db5d4ec6c9b38b5 /src/app
parent4e86e3e18e9b43e442a35361ac82b30dd6c0103a (diff)
wasm add resources tracking
Diffstat (limited to 'src/app')
-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
-rw-r--r--src/app/root.zig1
-rw-r--r--src/app/theme.css17
5 files changed, 45 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});
}
diff --git a/src/app/root.zig b/src/app/root.zig
index f587cfb..eefc374 100644
--- a/src/app/root.zig
+++ b/src/app/root.zig
@@ -17,6 +17,7 @@ pub const app: z.App(.{
@import("components/hello/root.zig").component,
},
.body = .native(.@"app-hello", .{}, .content("")),
+ .theme = @embedFile("theme.css"),
}) = .init;
comptime {
diff --git a/src/app/theme.css b/src/app/theme.css
new file mode 100644
index 0000000..de933dc
--- /dev/null
+++ b/src/app/theme.css
@@ -0,0 +1,17 @@
+
+:root {
+ --background: #282828;
+ --color: #ebdbb2;
+}
+
+body {
+ width: 100vw;
+ height: 100vh;
+ background: #202020;
+ margin: 0;
+ overflow: hidden;
+}
+
+div {
+ background: var(--background);
+}