diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/app/components/icons/index.css | 0 | ||||
| -rw-r--r-- | src/app/components/icons/menu.svg | 3 | ||||
| -rw-r--r-- | src/app/components/icons/root.zig | 21 | ||||
| -rw-r--r-- | src/app/components/icons/settings.svg | 4 | ||||
| -rw-r--r-- | src/app/components/icons/upload.svg | 4 | ||||
| -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 | ||||
| -rw-r--r-- | src/app/components/root.zig | 6 | ||||
| -rw-r--r-- | src/app/theme.css | 4 | ||||
| -rw-r--r-- | src/z/App/root.zig | 2 | ||||
| -rw-r--r-- | src/z/html/parser.zig | 1 |
12 files changed, 115 insertions, 9 deletions
diff --git a/src/app/components/icons/index.css b/src/app/components/icons/index.css new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/app/components/icons/index.css diff --git a/src/app/components/icons/menu.svg b/src/app/components/icons/menu.svg new file mode 100644 index 0000000..df05f82 --- /dev/null +++ b/src/app/components/icons/menu.svg @@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-three-dots-vertical" viewBox="0 0 16 16"> + <path d="M9.5 13a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0"></path> +</svg> diff --git a/src/app/components/icons/root.zig b/src/app/components/icons/root.zig new file mode 100644 index 0000000..a2b0fa6 --- /dev/null +++ b/src/app/components/icons/root.zig @@ -0,0 +1,21 @@ +const z = @import("z"); + +pub const icons: []const z.Component = &.{ + icon("menu"), + icon("upload"), + icon("settings"), +}; + +const Icon = struct { + pub fn init(_: *@This(), _: *z.Object) void {} +}; + +pub fn icon(name: []const u8) z.Component { + return .{ + .namespace = "icon", + .name = name, + .html = .parse(@embedFile(name ++ ".svg")), + .css = @embedFile("index.css"), + .link = Icon, + }; +} diff --git a/src/app/components/icons/settings.svg b/src/app/components/icons/settings.svg new file mode 100644 index 0000000..783f55f --- /dev/null +++ b/src/app/components/icons/settings.svg @@ -0,0 +1,4 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-gear" viewBox="0 0 16 16"> + <path d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492M5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0"></path> + <path d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.377l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115z"></path> +</svg> diff --git a/src/app/components/icons/upload.svg b/src/app/components/icons/upload.svg new file mode 100644 index 0000000..5187f80 --- /dev/null +++ b/src/app/components/icons/upload.svg @@ -0,0 +1,4 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cloud-arrow-up" viewBox="0 0 16 16"> + <path fill-rule="evenodd" d="M7.646 5.146a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1-.708.708L8.5 6.707V10.5a.5.5 0 0 1-1 0V6.707L6.354 7.854a.5.5 0 1 1-.708-.708z"></path> + <path d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383m.653.757c-.757.653-1.153 1.44-1.153 2.056v.448l-.445.049C2.064 6.805 1 7.952 1 9.318 1 10.785 2.23 12 3.781 12h8.906C13.98 12 15 10.988 15 9.773c0-1.216-1.02-2.228-2.313-2.228h-.5v-.5C12.188 4.825 10.328 3 8 3a4.53 4.53 0 0 0-2.941 1.1z"></path> +</svg> 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"}); } diff --git a/src/app/components/root.zig b/src/app/components/root.zig index 32ed436..934279f 100644 --- a/src/app/components/root.zig +++ b/src/app/components/root.zig @@ -1,5 +1,7 @@ const z = @import("z"); -pub const components: []const z.Component = &.{ +const icons = @import("icons/root.zig").icons; + +pub const components: []const z.Component = &[_]z.Component{ @import("navbutton/root.zig").component, -}; +} ++ icons; diff --git a/src/app/theme.css b/src/app/theme.css index 4471dbe..00a1e92 100644 --- a/src/app/theme.css +++ b/src/app/theme.css @@ -1,8 +1,8 @@ :root { - --background: #282828; - --color: #ebdbb2; + --color: #efefef; --primary: #726eff; + --secondary: #39378a; } body { diff --git a/src/z/App/root.zig b/src/z/App/root.zig index b8ca529..8681c4a 100644 --- a/src/z/App/root.zig +++ b/src/z/App/root.zig @@ -68,7 +68,7 @@ pub fn App(comptime options: Options) type { .node("title", .{}, &.{.text(options.name)}), .void("meta", .{ .name = "viewport", - .content = "width=device-width, initial-scale=1.0", + .content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0", }), .node("style", .{}, &.{.text(options.theme)}), }), diff --git a/src/z/html/parser.zig b/src/z/html/parser.zig index c85cc16..38b28bb 100644 --- a/src/z/html/parser.zig +++ b/src/z/html/parser.zig @@ -24,6 +24,7 @@ const void_elements: std.StaticStringMap(void) = .initComptime(.{ }); pub fn fragment(buffer: []const u8) Fragment { + @setEvalBranchQuota(buffer.len * 1000); var elements: []const Element = &.{}; var buf = buffer; |