aboutsummaryrefslogtreecommitdiff
path: root/src/web
diff options
context:
space:
mode:
Diffstat (limited to 'src/web')
-rw-r--r--src/web/component/image/index.css0
-rw-r--r--src/web/component/image/index.html2
-rw-r--r--src/web/component/image/index.js1
-rw-r--r--src/web/component/image/root.zig8
-rw-r--r--src/web/component/root.zig6
-rw-r--r--src/web/component/timeline/index.css18
-rw-r--r--src/web/component/timeline/index.html2
-rw-r--r--src/web/component/timeline/index.js96
-rw-r--r--src/web/component/timeline/root.zig8
-rw-r--r--src/web/index.css20
-rw-r--r--src/web/index.html2
-rw-r--r--src/web/index.js0
-rw-r--r--src/web/pinch.js82
-rw-r--r--src/web/root.zig27
14 files changed, 0 insertions, 272 deletions
diff --git a/src/web/component/image/index.css b/src/web/component/image/index.css
deleted file mode 100644
index e69de29..0000000
--- a/src/web/component/image/index.css
+++ /dev/null
diff --git a/src/web/component/image/index.html b/src/web/component/image/index.html
deleted file mode 100644
index 918c5df..0000000
--- a/src/web/component/image/index.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<div id="image">
-</div>
diff --git a/src/web/component/image/index.js b/src/web/component/image/index.js
deleted file mode 100644
index d88023d..0000000
--- a/src/web/component/image/index.js
+++ /dev/null
@@ -1 +0,0 @@
-console.log(Z.by_selector('div'));
diff --git a/src/web/component/image/root.zig b/src/web/component/image/root.zig
deleted file mode 100644
index 7c8ec77..0000000
--- a/src/web/component/image/root.zig
+++ /dev/null
@@ -1,8 +0,0 @@
-const z = @import("z");
-
-pub const component: z.Component = .{
- .name = .image,
- .body = @embedFile("index.html"),
- .style = @embedFile("index.css"),
- .script = @embedFile("index.js"),
-};
diff --git a/src/web/component/root.zig b/src/web/component/root.zig
deleted file mode 100644
index 226f3f7..0000000
--- a/src/web/component/root.zig
+++ /dev/null
@@ -1,6 +0,0 @@
-const z = @import("z");
-
-pub const components: []const z.Component = &.{
- @import("image/root.zig").component,
- @import("timeline/root.zig").component,
-};
diff --git a/src/web/component/timeline/index.css b/src/web/component/timeline/index.css
deleted file mode 100644
index 6d58f59..0000000
--- a/src/web/component/timeline/index.css
+++ /dev/null
@@ -1,18 +0,0 @@
-#container {
- width: 100%;
- display: inline-grid;
- gap: 0px;
- overflow-y: auto;
-}
-
-.image {
- text-align: center;
- align-content: center;
- font-weight: bold;
- font-size: 0.5em;
- overflow: hidden;
-}
-
-#container.tiling .image {
- aspect-ratio: 1 / 1 !important;
-}
diff --git a/src/web/component/timeline/index.html b/src/web/component/timeline/index.html
deleted file mode 100644
index 41d4617..0000000
--- a/src/web/component/timeline/index.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<div id="container">
-</div>
diff --git a/src/web/component/timeline/index.js b/src/web/component/timeline/index.js
deleted file mode 100644
index 81322c6..0000000
--- a/src/web/component/timeline/index.js
+++ /dev/null
@@ -1,96 +0,0 @@
-const container = Z.by_id('container');
-
-function getRandomColor() {
- var letters = '0123456789ABCDEF';
- var color = '#';
- for (var i = 0; i < 6; i++) {
- color += letters[Math.floor(Math.random() * 16)];
- }
- return color;
-}
-
-for (let i = 0; i < 10000; ++i) {
- container.appendChild(Z.native('div', {
- innerText: i,
- className: 'image',
- style: {
- background: getRandomColor(),
- aspectRatio: '1 / ' + (Math.random() + 0.5),
- },
- }));
-}
-
-const zoom = new (class {
- constructor() {
- this.committed = 5;
- container.style.gridTemplateColumns = `repeat(5, 1fr)`;
- container.classList.toggle('tiling', this.committed != 1);
- this.por = { x: 0, y: 0 };
- this.eor = null;
- this.y_offset = 0;
- this.distance = 0;
- }
-
- update(distance, point) {
- const scale = distance / this.distance;
- const x = point.x - this.por.x;
- container.style.transform = `translate(${x}px, 0px) scale(${scale})`;
- }
-
- set reference({ point, distance }) {
- const rect = container.getClientRects()[0];
-
- this.por = { x: point.x, y: point.y - rect.y };
- container.style.transformOrigin = `${this.por.x}px ${this.por.y}px`;
- this.eor = Z.document.shadowRoot.elementFromPoint(point.x, point.y);
-
- const box_rect = this.eor.getBoundingClientRect();
- this.y_offset = box_rect.y;
-
- this.distance = distance;
- }
-
- commit(distance) {
- const scale = distance / this.distance;
- this.committed = Math.round(Math.min(Math.max(this.committed / scale, 1), 20));
- container.style.gridTemplateColumns = `repeat(${this.committed}, 1fr)`;
- container.classList.toggle('tiling', this.committed != 1);
- container.style.transform = 'scale(1)';
-
- const rect = this.eor.getBoundingClientRect();
-
- Z.document.scrollBy({
- top: rect.y - this.y_offset,
- behavior: 'instant',
- });
- }
-
- increase_line_by(n) {
- this.committed = Math.min(Math.max(this.committed + n, 1), 20);
- container.style.gridTemplateColumns = `repeat(${this.committed}, 1fr)`;
- container.classList.toggle('tiling', this.committed != 1);
- container.style.transform = 'scale(1)';
- }
-});
-
-Z.document.onwheel = (event) => {
- if (!event.ctrlKey) {
- return;
- }
- event.preventDefault();
- zoom.increase_line_by(event.wheelDeltaY / 120);
-};
-
-const pinch = new Pinch(Z.document);
-
-pinch.onstart = (event) => {
- zoom.reference = event;
-};
-
-pinch.onpinch = (event) => {
- zoom.update(event.distance, event.point);
-};
-
-pinch.onfinish = (event) => {
- zoom.commit(event.distance);
-};
diff --git a/src/web/component/timeline/root.zig b/src/web/component/timeline/root.zig
deleted file mode 100644
index 9faa40e..0000000
--- a/src/web/component/timeline/root.zig
+++ /dev/null
@@ -1,8 +0,0 @@
-const z = @import("z");
-
-pub const component: z.Component = .{
- .name = .timeline,
- .body = @embedFile("index.html"),
- .style = @embedFile("index.css"),
- .script = @embedFile("index.js"),
-};
diff --git a/src/web/index.css b/src/web/index.css
deleted file mode 100644
index 6b1927f..0000000
--- a/src/web/index.css
+++ /dev/null
@@ -1,20 +0,0 @@
-html {
- height: 100vh;
- width: 100vw;
-}
-
-body {
- padding: 0;
- margin: 0;
- width: 100vw;
- height: 100vh;
- overflow: hidden;
- touch-action: pan-y;
-}
-
-#timeline {
- display: block;
- height: 100vh;
- overflow-y: auto;
- background: gray;
-}
diff --git a/src/web/index.html b/src/web/index.html
deleted file mode 100644
index d2bc6fe..0000000
--- a/src/web/index.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<z-component type="timeline" id="timeline">
-</z-component>
diff --git a/src/web/index.js b/src/web/index.js
deleted file mode 100644
index e69de29..0000000
--- a/src/web/index.js
+++ /dev/null
diff --git a/src/web/pinch.js b/src/web/pinch.js
deleted file mode 100644
index bb06b0d..0000000
--- a/src/web/pinch.js
+++ /dev/null
@@ -1,82 +0,0 @@
-class Pinch {
- constructor(element) {
- this.event_cache = [];
- this.onpinch = () => {};
- this.onfinish = () => {};
- this.onstart = () => {};
-
- element.onpointerdown = (e) => this.pointer_down_handler(e);
- element.onpointermove = (e) => this.pointer_move_handler(e);
- element.onpointerup = (e) => this.pointer_up_handler(e);
- element.onpointercancel = (e) => this.pointer_up_handler(e);
- element.onpointerout = (e) => this.pointer_up_handler(e);
- element.onpointerleave = (e) => this.pointer_up_handler(e);
- }
-
- pointer_down_handler(event) {
- this.event_cache.push(event);
-
- if (this.event_cache.length === 2) {
- const diff = Math.hypot(
- this.event_cache[0].clientX - this.event_cache[1].clientX,
- this.event_cache[0].clientY - this.event_cache[1].clientY,
- );
-
- const point = {
- x: (this.event_cache[0].clientX + this.event_cache[1].clientX) / 2,
- y: (this.event_cache[0].clientY + this.event_cache[1].clientY) / 2,
- };
-
- this.onstart({ point, distance: diff });
- }
- }
-
- pointer_move_handler(event) {
- const index = this.event_cache.findIndex(
- (cached) => cached.pointerId == event.pointerId,
- );
- this.event_cache[index] = event;
-
- if (this.event_cache.length === 2) {
- const diff = Math.hypot(
- this.event_cache[0].clientX - this.event_cache[1].clientX,
- this.event_cache[0].clientY - this.event_cache[1].clientY,
- );
-
- const point = {
- x: (this.event_cache[0].clientX + this.event_cache[1].clientX) / 2,
- y: (this.event_cache[0].clientY + this.event_cache[1].clientY) / 2,
- };
-
- this.onpinch({ distance: diff, point });
- }
- }
-
- pointer_up_handler(event) {
- let cleanup = false;
- const ev = {};
-
- if (this.event_cache.length === 2) {
- ev['distance'] = Math.hypot(
- this.event_cache[0].clientX - this.event_cache[1].clientX,
- this.event_cache[0].clientY - this.event_cache[1].clientY,
- );
-
- ev['point'] = {
- x: (this.event_cache[0].clientX + this.event_cache[1].clientX) / 2,
- y: (this.event_cache[0].clientY + this.event_cache[1].clientY) / 2,
- };
-
- cleanup = true;
- }
-
- const index = this.event_cache.findIndex(
- (cached) => cached.pointerId === event.pointerId,
- );
- this.event_cache.splice(index, 1);
-
- if (cleanup) {
- this.onfinish(ev);
- }
- }
-}
diff --git a/src/web/root.zig b/src/web/root.zig
deleted file mode 100644
index c9c1b08..0000000
--- a/src/web/root.zig
+++ /dev/null
@@ -1,27 +0,0 @@
-const z = @import("z");
-const html = @import("html");
-const http = @import("http");
-const Static = http.handler.Static;
-
-const components = @import("component/root.zig").components;
-
-const document: html.Element = .native(.html, .{}, .children(&.{
- .native(.head, .{}, .children(&.{
- .native(.title, .{}, .content("Memora")),
- .native(.meta, .{
- .name = "viewport",
- .content = "width=device-width, initial-scale=1.0",
- }, .void),
- z.script.load(@embedFile("pinch.js")),
- z.style.load(@embedFile("index.css")),
- z.env(components),
- })),
- .native(.body, .{}, .children(&.{
- z.html.load(@embedFile("index.html")),
- })),
-}));
-
-pub const interfaces: []const http.handler.Interface = &.{
- Static(.index, document.toDocument()).interface(),
-};
-