Spaces:
Running
Running
Examples: always a dropdown showing the current logo
Browse filesFiles changed (3)
- index.html+3-2
- src/style.css+28-17
- src/ui.ts+21-3
44 unmodified lines45464748495051525344 unmodified lines<span class="for-touch">Drag the logo into Huggy · Pinch to resize and rotate</span></p><div id="toolbar" class="toolbar" role="toolbar" aria-label="Logo"><div class="tgroup" data-group="examples"><button class="tg-btn btn ghost small" aria-haspopup="true" aria-expanded="false"><span>Examples</span><svg class="icon chevron" viewBox="0 0 20 20" aria-hidden="true"><path d="M6 12l4-4 4 4" /></svg></button><div class="tg-panel examples">44 unmodified lines4546474849505152535444 unmodified lines<span class="for-touch">Drag the logo into Huggy · Pinch to resize and rotate</span></p><div id="toolbar" class="toolbar" role="toolbar" aria-label="Logo"><div class="tgroup dropdown" data-group="examples"><button class="tg-btn btn ghost small" aria-haspopup="true" aria-expanded="false"><span class="tg-name">Examples:</span><span id="currentExample" class="tg-current">Pydantic</span><svg class="icon chevron" viewBox="0 0 20 20" aria-hidden="true"><path d="M6 12l4-4 4 4" /></svg></button><div class="tg-panel examples">
563 unmodified lines5645655665675685695705711 unmodified line5735745755765775785798 unmodified lines5885895905915925935945955965975985996006016026036046056064 unmodified lines6116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556562 unmodified lines6596606616626636646656 unmodified lines672673674675676677678563 unmodified linesdisplay: none;}/* Compact: each group is a button that opens its controls in a popover above it. */.toolbar.compact .tg-btn {display: inline-flex;}1 unmodified linedisplay: none;}.toolbar.compact .tg-panel {display: none;position: absolute;bottom: calc(100% + 14px);8 unmodified linesanimation: pop-up 200ms var(--ease);}.toolbar.compact .tgroup.open .tg-panel {display: flex;}.toolbar.compact .tgroup.open .tg-btn {background: var(--fill-strong);}.toolbar.compact .tg-btn .chevron {transition: transform 200ms var(--ease);}.toolbar.compact .tgroup.open .tg-btn .chevron {transform: rotate(180deg);}4 unmodified lines}}/* Examples popover: a vertical list with its label as the title. */.toolbar.compact .examples {flex-direction: column;align-items: stretch;min-width: 168px;}.toolbar.compact .examples .toolbar-label {padding: 2px 8px 6px;}.toolbar.compact .chips {flex-direction: column;gap: 2px;}.toolbar.compact .chip {height: 38px;padding: 0 12px;text-align: left;border-radius: 10px;}.toolbar.compact .chip[aria-pressed='true'] {background: var(--fill);box-shadow: none;}/* Adjust popover: tall vertical sliders (Control Center style) and Reset. */.toolbar.compact .adjust {flex-direction: column;gap: 10px;padding: 14px 14px 10px;}.toolbar.compact .adjust .mini {display: none;}.toolbar.compact .vsliders {display: flex;gap: 14px;}2 unmodified linesopacity: 0;}.toolbar.compact #reset {display: inline-flex;align-items: center;width: auto;6 unmodified linescolor: var(--ink);}.toolbar.compact .reset-label {display: inline;}563 unmodified lines5645655665675685695705715721 unmodified line5745755765775785795808 unmodified lines5895905915925935945955965975985996006016026036046056066074 unmodified lines6126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666672 unmodified lines6706716726736746756766 unmodified lines683684685686687688689563 unmodified linesdisplay: none;}/* Dropdown groups (Examples always; Adjust when space is tight): a button that opens itscontrols in a popover above it. */.tgroup.dropdown .tg-btn {display: inline-flex;}1 unmodified linedisplay: none;}.tgroup.dropdown .tg-panel {display: none;position: absolute;bottom: calc(100% + 14px);8 unmodified linesanimation: pop-up 200ms var(--ease);}.tgroup.dropdown.open .tg-panel {display: flex;}.tgroup.dropdown.open .tg-btn {background: var(--fill-strong);}.tgroup.dropdown .tg-btn .chevron {transition: transform 200ms var(--ease);}.tgroup.dropdown.open .tg-btn .chevron {transform: rotate(180deg);}4 unmodified lines}}/* Examples button: "Examples: <current>" */.tg-name {color: var(--ink-3);font-weight: 400;}.tg-current {text-transform: capitalize;}/* Examples popover: a vertical list with its label as the title. */.tgroup.dropdown .examples {flex-direction: column;align-items: stretch;min-width: 168px;}.tgroup.dropdown .examples .toolbar-label {padding: 2px 8px 6px;}.tgroup.dropdown .chips {flex-direction: column;gap: 2px;}.tgroup.dropdown .chip {height: 38px;padding: 0 12px;text-align: left;border-radius: 10px;}.tgroup.dropdown .chip[aria-pressed='true'] {background: var(--fill);box-shadow: none;}/* Adjust popover: tall vertical sliders (Control Center style) and Reset. */.tgroup.dropdown .adjust {flex-direction: column;gap: 10px;padding: 14px 14px 10px;}.tgroup.dropdown .adjust .mini {display: none;}.tgroup.dropdown .vsliders {display: flex;gap: 14px;}2 unmodified linesopacity: 0;}.tgroup.dropdown #reset {display: inline-flex;align-items: center;width: auto;6 unmodified linescolor: var(--ink);}.tgroup.dropdown .reset-label {display: inline;}
99 unmodified lines10010110210310410510610710811 unmodified lines1201211221231241251266 unmodified lines13313413513613713813914014114214314499 unmodified lineshandle.addEventListener('pointerup', release);handle.addEventListener('pointercancel', release);// ----- Toolbar: full inline controls when they fit, otherwise dropdown groups -----const toolbar = $<HTMLDivElement>('toolbar');const groups = Array.from(toolbar.querySelectorAll<HTMLElement>('.tgroup'));function setGroup(g: HTMLElement | null) {for (const x of groups) {11 unmodified lines}// Picking an example closes its list; any click outside closes an open group.toolbar.querySelector('.examples')!.addEventListener('click', (e) => {if ((e.target as Element).closest('.chip') && toolbar.classList.contains('compact')) setGroup(null);});document.addEventListener('pointerdown', (e) => {if (!(e.target as Element).closest('.tgroup')) setGroup(null);6 unmodified linescompactRaf = requestAnimationFrame(() => {const was = toolbar.classList.contains('compact');toolbar.classList.remove('compact');const stage = $<HTMLElement>('stage').getBoundingClientRect();const sheetRoom = document.body.classList.contains('sheet-open') && !small.matches ? 364 : 0;const room = stage.width - sheetRoom - 24;const compact = toolbar.scrollWidth > room;toolbar.classList.toggle('compact', compact);if (!compact) setGroup(null);if (compact !== was) window.dispatchEvent(new Event('layoutchange'));});}99 unmodified lines10010110210310410510610710810911 unmodified lines1211221231241251261271281291301311321331341351361371381391401411426 unmodified lines14915015115215315415515615715815916016116299 unmodified lineshandle.addEventListener('pointerup', release);handle.addEventListener('pointercancel', release);// ----- Toolbar: Examples is always a dropdown; Adjust is inline when it fits, else a dropdown -----const toolbar = $<HTMLDivElement>('toolbar');const groups = Array.from(toolbar.querySelectorAll<HTMLElement>('.tgroup'));const adjustGroup = toolbar.querySelector<HTMLElement>('[data-group="adjust"]')!;function setGroup(g: HTMLElement | null) {for (const x of groups) {11 unmodified lines}// Picking an example closes its list; any click outside closes an open group.toolbar.querySelector('.examples')!.addEventListener('click', (e) => {if ((e.target as Element).closest('.chip')) setGroup(null);});// The Examples button names the logo on stage ("Examples: Pydantic"); none for an upload.const samplesEl = $<HTMLElement>('samples');const currentExample = $<HTMLSpanElement>('currentExample');function updateCurrentExample() {const on = samplesEl.querySelector<HTMLButtonElement>('.chip[aria-pressed="true"]');currentExample.textContent = on?.textContent ?? '';currentExample.hidden = !on;}new MutationObserver(updateCurrentExample).observe(samplesEl, {subtree: true,childList: true,attributes: true,attributeFilter: ['aria-pressed'],});document.addEventListener('pointerdown', (e) => {if (!(e.target as Element).closest('.tgroup')) setGroup(null);6 unmodified linescompactRaf = requestAnimationFrame(() => {const was = toolbar.classList.contains('compact');toolbar.classList.remove('compact');adjustGroup.classList.remove('dropdown');const stage = $<HTMLElement>('stage').getBoundingClientRect();const sheetRoom = document.body.classList.contains('sheet-open') && !small.matches ? 364 : 0;const room = stage.width - sheetRoom - 24;const compact = toolbar.scrollWidth > room;toolbar.classList.toggle('compact', compact);adjustGroup.classList.toggle('dropdown', compact);if (!compact && adjustGroup.classList.contains('open')) setGroup(null);if (compact !== was) window.dispatchEvent(new Event('layoutchange'));});}
index.html+3-2
src/style.css+28-17
src/ui.ts+21-3