Spaces:
Running
Running
Minimal UI: floating toolbar, export menu, Advanced tweaking sheet
Browse filesFiles changed (4)
- index.html+73-36
- src/main.ts+14-2
- src/style.css+608-158
- src/ui.tsAdded+63
8 unmodified lines91011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859608 unmodified lines<body><header class="bar"><div class="brand"><span class="emoji">🤗</span><div><h1>Hugging Partnership</h1><p>Drop a partner logo, drag it into Huggy, get a hug.</p></div></div><div class="actions"><label class="btn primary">Upload SVG<input id="file" type="file" accept=".svg,image/svg+xml" hidden /></label><button id="exportSvg" class="btn">Export SVG</button><button id="exportPng" class="btn">Export PNG</button></div></header><main><section id="stage" class="stage"><div id="drop" class="drop">Drop an SVG logo here</div></section><aside class="panel"><div class="group"><h2>Version</h2><select id="version" class="version-select"></select><p id="versionDesc" class="hint"></p></div><div class="group"><h2>Samples</h2><div id="samples" class="samples"></div></div><div class="group"><h2>Logo</h2><label class="field">Size <input id="size" type="range" min="140" max="1000" value="520" /></label><label class="field">Rotation <input id="rotation" type="range" min="-180" max="180" value="0" /></label><button id="reset" class="btn small">Reset position</button><p class="hint">Drag the logo. Scroll over it to resize, Shift + scroll to rotate.</p><p class="hint">Drag a hand to place it, scroll over it to rotate. The magnet snaps it back.</p></div><div class="group"><label class="check"><input id="debug" type="checkbox" /> Show pockets & grip</label></div><div class="group tuner" id="tuner"></div><p id="status" class="status"></p></aside></main><script type="module" src="/src/main.ts"></script></body></html>8 unmodified lines9101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596978 unmodified lines<body><header class="bar"><div class="brand"><span class="brand-mark" aria-hidden="true">🤗</span><h1>Hugging Partnership</h1></div><div class="actions"><label class="btn ghost" title="Upload an SVG logo"><svg class="icon" viewBox="0 0 20 20" aria-hidden="true"><path d="M10 13V3.5M6 7l4-4 4 4M4 13.5V16h12v-2.5" /></svg><span>Upload</span><input id="file" type="file" accept=".svg,image/svg+xml" hidden /></label><div class="menu-anchor"><button id="exportBtn" class="btn primary" aria-haspopup="menu" aria-expanded="false"><span>Export</span><svg class="icon chevron" viewBox="0 0 20 20" aria-hidden="true"><path d="M6 8l4 4 4-4" /></svg></button><div id="exportMenu" class="menu" role="menu" hidden><button id="exportSvg" class="menu-item" role="menuitem"><span>SVG</span><span class="menu-note">Vector</span></button><button id="exportPng" class="menu-item" role="menuitem"><span>PNG</span><span class="menu-note">Transparent, 2×</span></button></div></div></div></header><main id="stage" class="stage"><div id="drop" class="drop"><span>Drop an SVG to hug it</span></div><div class="dock"><p id="hint" class="hint"><span class="for-pointer">Drag the logo into Huggy · Scroll to resize · ⇧ Scroll to rotate</span><span class="for-touch">Drag the logo into Huggy</span></p><div class="toolbar" role="toolbar" aria-label="Logo"><div id="samples" class="chips" aria-label="Sample logos"></div><span class="divider" aria-hidden="true"></span><label class="mini" title="Size"><span>Size</span><input id="size" type="range" min="140" max="1000" value="520" /></label><label class="mini" title="Rotation"><span>Rotate</span><input id="rotation" type="range" min="-180" max="180" value="0" /></label><button id="reset" class="icon-btn" title="Reset position" aria-label="Reset position"><svg class="icon" viewBox="0 0 20 20" aria-hidden="true"><path d="M4.5 9.5a5.5 5.5 0 1 0 1.7-4" /><path d="M4 3v3.5h3.5" /></svg></button><span class="divider" aria-hidden="true"></span><button id="advancedBtn" class="btn ghost small" aria-expanded="false" aria-controls="advanced"><svg class="icon" viewBox="0 0 20 20" aria-hidden="true"><path d="M4 6h7M14 6h2M4 14h2M9 14h7" /><circle cx="12.5" cy="6" r="1.6" /><circle cx="7.5" cy="14" r="1.6" /></svg><span>Advanced</span></button></div></div><p id="status" class="toast" role="status" aria-live="polite"></p></main><aside id="advanced" class="sheet" aria-label="Advanced tweaking" hidden><div class="sheet-head"><h2>Advanced tweaking</h2><button id="advancedClose" class="icon-btn" aria-label="Close"><svg class="icon" viewBox="0 0 20 20" aria-hidden="true"><path d="M5.5 5.5l9 9M14.5 5.5l-9 9" /></svg></button></div><div class="sheet-body"><section class="section"><h3>Version</h3><select id="version" class="select"></select><p id="versionDesc" class="note"></p></section><section class="section"><label class="switch-row"><span>Show pockets & grip</span><input id="debug" type="checkbox" class="switch" /></label><p class="note">Drag a hand to place it, scroll over it to rotate. The magnet snaps it back.</p></section><section class="section tuner" id="tuner"></section></div></aside><script type="module" src="/src/main.ts"></script></body></html>
4 unmodified lines5678910166 unmodified lines177178179180181182710 unmodified lines89389489589689789889911 unmodified lines9119129139149159169179189199209219229239249259269274 unmodified linesimport { SpringPose, poseTransform, solveLeftHand, solveRightHand, type GripChoice, type Pose } from './hands';import { DEFAULT_WARP, LogoWarp, squishLevel, type EdgeShape, type Offsets, type WarpParams } from './warp';import { createTuner, type ParamSpec, type SweetSpot } from './tuner';import { FieldWarp } from './warpField';import { CURRENT_VERSION, VERSIONS, type Version } from './versions';166 unmodified lines}async function loadSample(name: string) {const res = await fetch(`./samples/${name}.svg`);await useLogo(await res.text(), name, true);}710 unmodified lines$<HTMLInputElement>('file').addEventListener('change', async (e) => {const file = (e.target as HTMLInputElement).files?.[0];if (file) await useLogo(await file.text(), file.name.replace(/\.svg$/i, ''));(e.target as HTMLInputElement).value = '';});11 unmodified linessetStatus('Please drop an SVG file.');return;}await useLogo(await file.text(), file.name.replace(/\.svg$/i, ''));});const samplesEl = document.getElementById('samples')!;for (const name of SAMPLES) {const b = document.createElement('button');b.className = 'btn small';b.textContent = name;b.addEventListener('click', () => loadSample(name));samplesEl.appendChild(b);}// ---------------------------------------------------------------------------------------------// Squish tuning panel (live sliders + sweet-spot recording)4 unmodified lines567891011166 unmodified lines178179180181182183184710 unmodified lines89589689789889990090190290390411 unmodified lines9169179189199209219229239249259269279289299309319329339349359369379389394 unmodified linesimport { SpringPose, poseTransform, solveLeftHand, solveRightHand, type GripChoice, type Pose } from './hands';import { DEFAULT_WARP, LogoWarp, squishLevel, type EdgeShape, type Offsets, type WarpParams } from './warp';import { createTuner, type ParamSpec, type SweetSpot } from './tuner';import './ui';import { FieldWarp } from './warpField';import { CURRENT_VERSION, VERSIONS, type Version } from './versions';166 unmodified lines}async function loadSample(name: string) {markSample(name);const res = await fetch(`./samples/${name}.svg`);await useLogo(await res.text(), name, true);}710 unmodified lines$<HTMLInputElement>('file').addEventListener('change', async (e) => {const file = (e.target as HTMLInputElement).files?.[0];if (file) {markSample(null);await useLogo(await file.text(), file.name.replace(/\.svg$/i, ''));}(e.target as HTMLInputElement).value = '';});11 unmodified linessetStatus('Please drop an SVG file.');return;}markSample(null);await useLogo(await file.text(), file.name.replace(/\.svg$/i, ''));});const samplesEl = document.getElementById('samples')!;for (const name of SAMPLES) {const b = document.createElement('button');b.className = 'chip';b.textContent = name;b.dataset.sample = name;b.setAttribute('aria-pressed', 'false');b.addEventListener('click', () => loadSample(name));samplesEl.appendChild(b);}/** Highlight the sample on stage (none for an uploaded logo). */function markSample(name: string | null) {samplesEl.querySelectorAll<HTMLButtonElement>('.chip').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.sample === name)));}// ---------------------------------------------------------------------------------------------// Squish tuning panel (live sliders + sweet-spot recording)
12345678910111213142 unmodified lines17181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677781 unmodified line808182838485868788899091929394959697989910010110210310410510610710814 unmodified lines1231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272 unmodified lines2302312322332342352362373 unmodified lines2412422432442452462472482492502512522532542552562572582592602612622632642652662672 unmodified lines2702712722732742752762772782792802814 unmodified lines2862872882892902912928 unmodified lines3013023033043053063073083 unmodified lines31231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634729 unmodified lines3773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084093 unmodified lines41341441541641741841942042142221 unmodified lines444445446:root {--bg: #fffaf0;--ink: #12141f;--muted: #6b6f80;--line: #f1e3c4;--yellow: #ffd21e;--orange: #ff9d00;font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;color: var(--ink);background: var(--bg);-webkit-font-smoothing: antialiased;}* {2 unmodified linesbody {margin: 0;min-height: 100vh;display: flex;flex-direction: column;}.bar {display: flex;align-items: center;justify-content: space-between;gap: 16px;padding: 14px 20px;border-bottom: 1px solid var(--line);}.brand {display: flex;align-items: center;gap: 12px;}.brand .emoji {font-size: 34px;}.brand h1 {margin: 0;font-size: 18px;}.brand p {margin: 2px 0 0;font-size: 13px;color: var(--muted);}.actions {display: flex;gap: 8px;}.btn {appearance: none;border: 1px solid #e6d3a8;background: #fff;color: var(--ink);border-radius: 10px;padding: 8px 14px;font: inherit;font-size: 14px;font-weight: 600;cursor: pointer;transition: transform 120ms ease, background 120ms ease;}.btn:hover {background: #fff6dc;}.btn:active {1 unmodified line}.btn.primary {background: var(--yellow);border-color: var(--orange);}.btn.small {padding: 6px 10px;font-size: 13px;}main {flex: 1;display: grid;grid-template-columns: 1fr 260px;min-height: 0;}.stage {position: relative;min-height: 520px;background:radial-gradient(circle at 1px 1px, #ecdcb8 1px, transparent 0) 0 0 / 22px 22px,var(--bg);overflow: hidden;}.stage > svg {14 unmodified lines.drop {position: absolute;inset: 16px;border: 2px dashed var(--orange);border-radius: 18px;display: none;align-items: center;justify-content: center;font-weight: 700;color: var(--orange);background: rgba(255, 210, 30, 0.12);pointer-events: none;z-index: 2;}.stage.dragover .drop {display: flex;}.panel {border-left: 1px solid var(--line);padding: 16px;display: flex;flex-direction: column;gap: 18px;background: #fffdf7;}.group h2 {margin: 0 0 8px;font-size: 12px;text-transform: uppercase;letter-spacing: 0.06em;color: var(--muted);}.samples {display: grid;grid-template-columns: repeat(2, 1fr);gap: 6px;}.samples button {text-transform: capitalize;}.field {display: flex;flex-direction: column;gap: 4px;font-size: 13px;margin-bottom: 10px;}.check {display: flex;align-items: center;gap: 6px;font-size: 13px;}.hint {font-size: 12px;color: var(--muted);margin: 8px 0 0;}.status {font-size: 12px;color: #b42318;margin: 0;}@media (max-width: 760px) {main {grid-template-columns: 1fr;}.panel {border-left: 0;border-top: 1px solid var(--line);}}[hidden] {display: none !important;}/* ---- Squish tuning panel ---- *//* Desktop: the page fits the window and the side panel scrolls on its own. */body {height: 100vh;}.panel {overflow-y: auto;}.tuner .tune-group {margin: 14px 0 6px;font-size: 12px;font-weight: 700;color: var(--ink);}2 unmodified linesgrid-template-columns: 1fr auto;align-items: center;gap: 2px 8px;font-size: 12.5px;margin-bottom: 8px;cursor: default;}3 unmodified lines}.tune-row output {font-variant-numeric: tabular-nums;font-size: 12px;color: var(--muted);cursor: pointer;user-select: none;}.tune-record {display: flex;flex-direction: column;gap: 6px;margin-top: 14px;}.tune-note {font: inherit;font-size: 12.5px;padding: 7px 9px;border: 1px solid #e6d3a8;border-radius: 8px;background: #fff;}.tune-list {2 unmodified linesgap: 8px;}.tune-item {border: 1px solid var(--line);border-radius: 10px;padding: 8px 10px;background: #fff;font-size: 12px;}.tune-item-head {4 unmodified lines}.tune-when {color: var(--muted);text-transform: none;font-variant-numeric: tabular-nums;}8 unmodified lines.tune-summary {margin-top: 4px;color: var(--muted);line-height: 1.35;}.tune-item-actions,3 unmodified linesmargin-top: 8px;}.tune-flash {min-height: 1em;color: #15803d;}@media (max-width: 760px) {body {height: auto;}.panel {overflow-y: visible;}}/* ---- Version dropdown ---- */.version-select {width: 100%;font: inherit;font-size: 13px;font-weight: 600;padding: 7px 9px;border: 1px solid #e6d3a8;border-radius: 8px;background: #fff;color: var(--ink);}#versionDesc {margin-top: 6px;line-height: 1.4;}/* ---- Draggable hands ---- */29 unmodified linesbackground: #fff;color: var(--ink);box-shadow:0 0 0 1px rgba(18, 20, 31, 0.08),0 1px 2px rgba(18, 20, 31, 0.12),0 4px 10px rgba(18, 20, 31, 0.1);cursor: pointer;transition:transform 140ms ease,box-shadow 140ms ease;animation: magnet-in 160ms ease-out;}.magnet:hover {transform: scale(1.08);box-shadow:0 0 0 1px rgba(18, 20, 31, 0.1),0 2px 4px rgba(18, 20, 31, 0.14),0 6px 14px rgba(18, 20, 31, 0.12);}.magnet:active {transform: scale(0.94);}.magnet:focus-visible {outline: 2px solid var(--orange);outline-offset: 2px;}.magnet[hidden] {display: none;}3 unmodified linesopacity: 0;transform: scale(0.6);}to {opacity: 1;transform: scale(1);}}/* Invisible safe hover zone between a pinned hand and its magnet button (shown with debug). */21 unmodified linesstroke: rgba(255, 157, 0, 0.6);stroke-dasharray: 4 3;}123456789101112131415161718192021222324252627282 unmodified lines3132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331 unmodified line13513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625714 unmodified lines2722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975982 unmodified lines6016026036046056066076083 unmodified lines6126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456462 unmodified lines6496506516526536546556566576586596606616626634 unmodified lines6686696706716726736748 unmodified lines6836846856866876886896903 unmodified lines69469569669769869970070170270370470570670770829 unmodified lines7387397407417427437447457467477487497507517527537547557567577587597607613 unmodified lines76576676776876977021 unmodified lines792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896/* Hugging Partnership — quiet, system-native UI: the canvas is the product, the chrome staysout of the way. One floating toolbar for everyday controls; everything else lives one leveldeeper in "Advanced tweaking". */:root {--bg: #f7f7f5;--surface: #ffffff;--ink: #1d1d1f;--ink-2: #6e6e73;--ink-3: #a1a1a6;--hairline: rgba(0, 0, 0, 0.08);--fill: rgba(0, 0, 0, 0.05);--fill-strong: rgba(0, 0, 0, 0.08);--accent: #ff9d00; /* Huggy's orange, used only for focus and small marks */--glass: rgba(255, 255, 255, 0.72);--shadow-float: 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04), 0 12px 32px rgba(0, 0, 0, 0.08);--radius: 12px;--ease: cubic-bezier(0.32, 0.72, 0, 1);font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', system-ui, sans-serif;font-size: 14px;line-height: 1.45;color: var(--ink);background: var(--bg);-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;}* {2 unmodified linesbody {margin: 0;height: 100vh;height: 100dvh;display: flex;flex-direction: column;overflow: hidden;}[hidden] {display: none !important;}button,input,select {font: inherit;color: inherit;}:focus-visible {outline: 2px solid var(--accent);outline-offset: 2px;}.icon {width: 18px;height: 18px;fill: none;stroke: currentColor;stroke-width: 1.6;stroke-linecap: round;stroke-linejoin: round;flex: none;}/* ---- Header ---- */.bar {height: 56px;flex: none;display: flex;align-items: center;justify-content: space-between;gap: 16px;padding: 0 16px 0 20px;position: relative;z-index: 10;}.brand {display: flex;align-items: center;gap: 10px;min-width: 0;}.brand-mark {font-size: 22px;line-height: 1;}.brand h1 {margin: 0;font-size: 15px;font-weight: 600;letter-spacing: -0.01em;white-space: nowrap;}.actions {display: flex;align-items: center;gap: 8px;}/* ---- Buttons ---- */.btn {appearance: none;display: inline-flex;align-items: center;gap: 6px;height: 34px;padding: 0 14px;border: 0;border-radius: 999px;background: var(--fill);font-size: 13.5px;font-weight: 500;letter-spacing: -0.005em;white-space: nowrap;cursor: pointer;user-select: none;transition:background 160ms ease,transform 120ms ease;}.btn:hover {background: var(--fill-strong);}.btn:active {1 unmodified line}.btn.primary {background: var(--ink);color: #fff;}.btn.primary:hover {background: #000;}.btn.ghost {background: transparent;}.btn.ghost:hover {background: var(--fill);}.btn.small {height: 30px;padding: 0 12px;font-size: 13px;}.btn .chevron {width: 14px;height: 14px;margin-right: -4px;opacity: 0.7;}.icon-btn {appearance: none;display: grid;place-items: center;width: 30px;height: 30px;padding: 0;border: 0;border-radius: 999px;background: transparent;color: var(--ink-2);cursor: pointer;transition:background 160ms ease,color 160ms ease,transform 120ms ease;}.icon-btn:hover {background: var(--fill);color: var(--ink);}.icon-btn:active {transform: scale(0.94);}/* ---- Export menu ---- */.menu-anchor {position: relative;}.menu {position: absolute;top: calc(100% + 8px);right: 0;min-width: 220px;padding: 6px;border-radius: 14px;background: var(--surface);box-shadow: var(--shadow-float);transform-origin: top right;animation: pop-in 180ms var(--ease);}.menu-item {appearance: none;width: 100%;display: flex;align-items: baseline;justify-content: space-between;gap: 16px;padding: 9px 12px;border: 0;border-radius: 9px;background: transparent;font-size: 13.5px;font-weight: 500;text-align: left;cursor: pointer;}.menu-item:hover,.menu-item:focus-visible {background: var(--fill);outline: none;}.menu-note {font-size: 12px;font-weight: 400;color: var(--ink-2);}@keyframes pop-in {from {opacity: 0;transform: scale(0.96) translateY(-4px);}}/* ---- Stage ---- */.stage {position: relative;flex: 1;min-height: 0;overflow: hidden;background: var(--bg);}.stage > svg {14 unmodified lines.drop {position: absolute;inset: 12px;z-index: 6;display: none;align-items: center;justify-content: center;border-radius: 20px;border: 1.5px dashed rgba(0, 0, 0, 0.18);background: rgba(255, 255, 255, 0.6);backdrop-filter: blur(6px);-webkit-backdrop-filter: blur(6px);font-size: 15px;font-weight: 500;color: var(--ink-2);pointer-events: none;}.stage.dragover .drop {display: flex;}/* ---- Floating toolbar ---- */.dock {position: absolute;left: 50%;bottom: 20px;z-index: 5;transform: translateX(-50%);display: flex;flex-direction: column;align-items: center;gap: 10px;max-width: calc(100% - 24px);}.hint {margin: 0;font-size: 12.5px;color: var(--ink-2);white-space: nowrap;transition: opacity 400ms ease;}.hint.gone {opacity: 0;}.toolbar {display: flex;align-items: center;gap: 6px;padding: 6px;border-radius: 999px;background: var(--glass);backdrop-filter: blur(24px) saturate(180%);-webkit-backdrop-filter: blur(24px) saturate(180%);box-shadow: var(--shadow-float);}.divider {width: 1px;height: 18px;margin: 0 4px;background: var(--hairline);flex: none;}.chips {display: flex;gap: 2px;}.chip {appearance: none;height: 30px;padding: 0 12px;border: 0;border-radius: 999px;background: transparent;font-size: 13px;font-weight: 500;color: var(--ink-2);text-transform: capitalize;white-space: nowrap;cursor: pointer;transition:background 160ms ease,color 160ms ease,transform 120ms ease;}.chip:hover {color: var(--ink);background: var(--fill);}.chip:active {transform: scale(0.96);}.chip[aria-pressed='true'] {color: var(--ink);background: #fff;box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.08);}.mini {display: flex;align-items: center;gap: 8px;padding: 0 6px;font-size: 12.5px;color: var(--ink-2);white-space: nowrap;}.mini input[type='range'] {width: 92px;}/* ---- Range sliders (thin track, white knob) ---- */input[type='range'] {-webkit-appearance: none;appearance: none;height: 20px;margin: 0;background: transparent;cursor: pointer;}input[type='range']::-webkit-slider-runnable-track {height: 4px;border-radius: 999px;background: var(--fill-strong);}input[type='range']::-moz-range-track {height: 4px;border-radius: 999px;background: var(--fill-strong);}input[type='range']::-webkit-slider-thumb {-webkit-appearance: none;width: 16px;height: 16px;margin-top: -6px;border-radius: 50%;background: #fff;box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.2);transition: transform 120ms ease;}input[type='range']::-moz-range-thumb {width: 16px;height: 16px;border: 0;border-radius: 50%;background: #fff;box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.2);}input[type='range']:active::-webkit-slider-thumb {transform: scale(1.12);}/* ---- Toast ---- */.toast {position: absolute;left: 50%;top: 12px;z-index: 7;margin: 0;padding: 8px 14px;border-radius: 999px;background: rgba(29, 29, 31, 0.88);color: #fff;font-size: 13px;transform: translateX(-50%);box-shadow: var(--shadow-float);animation: pop-in 180ms var(--ease);}.toast:empty {display: none;}/* ---- Advanced sheet ---- */.sheet {position: fixed;top: 64px;right: 12px;bottom: 12px;z-index: 20;width: 340px;display: flex;flex-direction: column;border-radius: 18px;background: var(--surface);box-shadow: var(--shadow-float);animation: sheet-in 260ms var(--ease);}@keyframes sheet-in {from {opacity: 0;transform: translateX(16px);}}.sheet-head {display: flex;align-items: center;justify-content: space-between;padding: 14px 12px 6px 20px;}.sheet-head h2 {margin: 0;font-size: 15px;font-weight: 600;letter-spacing: -0.01em;}.sheet-body {flex: 1;overflow-y: auto;padding: 4px 20px 20px;overscroll-behavior: contain;}.section {padding: 14px 0;border-top: 1px solid var(--hairline);}.section:first-child {border-top: 0;}.section h3,.tuner h2 {margin: 0 0 8px;font-size: 12px;font-weight: 600;letter-spacing: 0.01em;color: var(--ink-2);}.note {margin: 8px 0 0;font-size: 12.5px;line-height: 1.5;color: var(--ink-2);}.select {width: 100%;height: 34px;padding: 0 32px 0 12px;border: 0;border-radius: 10px;background: var(--fill)url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M6 8l4 4 4-4' fill='none' stroke='%236e6e73' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")no-repeat right 10px center / 16px;-webkit-appearance: none;appearance: none;font-size: 13.5px;font-weight: 500;cursor: pointer;}/* iOS-style switch */.switch-row {display: flex;align-items: center;justify-content: space-between;gap: 12px;font-size: 13.5px;cursor: pointer;}.switch {-webkit-appearance: none;appearance: none;position: relative;width: 36px;height: 22px;margin: 0;flex: none;border-radius: 999px;background: var(--fill-strong);cursor: pointer;transition: background 200ms ease;}.switch::after {content: '';position: absolute;top: 2px;left: 2px;width: 18px;height: 18px;border-radius: 50%;background: #fff;box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);transition: transform 220ms var(--ease);}.switch:checked {background: #34c759;}.switch:checked::after {transform: translateX(14px);}/* Tuning panel (built by tuner.ts) */.tuner .tune-group {margin: 18px 0 8px;font-size: 12px;font-weight: 600;color: var(--ink);}2 unmodified linesgrid-template-columns: 1fr auto;align-items: center;gap: 2px 8px;margin-bottom: 10px;font-size: 13px;cursor: default;}3 unmodified lines}.tune-row output {font-size: 12px;font-variant-numeric: tabular-nums;color: var(--ink-2);cursor: pointer;user-select: none;}.tuner > .btn {margin-top: 6px;}.tune-record {display: flex;flex-direction: column;gap: 8px;margin-top: 18px;}.tune-note {height: 34px;padding: 0 12px;border: 0;border-radius: 10px;background: var(--fill);font-size: 13px;}.tune-record .btn {justify-content: center;}.tune-list {2 unmodified linesgap: 8px;}.tune-list .hint {white-space: normal;}.tune-item {padding: 10px 12px;border-radius: 12px;background: var(--fill);font-size: 12.5px;}.tune-item-head {4 unmodified lines}.tune-when {color: var(--ink-2);text-transform: none;font-variant-numeric: tabular-nums;}8 unmodified lines.tune-summary {margin-top: 4px;line-height: 1.4;color: var(--ink-2);}.tune-item-actions,3 unmodified linesmargin-top: 8px;}.tune-item .btn {background: #fff;}.tune-flash {min-height: 1em;margin: 8px 0 0;font-size: 12.5px;color: #248a3d;}/* ---- Draggable hands ---- */29 unmodified linesbackground: #fff;color: var(--ink);box-shadow:0 0 0 0.5px rgba(0, 0, 0, 0.08),0 1px 2px rgba(0, 0, 0, 0.1),0 4px 12px rgba(0, 0, 0, 0.08);cursor: pointer;transition:transform 140ms ease,box-shadow 140ms ease;animation: magnet-in 160ms var(--ease);}.magnet:hover {transform: scale(1.08);}.magnet:active {transform: scale(0.94);}.magnet[hidden] {display: none;}3 unmodified linesopacity: 0;transform: scale(0.6);}}/* Invisible safe hover zone between a pinned hand and its magnet button (shown with debug). */21 unmodified linesstroke: rgba(255, 157, 0, 0.6);stroke-dasharray: 4 3;}/* While the sheet is open, keep the toolbar centred in the space left of it. */.dock {transition: left 320ms var(--ease);}.sheet-open .dock {left: calc(50% - 176px);}.btn.ghost.active {background: var(--fill-strong);}/* Hint text for mouse vs touch */.for-touch {display: none;}@media (hover: none) {.for-pointer {display: none;}.for-touch {display: inline;}}/* ---- Small screens: toolbar wraps to two rows, the sheet comes up from the bottom ---- */@media (max-width: 760px) {.brand h1 {font-size: 14px;}.actions .btn.ghost span {display: none;}.dock,.sheet-open .dock {left: 12px;right: 12px;bottom: 12px;transform: none;max-width: none;}.hint {white-space: normal;text-align: center;}.toolbar {flex-wrap: wrap;justify-content: center;row-gap: 4px;border-radius: 20px;}.toolbar .divider {display: none;}.chips {width: 100%;justify-content: center;}.mini span {display: none;}.mini input[type='range'] {width: 84px;}.sheet {top: auto;left: 8px;right: 8px;bottom: 8px;width: auto;max-height: 78dvh;animation-name: sheet-up;}@keyframes sheet-up {from {opacity: 0;transform: translateY(24px);}}}@media (prefers-reduced-motion: reduce) {*,*::before,*::after {animation-duration: 1ms !important;transition-duration: 1ms !important;}}@media (prefers-reduced-transparency: reduce) {.toolbar,.menu,.sheet {background: #fff;backdrop-filter: none;-webkit-backdrop-filter: none;}}
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263// Page chrome behaviour: export menu, "Advanced tweaking" sheet, first-use hint and toasts.// The scene and its controls are wired in main.ts; this only opens / closes the chrome.
const $ = <T extends HTMLElement>(id: string) => document.getElementById(id) as T;
// ----- Export menu (anchored to its button; closes on choice, outside click or Esc) -----const exportBtn = $<HTMLButtonElement>('exportBtn');const exportMenu = $<HTMLDivElement>('exportMenu');
function setMenu(open: boolean) { exportMenu.hidden = !open; exportBtn.setAttribute('aria-expanded', String(open)); if (open) exportMenu.querySelector<HTMLButtonElement>('.menu-item')?.focus({ preventScroll: true });}exportBtn.addEventListener('click', (e) => { e.stopPropagation(); setMenu(exportMenu.hidden);});exportMenu.addEventListener('click', () => setMenu(false));document.addEventListener('pointerdown', (e) => { if (!exportMenu.hidden && !(e.target as Element).closest('.menu-anchor')) setMenu(false);});
// ----- Advanced tweaking sheet -----const advancedBtn = $<HTMLButtonElement>('advancedBtn');const advanced = $<HTMLElement>('advanced');
function setSheet(open: boolean) { advanced.hidden = !open; advancedBtn.setAttribute('aria-expanded', String(open)); advancedBtn.classList.toggle('active', open); document.body.classList.toggle('sheet-open', open);}advancedBtn.addEventListener('click', () => setSheet(advanced.hidden));$<HTMLButtonElement>('advancedClose').addEventListener('click', () => { setSheet(false); advancedBtn.focus();});
document.addEventListener('keydown', (e) => { if (e.key !== 'Escape') return; if (!exportMenu.hidden) { setMenu(false); exportBtn.focus(); } else if (!advanced.hidden) { setSheet(false); advancedBtn.focus(); }});
// ----- First-use hint: fades once the logo has been dragged -----const hint = $<HTMLParagraphElement>('hint');$<HTMLElement>('stage').addEventListener('pointerdown', (e) => { if ((e.target as Element).closest('#logoLayer')) hint.classList.add('gone');});
// ----- Toast: status messages show briefly, then clear -----const toast = $<HTMLParagraphElement>('status');let toastTimer = 0;new MutationObserver(() => { window.clearTimeout(toastTimer); if (toast.textContent) toastTimer = window.setTimeout(() => (toast.textContent = ''), 3200);}).observe(toast, { childList: true, characterData: true, subtree: true });index.html+73-36
src/main.ts+14-2
src/style.css+608-158
src/ui.tsAdded+63