You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte-kit-vice/scripts/probe-toggle.ts

45 lines
1.4 KiB

eidos: pilot wrapper pattern + doctrinal API conventions Toggle as the eidos pilot: subdirectory layout (recipe + Svelte wrapper + types + index + README) replacing the flat CSS-only form. Pattern is documented in eidos/components/README.md and the toggle README. Shared types live in eidos/lib/types.ts. First export is `Size` (8 values xxs..xxl + full); components narrow with `Extract<Size, ...>` per the per-component-subset doctrine. No `Eidos` prefix on types — module path already conveys the layer. API doctrine: - soma stays compound (Toggle.Provider) for symmetry with multi-part - eidos exports both default + Provider so single-part components accept both `<Toggle>` (ergonomic) and `<Toggle.Provider>` (compound-style consumers) SoundChannel eager-init fixes the autoplay race: AudioContext is created + resumed synchronously on the first user gesture (capture-phase listener registered in the constructor), avoiding the previous race where the first emit() scheduled the resume in a microtask outside the gesture window. Demo page (web/routes/toggle/+page.svelte) restructured so the live preview renders ALWAYS above the tablist — Sema-tab Play buttons can fire on the real toggle. Motion preview amplifies scale ×8 visually only; doctrinal values stay in the <dl>. Conventions 7-13 added to src/docs/sema-implementation-guide.md covering: directory structure, wrapper composition, no Eidos prefix, soma compound vs eidos flat, iconOnly sr-only body, sound eager-init, docs-preview amplification. CLAUDE.md gets a session hand-off block listing where things stand and next concrete steps (migrate switch/collapsible/dialog/drawer/popover/ toast/avatar; wire topbar sound mute to masterGain; rename theme tokens to drop the success/warning/danger fallback aliases). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
/**
* Probe Toggle page across themes + interaction. Captures screenshots
* and console errors.
*/
import { chromium } from 'playwright';
import { mkdir } from 'node:fs/promises';
const BASE = process.env.BASE_URL ?? 'http://localhost:5177';
const OUT = 'g:/tmp/demos';
async function main() {
await mkdir(OUT, { recursive: true });
const b = await chromium.launch();
const ctx = await b.newContext({ viewport: { width: 1280, height: 900 } });
const p = await ctx.newPage();
const errs: string[] = [];
p.on('console', (m) => {
if (m.type() === 'error') errs.push(m.text());
});
p.on('pageerror', (e) => errs.push('pe: ' + e.message));
await p.goto(BASE + '/toggle', { waitUntil: 'networkidle' });
await p.waitForTimeout(500);
await p.screenshot({ path: OUT + '/toggle-light.png', fullPage: true });
await p.locator('[data-toggle]').first().click();
await p.waitForTimeout(150);
await p.screenshot({ path: OUT + '/toggle-press.png', fullPage: true });
await p.waitForTimeout(500);
// Switch to dark theme via the topbar
await p.locator('button[aria-label="Toggle theme"]').first().click();
await p.waitForTimeout(300);
await p.screenshot({ path: OUT + '/toggle-dark.png', fullPage: true });
console.log('errors:', errs.length);
for (const e of errs) console.log(' ' + e.slice(0, 200));
await b.close();
}
main().catch((e) => {
console.error(e);
process.exit(1);
});

Powered by TurnKey Linux.