diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-09 09:40:06 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-09 09:40:06 +0200 |
| commit | d0f90548f5edb32225af4a1f79413a2a56d186c8 (patch) | |
| tree | 336a1b43d34518d06bdfdbdfcf6985f95c502038 /src/app/components/navbutton | |
| parent | e7aebc79968816ea5037c332df7a3534d533b144 (diff) | |
app: add navbutton
Diffstat (limited to 'src/app/components/navbutton')
| -rw-r--r-- | src/app/components/navbutton/index.css | 46 | ||||
| -rw-r--r-- | src/app/components/navbutton/index.html | 12 | ||||
| -rw-r--r-- | src/app/components/navbutton/root.zig | 21 |
3 files changed, 75 insertions, 4 deletions
diff --git a/src/app/components/navbutton/index.css b/src/app/components/navbutton/index.css index bf1b4ee..4c1a138 100644 --- a/src/app/components/navbutton/index.css +++ b/src/app/components/navbutton/index.css @@ -1,9 +1,51 @@ -#button { +:host { position: absolute; bottom: 10px; right: 10px; + --items-count: 2; +} + +#button { + position: relative; + width: 50px; + height: 50px; + background: var(--secondary); + border-radius: 50px; + cursor: pointer; + color: var(--color); + transition: 0.2s ease height; + display: grid; + justify-content: center; + align-content: end; + overflow: hidden; +} + +#button.open { + height: calc(50px * (var(--items-count) + 1)); +} + +#menu { width: 50px; height: 50px; + background: red; + border-radius: 50px; + display: grid; background: var(--primary); - border-radius: 100%; +} + +.icon { + margin: auto; + width: fit-content; + height: fit-content; + padding-top: 4px; +} + +.items { + height: calc(50px * var(--items-count)); + display: grid; + grid-template-rows: repeat(var(--items-count), auto); +} + +.item { + margin: auto; } diff --git a/src/app/components/navbutton/index.html b/src/app/components/navbutton/index.html index ab23160..f2c9ff8 100644 --- a/src/app/components/navbutton/index.html +++ b/src/app/components/navbutton/index.html @@ -1,2 +1,12 @@ -<div id="button"> +<div id="button" onclick="@open"> + <div class="items"> + <div class="item"><icon-upload></icon-upload></div> + <div class="item"><icon-settings></icon-settings></div> + </div> + + <div id="menu"> + <div class="icon"> + <icon-menu></icon-menu> + </div> + </div> </div> diff --git a/src/app/components/navbutton/root.zig b/src/app/components/navbutton/root.zig index 0040c9d..1078924 100644 --- a/src/app/components/navbutton/root.zig +++ b/src/app/components/navbutton/root.zig @@ -1,3 +1,4 @@ +const std = @import("std"); const z = @import("z"); const Self = @This(); @@ -10,7 +11,25 @@ pub const component: z.Component = .{ }; element: *z.Object, +shadow_root: *z.Object, +button: struct { + classList: *z.Object, +}, + +pub fn init(self: *Self, element: *z.Object) !void { + var env: z.Env = .default; + defer env.deinit(); -pub fn init(self: *Self, element: *z.Object) void { self.element = element; + self.shadow_root = try self.element.get(&env, "shadowRoot").await(&env, .object); + const button = try self.shadow_root.call(&env, "getElementById", .{"button"}).await(&env, .object); + defer _ = button.free(&env); + self.button.classList = try button.get(&env, "classList").await(&env, .object); +} + +pub fn open(self: *Self) !void { + var env: z.Env = .default; + defer env.deinit(); + + _ = self.button.classList.call(&env, "toggle", .{"open"}); } |