aboutsummaryrefslogtreecommitdiff
path: root/src/app/components/navbutton
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/components/navbutton')
-rw-r--r--src/app/components/navbutton/index.css63
-rw-r--r--src/app/components/navbutton/index.html12
-rw-r--r--src/app/components/navbutton/root.zig58
3 files changed, 133 insertions, 0 deletions
diff --git a/src/app/components/navbutton/index.css b/src/app/components/navbutton/index.css
new file mode 100644
index 0000000..6909464
--- /dev/null
+++ b/src/app/components/navbutton/index.css
@@ -0,0 +1,63 @@
+: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);
+}
+
+.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;
+ width: 40px;
+ height: 40px;
+ border-radius: 40px;
+ display: grid;
+}
+
+.item * {
+ margin: auto;
+}
+
+.item:hover {
+ background: #5f5e9c;
+}
diff --git a/src/app/components/navbutton/index.html b/src/app/components/navbutton/index.html
new file mode 100644
index 0000000..f2c9ff8
--- /dev/null
+++ b/src/app/components/navbutton/index.html
@@ -0,0 +1,12 @@
+<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
new file mode 100644
index 0000000..a512d1d
--- /dev/null
+++ b/src/app/components/navbutton/root.zig
@@ -0,0 +1,58 @@
+const std = @import("std");
+const app = @import("root").app;
+const zilch = @import("zilch");
+const Object = zilch.Object;
+const Promise = zilch.Promise;
+
+const Self = @This();
+
+pub const component: zilch.Component = .build(.{
+ .name = "navbutton",
+ .html = .parse(@embedFile("index.html")),
+ .css = @embedFile("index.css"),
+ .link = @This(),
+});
+
+element: *zilch.Object,
+shadow_root: *zilch.Object,
+button: struct {
+ classList: *zilch.Object,
+},
+
+pub fn init(self: *Self, element: *Object) !void {
+ var env: zilch.Env = .default;
+ defer env.deinit();
+
+ self.element = element;
+
+ var shadow_root = self.element.get(&env, "shadowRoot");
+
+ var class_list = cls: {
+ var button = Object.call(shadow_root, &env, "getElementById", .{"button"});
+ defer button.ignore(&env);
+ defer _ = Object.free(button, &env);
+
+ break :cls Object.get(button, &env, "classList");
+ };
+
+ self.button.classList = try class_list.await(&env, *Object);
+
+ self.shadow_root = try shadow_root.await(&env, *Object);
+}
+
+pub fn deinit(self: *Self) !void {
+ var env: zilch.Env = .default;
+ defer env.deinit();
+
+ _ = self.element.free(&env);
+ _ = self.shadow_root.free(&env);
+ _ = self.button.classList.free(&env);
+}
+
+pub fn open(self: *Self) !void {
+ var env: zilch.Env = .default;
+ defer env.deinit();
+
+ var toggle_call = self.button.classList.call(&env, "toggle", .{"open"});
+ toggle_call.ignore(&env);
+}