diff --git a/public/nimble/behaviors.js b/public/nimble/behaviors.js index 9872254..9a7ee20 100644 --- a/public/nimble/behaviors.js +++ b/public/nimble/behaviors.js @@ -19,6 +19,8 @@ Confirm NimbleUI.confirm({title, message, confirmLabel, cancelLabel, danger}) -> Promise Install [data-install] (button, hidden until the browser says the app can be installed; shows a download-arrow icon, no text (in a menu row put next to the label); click = install prompt; hidden once installed or when already running as an installed app; needs a web app manifest; iOS has no install prompt, so it stays hidden there) + File drop [data-filedrop] (e.g. .dropzone): drop files on it or click/Enter to choose; optional data-filedrop-input="#fileInput" (an ), data-filedrop-accept=".json,.csv"; + event nimble:filedrop {files: File[]} (files not matching the accept list are ignored); the zone gets .is-over while dragging over it Menu [data-menu-toggle="#id"] + .menu[hidden] > [role=menuitem]; arrows/Home/End/Esc; event nimble:menuselect {item, value} Tabs [data-tabs] > [role=tablist] > [role=tab][aria-controls]; panels [role=tabpanel]; event nimble:tab {tab, panel} Toast NimbleUI.toast(text, {tone:'warn', duration:3200}) */ @@ -518,6 +520,33 @@ if (ev.userChoice) ev.userChoice.then(function (c) { document.dispatchEvent(new CustomEvent('nimble:install', { detail: { outcome: c && c.outcome } })); }); }); + /* ═════════════ file drop ═════════════ */ + function dropOk(zone, f) { + var acc = zone.getAttribute('data-filedrop-accept'); if (!acc) return true; + var n = f.name.toLowerCase(); + return acc.toLowerCase().split(',').some(function (a) { a = a.trim(); return a && (a.charAt(0) === '.' ? n.slice(-a.length) === a : f.type === a || (a.slice(-2) === '/*' && f.type.indexOf(a.slice(0, -1)) === 0)); }); + } + function dropEmit(zone, list) { + var files = Array.prototype.slice.call(list || []).filter(function (f) { return dropOk(zone, f); }); + if (files.length) emit(zone, 'nimble:filedrop', { files: files }); + } + document.addEventListener('dragover', function (e) { + var z = e.target.closest && e.target.closest('[data-filedrop]'); + if (z && e.dataTransfer && Array.prototype.indexOf.call(e.dataTransfer.types || [], 'Files') >= 0) { e.preventDefault(); z.classList.add('is-over'); } + }); + document.addEventListener('dragleave', function (e) { var z = e.target.closest && e.target.closest('[data-filedrop]'); if (z && !z.contains(e.relatedTarget)) z.classList.remove('is-over'); }); + document.addEventListener('drop', function (e) { + var z = e.target.closest && e.target.closest('[data-filedrop]'); if (!z) return; + e.preventDefault(); z.classList.remove('is-over'); dropEmit(z, e.dataTransfer && e.dataTransfer.files); + }); + function dropPick(z) { var i = z.getAttribute('data-filedrop-input') && $(z.getAttribute('data-filedrop-input')); if (i) i.click(); } + document.addEventListener('click', function (e) { var z = e.target.closest && e.target.closest('[data-filedrop]'); if (z && !e.target.closest('input,button,a')) dropPick(z); }); + document.addEventListener('keydown', function (e) { var z = e.target.closest && e.target.closest('[data-filedrop]'); if (z && z === e.target && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); dropPick(z); } }); + document.addEventListener('change', function (e) { + var t = e.target; if (!t || t.type !== 'file' || !t.id) return; + var z = document.querySelector('[data-filedrop-input="#' + t.id + '"]'); if (z) { dropEmit(z, t.files); } + }); + /* ═════════════ boot ═════════════ */ function init(root) { refreshSortable(root); refreshEditable(root); initTabs(root); refreshInstall(); } NS.init = init; diff --git a/public/nimble/components.css b/public/nimble/components.css index ad52f56..52177d7 100644 --- a/public/nimble/components.css +++ b/public/nimble/components.css @@ -1,7 +1,7 @@ /* ═══════════════════════════════════════ nimbleUI — components (GENERATED by tools/build-css.mjs from src/css/*.css; edit those, not this file) Needs tokens.css first. Only colours come from tokens; nothing here depends on the theme. - Modules: base, controls, overlays, board, page. + Modules: base, controls, overlays, board, shelf, page. ═══════════════════════════════════════ */ /* nimbleUI · base — reset, document defaults, focus ring, utilities (.wrap .ico .grow .mono .dim .sr-only), reduced motion. Load first; skip it in an app that has its own reset. @@ -282,6 +282,44 @@ html.is-sorting, html.is-sorting * { cursor: grabbing !important; user-select: n .listrow__sub { color: var(--muted); font-size: .8125rem; } .listrow__actions { display: flex; align-items: center; gap: 2px; margin-left: auto; } +/* nimbleUI · shelf, matrix, dropzone — collapsible bars that also accept drops, a 2×2 matrix, and a file drop target. + Shelf is a
: no script to open/close. Sortable drops onto a collapsed shelf use data-sortable-drop on the summary. */ +.shelf { --tone: var(--muted); background: color-mix(in srgb, var(--tone) 7%, var(--surface)); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; } +.shelf--ok { --tone: var(--success); } +.shelf--info { --tone: var(--info); } +.shelf--warn { --tone: var(--warn); } +.shelf__head { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; cursor: pointer; list-style: none; user-select: none; } +.shelf__head::-webkit-details-marker { display: none; } +.shelf__head:hover { background: color-mix(in srgb, var(--tone) 8%, transparent); } +.shelf__label { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); } +.shelf__head:hover .shelf__label { color: var(--tone); } +.shelf__count { min-width: 22px; padding: 0 8px; border: 1px solid var(--tone); border-radius: 999px; background: color-mix(in srgb, var(--tone) 12%, transparent); color: var(--tone); font-size: .6875rem; font-weight: 700; text-align: center; line-height: 20px; } +.shelf__hint { margin-left: auto; color: var(--subtle, var(--muted)); font-size: .6875rem; opacity: 0; transition: opacity var(--fast) var(--ease); } +.shelf__head:hover .shelf__hint { opacity: 1; } +.shelf__chev { margin-left: auto; display: inline-flex; color: var(--muted); transition: transform var(--norm) var(--ease); } +.shelf__hint + .shelf__chev { margin-left: 0; } +.shelf[open] > .shelf__head .shelf__chev { transform: rotate(180deg); } +.shelf__actions { display: inline-flex; gap: 6px; } +.shelf__body { max-height: 252px; overflow: auto; padding: 4px 12px 10px; scrollbar-width: thin; } +.shelf__list { display: flex; flex-direction: column; gap: 4px; } +.shelf__empty { padding: 8px 0; color: var(--muted); font-size: .75rem; text-align: center; } +.shelf.is-over, .shelf [data-sortable-over], .shelf.over { outline: 2px dashed var(--tone); outline-offset: -2px; } + +.matrix { display: grid; grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr); gap: 10px; min-height: 360px; } +.matrix__axis { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; } +.matrix__axis--y span { writing-mode: vertical-rl; transform: rotate(180deg); } +.matrix__quad { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); } +.matrix__quad--hl { background: color-mix(in srgb, var(--primary) 8%, var(--surface)); border-color: var(--primary); } +.matrix__head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .75rem; font-weight: 700; } +.matrix__count { padding: 0 8px; border-radius: 999px; background: var(--surface-2); font-size: .6875rem; font-weight: 600; } +.matrix__cards { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; } +@media (max-width: 560px) { .matrix { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; } .matrix__axis { display: none; } } + +.dropzone { display: grid; gap: 6px; justify-items: center; padding: 22px 16px; border: 2px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2); color: var(--muted); font-size: .875rem; text-align: center; cursor: pointer; transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease); } +.dropzone:hover, .dropzone:focus-visible, .dropzone.is-over { border-color: var(--primary); color: var(--text); background: color-mix(in srgb, var(--primary) 8%, var(--surface-2)); } +.dropzone__title { color: var(--text); font-weight: 600; } +.dropzone__hint { font-size: .75rem; } + /* nimbleUI · page — .topbar/.brand/.nav, .hero, landing blocks (.lp-*, .fcard, .steps, .snippet, .grid2/3), legal pages (.doc). Needs tokens.css. Generated into components.css by tools/build-css.mjs (edit this file, then run the script). */ /* ── Top bar ─────────────────────────────────────────────────────────────── */