diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-26 15:45:33 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-26 15:45:33 +0100 |
| commit | feeedb0bf31314b182e7bbc135182f6e0bc859b2 (patch) | |
| tree | 163948cd874729925c2bf57d0927619065d2322d /src/app/components/image/root.zig | |
| parent | 91d9b6992ac0ebee13704a3faefa8fd41a00075e (diff) | |
update zilch
Diffstat (limited to 'src/app/components/image/root.zig')
| -rw-r--r-- | src/app/components/image/root.zig | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/app/components/image/root.zig b/src/app/components/image/root.zig index c9aeef4..1d46d30 100644 --- a/src/app/components/image/root.zig +++ b/src/app/components/image/root.zig @@ -1,3 +1,4 @@ +const std = @import("std"); const zilch = @import("zilch"); pub const component: zilch.Component = .build(.{ @@ -10,9 +11,22 @@ pub const component: zilch.Component = .build(.{ const Self = @This(); element: *zilch.Object, +style: *zilch.Object, pub fn init(self: *Self, element: *zilch.Object) !void { + var env: zilch.Env = .default; + defer env.deinit(); + self.element = element; + self.style = blk: { + var style = self.element.get(&env, "style"); + break :blk try style.await(&env, *zilch.Object); + }; } -pub const connect = component.connect; +pub fn setUrl(self: *Self, env: *zilch.Env, url: []const u8) zilch.Env.Future(void) { + var buffer: [1024]u8 = undefined; + var writer: std.Io.Writer = .fixed(&buffer); + writer.print("url({s})", .{url}) catch unreachable; + return .fromAny(self.style.call(env, "setProperty", .{"--image", writer.buffered()})); +} |