Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(home): give the floorplan editor real touch targets, and the stylesheet it never had
nirholasdad31271ea1e
diff --git a/pages/home-scene.html b/pages/home-scene.htmlindex 62f288f50..785c8feb1 100644--- a/pages/home-scene.html+++ b/pages/home-scene.html@@ -18,6 +18,18 @@<link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/fonts/fonts.css" /><link rel="stylesheet" href="/home-scene.css" />+ <!--+ The floorplan editor's own stylesheet. It renders inside this page's Plan+ view (src/home/floorplan.js, every class prefixed hm-plan-), and its rules+ live in the smart-home surface's sheet, which only the /smart-home pages+ were loading. So the editor shipped here with no styling at all: browser+ default buttons, a 21px toolbar, and none of the touch sizing the rest of+ the lane has. Caught by measuring its controls on an emulated phone in+ tests/e2e/home-a11y.spec.js. The sheet is safe to add: outside a :root+ block of --hm-* custom properties, every selector in it is scoped to an+ hm- class, and this page uses hs- ones.+ -->+ <link rel="stylesheet" href="/src/home/home.css" /></head><body><div id="nav-container"></div>diff --git a/src/home/home.css b/src/home/home.cssindex bfb2dc15a..e24dc4496 100644--- a/src/home/home.css+++ b/src/home/home.css@@ -723,6 +723,22 @@.hm-plan-room-name { font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: 1.15; }.hm-plan-room-size { font-size: var(--text-2xs); color: var(--hm-ink-3); font-variant-numeric: tabular-nums; }++/* A room card is drawn to scale, so its box is the room's real footprint and+ the content has to survive whatever that turns out to be. An ordinary 5.7 m+ room is 80px across at this zoom, which cannot hold a name, a measurement and+ a button: everything wrapped mid-word and clipped, and a plan of small rooms+ read as garbled text rather than as a plan. The name is what identifies the+ room, so it is the last thing to go; the measurement and the orphan tag drop+ out when there is no room for them, and the name shrinks with the box. */+.hm-plan-room { container-type: size; }+@container (max-width: 128px) or (max-height: 92px) {+ .hm-plan-room-size { display: none; }+}+@container (max-width: 96px) or (max-height: 64px) {+ .hm-plan-room-tag { display: none; }+ .hm-plan-room-name { font-size: var(--text-2xs); }+}.hm-plan-room-tag {font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.07em;color: var(--hm-ink-3);@@ -735,7 +751,9 @@.hm-plan-room-drop:hover { color: var(--ink); border-color: var(--hm-ink-3); }.hm-plan-handle {- appearance: none; position: absolute; right: -1px; bottom: -1px;+ /* Logical, not `right`: in an RTL locale the grab corner belongs on the end+ of the room the reader's eye finishes at, which is the left one. */+ appearance: none; position: absolute; inset-inline-end: -1px; bottom: -1px;width: 22px; height: 22px; padding: 0; cursor: nwse-resize; touch-action: none;border: 0; border-radius: 0 0 var(--radius-sm) 0;background: linear-gradient(135deg, transparent 50%, var(--hm-ink-3) 50%);@@ -842,3 +860,48 @@background: var(--surface-2);border-color: var(--stroke-strong);}++/*+ * The floorplan editor on a finger.+ *+ * Its toolbar buttons, its tray of rooms and the per-device File buttons all+ * render at 21px, which is comfortable with a mouse and under half of what+ * WCAG 2.5.5 asks of a touch target. The editor is also the one surface in this+ * lane somebody is most likely to use standing up with a phone in one hand:+ * they are walking round the house deciding where the rooms are.+ *+ * The rooms drawn on the canvas are deliberately NOT in this list. A room's+ * rectangle is sized by the plan, in metres, and stretching a small room to+ * 44px would draw a house that is not the house. Its resize handle is here+ * instead, because a 22px grab corner is unusable with a fingertip and it is+ * chrome rather than a measurement.+ *+ * Coarse pointers only, so a laptop's editor is untouched: a tray that grew+ * 23px per chip on a desktop would push the canvas off the screen.+ *+ * Last in the file on purpose. `.hm-plan-tray-file` sets its own `min-height:+ * 32px` several hundred lines below where this block reads best, and at equal+ * specificity the later rule wins: placed up there, this raised every control+ * except the File buttons, which stayed at 32px on a phone.+ */+@media (pointer: coarse) {+ .hm-plan-btn,+ .hm-plan-tray-room,+ .hm-plan-tray-file,+ .hm-plan-room-drop,+ .hm-plan-filemenu-item,+ .hm-plan-naming-input {+ min-height: 44px;+ }+ .hm-plan-btn,+ .hm-plan-tray-room,+ .hm-plan-tray-file,+ .hm-plan-room-drop,+ .hm-plan-filemenu-item {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ min-width: 44px;+ }+ .hm-plan-handle { width: 44px; height: 44px; }+}diff --git a/tests/e2e/home-a11y.spec.js b/tests/e2e/home-a11y.spec.jsindex dc4c60f7a..8c9a1b31a 100644--- a/tests/e2e/home-a11y.spec.js+++ b/tests/e2e/home-a11y.spec.js@@ -296,19 +296,64 @@ test('the house is usable at 320, 375, 768 and 1440, with the primary action inconst overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);expect(overflow, `no horizontal overflow at ${width}px`).toBeLessThanOrEqual(1);- // Every control a finger has to hit is at least 44px tall.- const small = await page.evaluate(() => {+ }+ await page.setViewportSize({ width: 1440, height: 900 });+});++/**+ * Measure every control's height on a page that is really emulating a phone.+ *+ * The 44px floor is scoped to `pointer: coarse` in public/home-scene.css, which+ * is the right question to ask: a laptop window dragged narrow has a mouse in+ * it, and a rail that grew 12px per row there would push half the house off the+ * screen. So the measurement has to be made on a context with touch emulation+ * on, not on a desktop browser at a small viewport, which reports `pointer:+ * fine` and skips those rules. Measured with a fine pointer, every one of the+ * lane's 46 controls "fails" and none of them is broken.+ */+async function touchTargetsUnder44(browser, width, path, ready) {+ const context = await browser.newContext({+ viewport: { width, height: 720 },+ hasTouch: true,+ isMobile: true,+ deviceScaleFactor: 2,+ });+ try {+ const page = await context.newPage();+ await signIn(page, 'owner');+ await page.goto(path, { waitUntil: 'domcontentloaded' });+ await ready(page);+ await settle(page);+ // The rules under test only exist inside `@media (pointer: coarse)`, so a+ // context that did not actually emulate touch would pass this by testing+ // nothing at all.+ const coarse = await page.evaluate(() => matchMedia('(pointer: coarse)').matches);+ expect(coarse, 'the context must really emulate a touch screen').toBe(true);+ return await page.evaluate(() => {const out = [];- for (const node of document.querySelectorAll('#hs-shell button, #hs-shell a[href]')) {+ // A room on the floorplan canvas is sized by the plan itself: a 1.5m+ // room is meant to be small, and stretching it to 44px would lie about+ // the house. Everything that is chrome rather than content is held to+ // the floor.+ for (const node of document.querySelectorAll('#hs-shell button:not(.hm-plan-room), #hs-shell a[href], #hs-shell input')) {const r = node.getBoundingClientRect();if (r.width === 0 && r.height === 0) continue;if (r.height < 44) out.push(`${node.className || node.tagName}: ${Math.round(r.height)}px`);}return out;});- if (width <= 768) expect(small, `touch targets under 44px at ${width}px`).toEqual([]);+ } finally {+ await context.close();+ }+}++test('every control in the live house clears 44px on a real touch screen', async ({ browser }) => {+ for (const width of [320, 375]) {+ const small = await touchTargetsUnder44(browser, width, `/smart-home/${homeId}?view=2d`, (page) =>+ expect(page.locator('#hs-rooms')).not.toHaveAttribute('aria-busy', 'true', { timeout: 120_000 }),+ );+ expect(small, `touch targets under 44px at ${width}px`).toEqual([]);}- await page.setViewportSize({ width: 1440, height: 900 });});test('a Fahrenheit house reads in Fahrenheit whatever the browser locale is', async ({ page }) => {@@ -490,33 +535,26 @@ test('on a phone, the confirmation survives a stray tap and only a real answer cawait page.setViewportSize({ width: 1440, height: 900 });});-test('the floorplan editor is a touch target at 320 and 375, not only at 1440', async ({ page }) => {- await signIn(page, 'owner');+test('the floorplan editor is a touch target too, not only the house', async ({ browser, page }) => {// The editor is where the 44px floor is easiest to miss: its controls are a- // dense toolbar and a tray of device chips, and the breakpoint sweep above- // only ever opens the 2D house.+ // dense toolbar and a tray of device chips, and the sweep above only ever+ // opens the 2D house.+ for (const width of [320, 375]) {+ const small = await touchTargetsUnder44(browser, width, `/smart-home/${homeId}?view=plan`, (page) =>+ expect(page.locator('#hs-plan .hm-plan-toolbar, #hs-plan .hm-plan-skeleton').first()).toBeVisible({ timeout: 120_000 }),+ );+ expect(small, `floorplan controls under 44px at ${width}px`).toEqual([]);+ }++ // And the editor holds its own width, which is a layout question rather than+ // a pointer one and so is asked of the ordinary page.+ await signIn(page, 'owner');for (const width of [320, 375]) {await page.setViewportSize({ width, height: 720 });await openView(page, homeId, 'plan');await settle(page);-const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);expect(overflow, `the editor must not push the page sideways at ${width}px`).toBeLessThanOrEqual(1);-- const small = await page.evaluate(() => {- const out = [];- // The rooms on the canvas are sized by the plan itself: a 1.5m room- // is meant to be small, and forcing it to 44px would lie about the- // house. Every control that is chrome rather than content is held to- // the floor.- for (const node of document.querySelectorAll('#hs-plan button, #hs-plan [role="button"]:not(.hm-plan-room), #hs-plan input')) {- const r = node.getBoundingClientRect();- if (r.width === 0 && r.height === 0) continue;- if (r.height < 44) out.push(`${node.className || node.tagName}: ${Math.round(r.height)}px`);- }- return out;- });- expect(small, `floorplan controls under 44px at ${width}px`).toEqual([]);}await page.setViewportSize({ width: 1440, height: 900 });await openView(page, homeId, '2d');