Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
workbenchthis machine
Phone portrait: the 3D model fills the space under the camera and the status strip, and both are always visible together #303
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
quill/arm:quill/274-phone-portrait-the-3d-model-fills-the-sp → main 1 commit fork
6 files
changed +248
−34
Software/README.md +3 −1
| @@ -336,7 +336,9 @@ stream) are only accepted from the app's own page, so another site can't | ||
| 336 | 336 | drive the arm through it. |
| 337 | 337 | |
| 338 | 338 | **On a phone held upright** the sheet's tabs give way to a bottom bar: **Drive** |
| 339 | (the view, and the controls on your turn), **Queue**, **Chat**, **Mod** (the | |
| 339 | (the camera on top at 16:9, the status strip, then the 3D model down to the bar, | |
| 340 | or down to the controls on your turn; the camera buttons pick which camera is on | |
| 341 | top and the model stays), **Queue**, **Chat**, **Mod** (the | |
| 340 | 342 | owner only) and **Machine**, one panel at a time. The tab is kept in the URL |
| 341 | 343 | hash (`#drive`, `#queue`, `#chat`, `#mod`, `#machine`); an unknown one, or |
| 342 | 344 | `#mod` for anyone but the owner, opens Drive. The bar is drawn once its small |
Software/so101/src/portrait-layout.test.ts added +191
| @@ -0,0 +1,191 @@ | ||
| 1 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 2 | import { mkdtempSync } from "node:fs"; | |
| 3 | import { tmpdir } from "node:os"; | |
| 4 | import { join } from "node:path"; | |
| 5 | import { FeetechBus } from "./bus.ts"; | |
| 6 | import { FakeBus } from "./fake-bus.ts"; | |
| 7 | import { startServer, type RunningServer } from "./server.ts"; | |
| 8 | ||
| 9 | // A phone held upright, read rather than rendered (there is no browser here): ui/mobile.css gives the shell's rows for | |
| 10 | // each state, which this resolves at real phone sizes into boxes for the camera, the strip, the model and the tab bar. | |
| 11 | ||
| 12 | type Rule = { selector: string; body: string; media: string }; | |
| 13 | ||
| 14 | /** Every rule, with the @media query it sits in ("" for none). */ | |
| 15 | function flatRules(css: string): Rule[] { | |
| 16 | const rules: Rule[] = []; | |
| 17 | const walk = (src: string, media: string) => { | |
| 18 | let i = 0; | |
| 19 | while (i < src.length) { | |
| 20 | const open = src.indexOf("{", i); | |
| 21 | if (open < 0) break; | |
| 22 | let depth = 1; | |
| 23 | let j = open + 1; | |
| 24 | for (; j < src.length && depth; j++) depth += src[j] === "{" ? 1 : src[j] === "}" ? -1 : 0; | |
| 25 | const head = src.slice(i, open).trim(); | |
| 26 | const inner = src.slice(open + 1, j - 1); | |
| 27 | if (head.startsWith("@")) walk(inner, head); | |
| 28 | else rules.push({ selector: head, body: inner, media }); | |
| 29 | i = j; | |
| 30 | } | |
| 31 | }; | |
| 32 | walk(css.replace(/\/\*[\s\S]*?\*\//g, ""), ""); | |
| 33 | return rules; | |
| 34 | } | |
| 35 | ||
| 36 | /** A declaration's value in the last rule whose selector list holds exactly `selector`. */ | |
| 37 | function decl(rules: Rule[], selector: string, prop: string): string | undefined { | |
| 38 | let value: string | undefined; | |
| 39 | for (const r of rules) { | |
| 40 | if (!r.selector.split(",").some((s) => s.trim() === selector)) continue; | |
| 41 | for (const d of r.body.split(/;(?![^(]*\))/)) { | |
| 42 | const at = d.indexOf(":"); | |
| 43 | if (at > 0 && d.slice(0, at).trim() === prop) value = d.slice(at + 1).trim(); | |
| 44 | } | |
| 45 | } | |
| 46 | return value; | |
| 47 | } | |
| 48 | ||
| 49 | /** Split a track list on the spaces outside parentheses. */ | |
| 50 | function tracks(list: string): string[] { | |
| 51 | const out: string[] = []; | |
| 52 | let depth = 0, cur = ""; | |
| 53 | for (const ch of list) { | |
| 54 | depth += ch === "(" ? 1 : ch === ")" ? -1 : 0; | |
| 55 | if (ch === " " && depth === 0) { if (cur) out.push(cur); cur = ""; } else cur += ch; | |
| 56 | } | |
| 57 | if (cur) out.push(cur); | |
| 58 | return out; | |
| 59 | } | |
| 60 | ||
| 61 | /** A length in px: calc() of px and vw terms, with every inset (env, --safe-*) zero as on a phone without a notch. */ | |
| 62 | function px(value: string, vw: number, vars: Record<string, string>): number { | |
| 63 | let v = value.replace(/var\((--[\w-]+)\)/g, (_, n: string) => (n.startsWith("--safe") ? "0px" : `(${vars[n] ?? "NaN"})`)); | |
| 64 | v = v.replace(/env\([^)]*\)/g, "0px").replace(/calc\(/g, "("); | |
| 65 | v = v.replace(/(-?[\d.]+)(px|vw)/g, (_, n: string, u: string) => String(u === "vw" ? (Number(n) * vw) / 100 : Number(n))); | |
| 66 | return arithmetic(v); | |
| 67 | } | |
| 68 | ||
| 69 | /** + - * / and parentheses over numbers: what is left of a calc() once its units are px. */ | |
| 70 | function arithmetic(src: string): number { | |
| 71 | const tokens = src.match(/[\d.]+|[()+\-*/]/g) ?? []; | |
| 72 | expect(tokens.join("")).toBe(src.replace(/\s+/g, "")); | |
| 73 | let i = 0; | |
| 74 | const atom = (): number => { | |
| 75 | const t = tokens[i++]; | |
| 76 | if (t === "(") { const v = sum(); i++; return v; } | |
| 77 | if (t === "-") return -atom(); | |
| 78 | return Number(t); | |
| 79 | }; | |
| 80 | const product = (): number => { let v = atom(); while (tokens[i] === "*" || tokens[i] === "/") v = tokens[i++] === "*" ? v * atom() : v / atom(); return v; }; | |
| 81 | const sum = (): number => { let v = product(); while (tokens[i] === "+" || tokens[i] === "-") v = tokens[i++] === "+" ? v + product() : v - product(); return v; }; | |
| 82 | return sum(); | |
| 83 | } | |
| 84 | ||
| 85 | /** The rows' tops and heights for a viewport: `auto` rows take the height given for their area, 1fr rows share the rest. */ | |
| 86 | function layout(rows: string, areas: string[], size: { w: number; h: number }, autos: Record<string, number>, vars: Record<string, string>) { | |
| 87 | const list = tracks(rows); | |
| 88 | expect(list.length).toBe(areas.length); | |
| 89 | const fixed = list.map((t, i) => (t === "auto" ? autos[areas[i]!]! : t.includes("fr") ? null : px(t, size.w, vars))); | |
| 90 | const frs = fixed.filter((f) => f === null).length; | |
| 91 | const rest = size.h - fixed.reduce<number>((s, f) => s + (f ?? 0), 0); | |
| 92 | let top = 0; | |
| 93 | const box: Record<string, { top: number; bottom: number; height: number }> = {}; | |
| 94 | list.forEach((_, i) => { | |
| 95 | const height = fixed[i] ?? Math.max(0, rest / frs); | |
| 96 | box[areas[i]!] = { top, bottom: top + height, height }; | |
| 97 | top += height; | |
| 98 | }); | |
| 99 | return { box, total: top }; | |
| 100 | } | |
| 101 | ||
| 102 | const hides = (body: string) => /(^|;)\s*display\s*:\s*none\b|(^|;)\s*visibility\s*:\s*(hidden|collapse)\b/i.test(body); | |
| 103 | const portrait = (media: string) => /orientation:\s*portrait/.test(media); | |
| 104 | ||
| 105 | let server: RunningServer; | |
| 106 | let html: string; | |
| 107 | let mobile: Rule[]; | |
| 108 | let all: Rule[]; | |
| 109 | ||
| 110 | beforeAll(async () => { | |
| 111 | const dataDir = mkdtempSync(join(tmpdir(), "so101-portrait-")); | |
| 112 | server = await startServer(new FeetechBus(new FakeBus([1, 2, 6])), { host: "127.0.0.1", port: 0, ids: [1, 2, 6], posesFile: join(dataDir, "poses.json"), watchdogMs: 60 }); | |
| 113 | const base = `http://127.0.0.1:${server.port}`; | |
| 114 | html = await (await fetch(`${base}/`)).text(); | |
| 115 | const href = (name: string) => new RegExp(`href="(/ui/[^"]+/${name})"`).exec(html)?.[1]; | |
| 116 | expect(href("mobile.css")).toBeDefined(); | |
| 117 | const mobileCss = await (await fetch(base + href("mobile.css")!)).text(); | |
| 118 | const tabsCss = await (await fetch(base + href("tabs.css")!)).text(); | |
| 119 | const inline = [...html.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((m) => m[1]!).join("\n"); | |
| 120 | mobile = flatRules(mobileCss); | |
| 121 | all = [...flatRules(inline), ...flatRules(tabsCss), ...mobile]; | |
| 122 | }); | |
| 123 | afterAll(() => Promise.race([server.close(), new Promise((r) => setTimeout(r, 500))])); | |
| 124 | ||
| 125 | const SIZES = [{ w: 390, h: 844 }, { w: 412, h: 915 }]; | |
| 126 | const STRIP = 64; // #strip's min-height: one line of who drives and the STOP | |
| 127 | ||
| 128 | describe("a phone held upright", () => { | |
| 129 | test("ui/mobile.css is linked for phone portrait only, and the page stacks its views under that same query", () => { | |
| 130 | const link = /<link rel="stylesheet" href="\/ui\/[^"]+\/mobile\.css" media="([^"]+)">/.exec(html); | |
| 131 | expect(link?.[1]).toBe("(max-width: 600px) and (orientation: portrait)"); | |
| 132 | expect(html).toContain(`const stacked = matchMedia("${link![1]}")`); | |
| 133 | expect(mobile.every((r) => r.media === "@media (max-width: 600px) and (orientation: portrait)")).toBe(true); | |
| 134 | }); | |
| 135 | ||
| 136 | test("the view spans the camera, strip and model rows; the camera pane takes the first, the model the third", () => { | |
| 137 | expect(decl(mobile, "#app", "grid-row")).toBe("view-start / model-end"); | |
| 138 | expect(decl(mobile, "#app", "grid-template-rows")).toBe("subgrid"); | |
| 139 | expect(decl(mobile, "#stage", "display")).toBe("contents"); | |
| 140 | expect(decl(mobile, "#stage > .pane", "grid-row")).toBe("1"); | |
| 141 | expect(decl(mobile, "#stage > #pane3", "grid-row")).toBe("3"); | |
| 142 | expect(decl(mobile, "#strip", "z-index")).toBe("1"); // over the view's middle row | |
| 143 | expect(html).toMatch(/<div id="stage">\s*<div class="pane" id="pane3"/); // the model is a pane of the view | |
| 144 | }); | |
| 145 | ||
| 146 | for (const size of SIZES) { | |
| 147 | for (const driving of [false, true]) { | |
| 148 | test(`${size.w}x${size.h}, Drive tab, ${driving ? "your turn" : "watching"}: camera 16:9 full width on top, the model under the strip, no overlap`, () => { | |
| 149 | const areas = tracks(decl(mobile, "html #shell.docked", "grid-template-areas")!.replace(/"\s+"/g, '" "')).map((a) => a.replace(/"/g, "")); | |
| 150 | expect(areas).toEqual(["view", "strip", "model", "sheet", "dock"]); | |
| 151 | const rows = decl(mobile, `html #shell.docked[data-panel="drive"]${driving ? ".mayDrive" : ":not(.mayDrive)"}`, "grid-template-rows")!; | |
| 152 | const vars = { "--cam": decl(mobile, "#shell", "--cam")! }; | |
| 153 | const cap = decl(mobile, 'html #shell.docked[data-panel="drive"].mayDrive #sheet', "max-height")!; | |
| 154 | expect(cap).toMatch(/^[\d.]+svh$/); | |
| 155 | const sheet = driving ? (parseFloat(cap) * size.h) / 100 : 0; // the controls at their tallest | |
| 156 | const { box, total } = layout(rows, areas, size, { strip: STRIP, sheet }, vars); | |
| 157 | expect(total).toBeCloseTo(size.h, 3); | |
| 158 | const camera = box.view!, model = box.model!; | |
| 159 | expect(camera.top).toBe(0); | |
| 160 | expect(camera.height).toBeCloseTo((size.w * 9) / 16, 3); // 16:9 across the full width | |
| 161 | expect(camera.bottom).toBeLessThanOrEqual(box.strip!.top); | |
| 162 | expect(box.strip!.bottom).toBeLessThanOrEqual(model.top); | |
| 163 | expect(model.top).toBeCloseTo(camera.height + STRIP, 3); // directly under the strip | |
| 164 | expect(model.height).toBeGreaterThan(driving ? 120 : 300); | |
| 165 | expect(model.bottom).toBeCloseTo(driving ? box.sheet!.top : box.dock!.top, 3); // down to the bar, or the controls on your turn | |
| 166 | expect(box.dock!.bottom).toBeCloseTo(size.h, 3); | |
| 167 | }); | |
| 168 | } | |
| 169 | } | |
| 170 | ||
| 171 | test("before the tab bar is drawn the camera and the model are both there too", () => { | |
| 172 | const rows = decl(mobile, "#shell", "grid-template-rows")!; | |
| 173 | const areas = tracks(decl(mobile, "#shell", "grid-template-areas")!).map((a) => a.replace(/"/g, "")); | |
| 174 | expect(areas).toEqual(["view", "strip", "model", "sheet"]); | |
| 175 | const vars = { "--cam": decl(mobile, "#shell", "--cam")! }; | |
| 176 | const { box } = layout(rows, areas, SIZES[0]!, { strip: STRIP }, vars); | |
| 177 | expect(box.view!.height).toBeCloseTo((390 * 9) / 16, 3); | |
| 178 | expect(box.model!.height).toBeGreaterThan(100); | |
| 179 | expect(box.model!.top).toBeGreaterThanOrEqual(box.strip!.bottom); | |
| 180 | }); | |
| 181 | ||
| 182 | test("on the Drive tab no portrait rule hides the view, a pane or the model", () => { | |
| 183 | const targets = [/#app\b/, /#stage\b/, /\.pane\b/, /#pane3\b/, /#model\b/, /urdf-viewer/]; | |
| 184 | const offenders = all | |
| 185 | .filter((r) => (r.media === "" ? false : portrait(r.media)) && hides(r.body)) | |
| 186 | .flatMap((r) => r.selector.split(",").map((s) => s.trim())) | |
| 187 | .filter((s) => !s.includes(':not([data-panel="drive"])')) // the other tabs show the sheet alone | |
| 188 | .filter((s) => targets.some((t) => t.test(s.split(/[\s>+~]+/).pop()!))); | |
| 189 | expect(offenders).toEqual([]); | |
| 190 | }); | |
| 191 | }); |
Software/so101/src/server.test.ts +6 −4
| @@ -199,9 +199,9 @@ describe("viewer page", () => { | ||
| 199 | 199 | expect(r.headers.get("content-type")).toBe("text/css"); |
| 200 | 200 | expect(r.headers.get("cache-control")).toContain("immutable"); |
| 201 | 201 | const css = await r.text(); |
| 202 | expect(css).toMatch(/#app \{[^}]*position: sticky; top: 0;[^}]*aspect-ratio: 16 \/ 9/); | |
| 202 | expect(css).toContain("--cam: calc(100vw * 9 / 16"); // the camera's 16:9 row (src/portrait-layout.test.ts lays it out) | |
| 203 | 203 | expect(css).toContain("env(safe-area-inset-top"); |
| 204 | expect(css).toContain("html #shell.docked { grid-template-rows: auto auto"); // the tab bar keeps the reserved 16:9 view | |
| 204 | expect(css).toContain("html #shell.docked { grid-template-rows: var(--cam) auto"); // the tab bar keeps the reserved 16:9 view | |
| 205 | 205 | expect(css).toMatch(/#top \.info, #driverTag \{ display: none; \}/); // the overlay's status lines give way to the strip's |
| 206 | 206 | expect(page).toContain("viewport-fit=cover"); |
| 207 | 207 | expect(page).toMatch(/<section id="strip"[\s\S]*id="armLine"[\s\S]*<\/section>/); |
| @@ -227,10 +227,12 @@ describe("viewer page", () => { | ||
| 227 | 227 | expect(r.status).toBe(200); |
| 228 | 228 | expect(r.headers.get("cache-control")).toContain("immutable"); |
| 229 | 229 | } |
| 230 | expect(page).toMatch(/#lever \{[^}]*touch-action: none/); | |
| 230 | // The one-joint lever shows only on a phone held upright, so its rules live in the phone's stylesheet. | |
| 231 | const tabsCss = await (await fetch(`${base}${/\/ui\/[0-9a-f]{12}\/tabs\.css/.exec(page)![0]}`)).text(); | |
| 232 | expect(tabsCss).toMatch(/#lever \{[^}]*touch-action: none/); | |
| 231 | 233 | expect(page).toMatch(/\.stick \{[^}]*touch-action: none/); |
| 232 | 234 | expect(page).toMatch(/#grips button \{[^}]*min-height: (7[2-9]|[89]\d)px/); |
| 233 | expect(page).toMatch(/#chips button small \{[^}]*white-space: nowrap/); // a long label never wraps and shifts the row | |
| 235 | expect(tabsCss).toMatch(/#chips button small \{[^}]*white-space: nowrap/); // a long label never wraps and shifts the row | |
| 234 | 236 | // One STOP in every layout: one stop control in the markup, and no layout hides it. Resume is its own control. |
| 235 | 237 | expect(page.match(/<button[^>]*data-stop/g)?.length).toBe(1); |
| 236 | 238 | expect(page).not.toMatch(/#stop \{[^}]*display: none/); |
Software/so101/src/ui/mobile.css +23 −11
| @@ -1,16 +1,28 @@ | ||
| 1 | /* A phone held upright: the video pinned on top, full-bleed, its 16:9 box reserved before the first frame arrives so | |
| 1 | /* A phone held upright: the video pinned on top, full-bleed, its 16:9 row reserved before the first frame arrives so | |
| 2 | 2 | nothing under it moves; directly under it one status strip (who drives and the time left, your place in line, the |
| 3 | arm live or reconnecting); the sheet of tabs below. viewer.html links this only for this media query, so the | |
| 4 | desktop and landscape layouts never read it. */ | |
| 3 | arm live or reconnecting); under that the 3D model, down to the tab bar (or to the controls, on your turn); the sheet | |
| 4 | of tabs below. viewer.html links this only for this media query, so the desktop and landscape layouts never read it. | |
| 5 | The camera and the model stay panes of one view (#app): it spans the camera, strip and model rows as a subgrid, so the | |
| 6 | camera pane takes the first row, the model pane the third, and the strip lies over the second. */ | |
| 5 | 7 | @media (max-width: 600px) and (orientation: portrait) { |
| 6 | #shell { grid-template-rows: auto auto minmax(0, 1fr); } | |
| 7 | /* With the tab bar (ui/tabs.css, linked earlier): the same 16:9 view on top; its per-panel rules still hide or fill it. */ | |
| 8 | html #shell.docked { grid-template-rows: auto auto minmax(0, 1fr) calc(56px + var()); } | |
| 9 | /* The notch: a black band the height of the top inset, outside the 16:9 box (content-box keeps the ratio on the picture). */ | |
| 10 | #app { position: sticky; top: 0; box-sizing: content-box; aspect-ratio: 16 / 9; border-top: env(safe-area-inset-top, 0px) solid #000; } | |
| 11 | /* The keyboard is up: the view gives way to the chat, as it does on every layout. */ | |
| 12 | #shell.typing { grid-template-rows: minmax(0, var()) auto minmax(0, 1fr); } | |
| 13 | #shell.typing #app { aspect-ratio: auto; } | |
| 8 | #shell { : calc(100vw * 9 / 16 + env(safe-area-inset-top, 0px)); grid-template-rows: var() auto minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "view" "strip" "model" "sheet"; } | |
| 9 | /* With the tab bar (ui/tabs.css, linked earlier). Drive: the model fills to the bar, or to the controls on your turn. Everything else: the sheet alone. */ | |
| 10 | html #shell.docked { grid-template-rows: var() auto minmax(0, 1fr) minmax(0, 1fr) calc(56px + var()); grid-template-areas: "view" "strip" "model" "sheet" "dock"; } | |
| 11 | html #shell.docked[data-panel="drive"]:not(.mayDrive) { grid-template-rows: var() auto minmax(0, 1fr) 0 calc(56px + var()); } | |
| 12 | html #shell.docked[data-panel="drive"].mayDrive { grid-template-rows: var() auto minmax(0, 1fr) auto calc(56px + var()); } | |
| 13 | html #shell.docked[data-panel="drive"].mayDrive #sheet { max-height: 45svh; } | |
| 14 | html #shell.docked:not([data-panel="drive"]) { grid-template-rows: 0 auto 0 minmax(0, 1fr) calc(56px + var()); } | |
| 15 | /* The notch: a black band the height of the top inset, above the 16:9 camera row (it is counted in --cam). */ | |
| 16 | #app { grid-area: auto; grid-row: view-start / model-end; display: grid; grid-template-columns: 100%; grid-template-rows: subgrid; border-top: env(safe-area-inset-top, 0px) solid #000; } | |
| 17 | #stage { display: contents; } | |
| 18 | #stage > .pane { grid-row: 1; grid-column: 1; min-height: 0; } | |
| 19 | #stage > #pane3 { grid-row: 3; } | |
| 20 | /* The strip sits over the view's middle row, so it paints above it. */ | |
| 21 | #strip { position: relative; z-index: 1; } | |
| 22 | /* The model is always on here, so its view button goes; the camera buttons pick which camera is on top. */ | |
| 23 | #v3 { display: none; } | |
| 24 | /* The keyboard is up: the view gives way to the chat, as it does on every layout, and the model folds away. */ | |
| 25 | #shell.typing { grid-template-rows: minmax(0, var()) auto 0 minmax(0, 1fr); } | |
| 14 | 26 | /* One status line: the arm's state moves from over the video into the strip, and the driver's name over the video goes, |
| 15 | 27 | since the strip already says who drives. */ |
| 16 | 28 | #top .info, #driverTag { display: none; } |
Software/so101/src/ui/tabs.css +19 −1
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | /* The phone-portrait bottom tab bar: one panel at a time. Hidden on desktop and in landscape. STOP stays in the strip. |
| 2 | Every rule keys on .docked, which the page sets once the bar is drawn: until then the sheet's own tabs are the navigation. */ | |
| 2 | Every bar rule keys on .docked, which the page sets once the bar is drawn: until then the sheet's own tabs are the navigation. | |
| 3 | Last, the touch lever, which shows only on a phone held upright. */ | |
| 3 | 4 | #dock { display: none; } |
| 4 | 5 | @media (max-width: 640px) and (orientation: portrait) { |
| 5 | 6 | html #shell.docked { grid-template-rows: minmax(0, var()) auto minmax(0, 1fr) calc(56px + var()); grid-template-areas: "view" "strip" "sheet" "dock"; } |
| @@ -12,4 +13,21 @@ | ||
| 12 | 13 | html #shell.docked[data-panel="drive"]:not(.mayDrive) #sheet { display: none; } |
| 13 | 14 | html #shell.docked:not([data-panel="drive"]) { grid-template-rows: 0 auto minmax(0, 1fr) calc(56px + var()); } |
| 14 | 15 | #shell.docked:not([data-panel="drive"]) #app { display: none; } |
| 16 | /* Touch driving (src/ui/drive.js), shown only here: pick a joint and push one big lever; let go and it stops. */ | |
| 17 | #chips { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; } | |
| 18 | #chips button { min-height: 50px; padding: 0 2px; border-radius: 10px; display: grid; place-content: center; gap: 1px; line-height: 1.1; } | |
| 19 | #chips button b { font-size: 15px; } #chips button small { font-size: 10.5px; color: var(); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } | |
| 20 | #chips button[aria-checked=true] { background: var(); border-color: var(); color: var(); } #chips button[aria-checked=true] small { color: inherit; opacity: .85; } | |
| 21 | #one { display: grid; grid-template-columns: minmax(0, 1fr) 84px minmax(0, 1fr); gap: 12px; height: clamp(210px, 36svh, 360px); } | |
| 22 | #one .nudges { display: grid; grid-template-rows: 1fr 1fr; gap: 10px; } | |
| 23 | #one .nudges button { display: grid; place-content: center; gap: 2px; font-size: 22px; line-height: 1; touch-action: none; -webkit-user-select: none; user-select: none; } | |
| 24 | #one .nudges small { font-size: 12px; color: var(); } | |
| 25 | #lever { position: relative; border-radius: 42px; background: var(); border: 1px solid var(); touch-action: none; -webkit-user-select: none; user-select: none; overflow: hidden; cursor: ns-resize; } | |
| 26 | #lever::before { content: ""; position: absolute; left: 16px; right: 16px; top: 50%; height: 2px; margin-top: -1px; background: var(); } | |
| 27 | #leverAt { position: absolute; left: 0; bottom: 0; width: 5px; height: 100%; background: var(); transform-origin: bottom; transform: scaleY(var(, .5)); } | |
| 28 | #leverKnob { position: absolute; left: 7px; right: 7px; top: 50%; height: 68px; margin-top: -34px; border-radius: 34px; background: var(); color: var(); display: grid; place-content: center; font-size: 22px; box-shadow: 0 2px 10px rgba(0,0,0,.3); transition: transform .14s ease-out; pointer-events: none; } | |
| 29 | #lever.held { border-color: var(); background: var(); } #lever.held #leverKnob { transition: none; } | |
| 30 | #one .about { display: grid; align-content: center; gap: 4px; min-width: 0; } | |
| 31 | #oneName { font-size: 20px; font-weight: 700; } #onePos { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; } | |
| 32 | #oneHint { color: var(); font-size: 12px; } | |
| 15 | 33 | } |
Software/so101/src/viewer.html +6 −17
| @@ -175,25 +175,9 @@ | ||
| 175 | 175 | .pose { display: inline-flex; gap: 4px; align-items: center; } |
| 176 | 176 | #readout { color: var(); font-size: 13px; display: flex; gap: 14px; flex-wrap: wrap; } #readout b { color: var(); font-weight: 550; } |
| 177 | 177 | |
| 178 | /* touch driving (src/ui/drive.js): on a phone held upright, pick a joint and push one big lever; let go and it stops */ | |
| 178 | /* touch driving (src/ui/drive.js): on a phone held upright, pick a joint and push one big lever; let go and it stops (ui/tabs.css) */ | |
| 179 | 179 | #touch { display: none; gap: 10px; } |
| 180 | #chips { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; } | |
| 181 | #chips button { min-height: 50px; padding: 0 2px; border-radius: 10px; display: grid; place-content: center; gap: 1px; line-height: 1.1; } | |
| 182 | #chips button b { font-size: 15px; } #chips button small { font-size: 10.5px; color: var(); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } | |
| 183 | #chips button[aria-checked=true] { background: var(); border-color: var(); color: var(); } #chips button[aria-checked=true] small { color: inherit; opacity: .85; } | |
| 184 | #one { display: grid; grid-template-columns: minmax(0, 1fr) 84px minmax(0, 1fr); gap: 12px; height: clamp(210px, 36svh, 360px); } | |
| 185 | #one .nudges { display: grid; grid-template-rows: 1fr 1fr; gap: 10px; } | |
| 186 | #one .nudges button { display: grid; place-content: center; gap: 2px; font-size: 22px; line-height: 1; touch-action: none; -webkit-user-select: none; user-select: none; } | |
| 187 | #one .nudges small { font-size: 12px; color: var(); } | |
| 188 | #lever { position: relative; border-radius: 42px; background: var(); border: 1px solid var(); touch-action: none; -webkit-user-select: none; user-select: none; overflow: hidden; cursor: ns-resize; } | |
| 189 | #lever::before { content: ""; position: absolute; left: 16px; right: 16px; top: 50%; height: 2px; margin-top: -1px; background: var(); } | |
| 190 | #leverAt { position: absolute; left: 0; bottom: 0; width: 5px; height: 100%; background: var(); transform-origin: bottom; transform: scaleY(var(, .5)); } | |
| 191 | #leverKnob { position: absolute; left: 7px; right: 7px; top: 50%; height: 68px; margin-top: -34px; border-radius: 34px; background: var(); color: var(); display: grid; place-content: center; font-size: 22px; box-shadow: 0 2px 10px rgba(0,0,0,.3); transition: transform .14s ease-out; pointer-events: none; } | |
| 192 | #lever.held { border-color: var(); background: var(); } #lever.held #leverKnob { transition: none; } | |
| 193 | 180 | #lever.end, .stick.end { box-shadow: 0 0 0 3px var(); } |
| 194 | #one .about { display: grid; align-content: center; gap: 4px; min-width: 0; } | |
| 195 | #oneName { font-size: 20px; font-weight: 700; } #onePos { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; } | |
| 196 | #oneHint { color: var(); font-size: 12px; } | |
| 197 | 181 | #lag { color: #f2cc60; font-variant-numeric: tabular-nums; } |
| 198 | 182 | #chat .earlier { display: block; margin: 2px auto 8px; font-size: 13px; } |
| 199 | 183 | /* on a phone on its side: two thumb sticks over the picture, the gripper between them */ |
| @@ -656,6 +640,8 @@ | ||
| 656 | 640 | const keep = () => { try { localStorage.setItem("so101.panes", JSON.stringify([...document.querySelectorAll(".pane.on")].map((p) => p.dataset.key))); } catch {} }; |
| 657 | 641 | const shown = () => document.querySelectorAll(".pane.on").length; |
| 658 | 642 | const paneOn = (c) => c.pane.classList.contains("on"); |
| 643 | const stacked = matchMedia("(max-width: 600px) and (orientation: portrait)"); // ui/mobile.css's | |
| 644 | stacked.onchange = () => stacked.matches ? fallback() : narrow.matches && cams.some(paneOn) && setPane("pane3", false); | |
| 659 | 645 | async function snap(c) { |
| 660 | 646 | clearTimeout(c.timer); |
| 661 | 647 | if (!paneOn(c) || plan.mode !== "snapshot" || document.hidden) return; |
| @@ -695,6 +681,7 @@ | ||
| 695 | 681 | function pick(key) { |
| 696 | 682 | const pane = key === "pane3" ? $("pane3") : cams.find((x) => x.pane.dataset.key === key)?.pane; |
| 697 | 683 | if (!pane) return; |
| 684 | if (stacked.matches) { if (key !== "pane3") for (const c of cams) if (paneOn(c) !== (c.pane === pane)) showCam(c, !paneOn(c)); return; } | |
| 698 | 685 | const on = !pane.classList.contains("on"); |
| 699 | 686 | if (!on && shown() === 1) return; // keep one pane |
| 700 | 687 | if (on && narrow.matches) for (const other of document.querySelectorAll(".pane.on")) setPane(other.dataset.key, false); |
| @@ -703,6 +690,7 @@ | ||
| 703 | 690 | } |
| 704 | 691 | /** Whether a view is on when it first appears: the viewer's last choice, else the camera when there is a real one, and the model beside it on a wide screen. */ |
| 705 | 692 | function wanted(key) { |
| 693 | if (stacked.matches) return false; // fallback() turns on both | |
| 706 | 694 | if (narrow.matches && shown() >= 1) return false; |
| 707 | 695 | if (key === "pane3" && !modelInfo?.ok) return false; |
| 708 | 696 | if (chosen) return chosen.has(key); |
| @@ -711,6 +699,7 @@ | ||
| 711 | 699 | } |
| 712 | 700 | /** At least one view on: the first camera, else the model. */ |
| 713 | 701 | function fallback() { |
| 702 | if (viewsReady && stacked.matches) { if (cams[0] && !cams.some(paneOn)) showCam(cams[0], true); if (modelInfo?.ok) setPane("pane3", true); return; } | |
| 714 | 703 | if (shown() || !viewsReady) return; |
| 715 | 704 | if (cams[0] && (cameraFirst || !modelInfo?.ok)) showCam(cams[0], true); |
| 716 | 705 | else if (modelInfo?.ok) setPane("pane3", true); |
new above
offline