diff --git a/README.md b/README.md index eaa5f73..567e292 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Pass `groupFolder: true` to `createProjectClient` to use the extension’s folde ### Project overview -Use the ISA Match layout for a project-based extension. Show recent activity on the left and **Projects** (**Projecten**) on the right. Place **+ Create project** at the top right of the Projects panel. Populate this list on launch with `await client.list()`, which returns active projects for the configured storage mode. `client.recent()` supplies optional personal shortcuts. Use the project rows to open existing projects and the create button to launch the setup form. +The shared project picker provides the ISA Match layout using the host theme tokens. Its header cards count active projects and accessible recent projects across the full inventory, including while searching. An embedded picker keeps its host extension’s summary header. While the inventory loads, the picker shows animated placeholder rows and keeps existing rows visible during refresh. Extensions can also use `mountProjectListSkeleton(target)` from `@isa-warden/isa-project-format/dom` during startup. Show recent activity on the left and **Projects** (**Projecten**) on the right. Place **+ Create project** at the top right of the Projects panel. Populate this list on launch with `await client.list()`, which returns active projects for the configured storage mode. `client.recent()` supplies optional personal shortcuts. Use the project rows to open existing projects and the create button to launch the setup form. Use the shared `ProjectWorkspace` or `mountProjectWorkspace` with the extension display name, locale and launch-scoped client. Custom overviews in picker-based mode can call `client.pickFolder()` from a user action and refresh `client.list()` after a selection. The picker can select a container such as `/shared` or a single existing `.isap` folder. The extension remembers selected paths for the launch scope and reads only through its ordinary filesystem grants. Use `client.openListed(row)` to reopen a project, `client.create(name, operationId)` to create it in an editable container, and `client.setArchived(row, archived)` to update the manifest. Extensions need the host permissions for filesystem reads, optional writes, and private preferences. diff --git a/src/dom.d.ts b/src/dom.d.ts index f3b3d06..c756fb7 100644 --- a/src/dom.d.ts +++ b/src/dom.d.ts @@ -11,3 +11,4 @@ export interface ProjectMountOptions { } export function mountProjectWorkspace(target: HTMLElement, options: ProjectMountOptions): {destroy(): void}; export function mountProjectHeader(target: HTMLElement, options: ProjectMountOptions): {destroy(): void}; +export function mountProjectListSkeleton(target: HTMLElement): {destroy(): void}; diff --git a/src/dom.js b/src/dom.js index a0a89fd..bbe58a2 100644 --- a/src/dom.js +++ b/src/dom.js @@ -147,3 +147,5 @@ export function mountProjectWorkspace(target, {client,bridge,locale='en',extensi } export function mountProjectHeader(target,options) {return mountProjectWorkspace(target,{...options,mode:'header'});} + +export { mountProjectListSkeleton } from './project-list-skeleton.js'; diff --git a/src/overview.js b/src/overview.js index 018c237..f9b4073 100644 --- a/src/overview.js +++ b/src/overview.js @@ -1,3 +1,4 @@ +import { mountProjectListSkeleton } from './project-list-skeleton.js'; import { workspaceElements } from './workspace-elements.js'; // A row identifies a folder accessible through the current launch's grants. Private @@ -20,6 +21,22 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm const root = element('section', '', 'isa-group-home'); const header = element('header'); header.append(element('h1', extensionName || text.projects)); + const summary = element('dl', '', 'isa-group-summary'); + function addCount(heading, label, symbol) { + if (onOverview) { + const badge = element('span', '', 'isa-group-count'); + heading.append(badge); + return badge; + } + const card = element('div'); + const term = element('dt', label); + term.prepend(icon(symbol)); + const value = element('dd', '—'); + card.append(term, value); + summary.append(card); + return value; + } + header.append(summary); const actions = element('div', '', 'isa-project-toolbar'); const refreshButton = button(text.refresh, refresh); refreshButton.className = 'isa-extension-button isa-extension-button--secondary'; @@ -43,8 +60,6 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm const activity = element('aside'); const recent = element('div'); const recentTitle = element('h2', text.recent); - const recentCount = element('span', '', 'isa-group-count'); - recentTitle.append(recentCount); activity.append(recentTitle, recent); const panel = element('section', '', 'isa-group-projects'); const heading = element('header'); @@ -52,8 +67,8 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm create.className = 'isa-extension-button isa-extension-button--primary'; create.prepend(icon('plus')); const panelTitle = element('h2', text.projects); - const projectCount = element('span', '', 'isa-group-count'); - panelTitle.append(projectCount); + const projectCount = addCount(panelTitle, text.projects, 'folder'); + const recentCount = addCount(recentTitle, text.recent, 'clock'); panelTitle.id = 'isa-projects-' + crypto.randomUUID(); panel.setAttribute('aria-labelledby',panelTitle.id); heading.append(panelTitle); @@ -71,14 +86,15 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm const option = element('option',label); option.value = value; sort.append(option); } controls.append(search,sort); - const alert = element('p'); + const alert = element('p', '', 'isa-group-alert'); alert.setAttribute('role','alert'); const list = element('div', '', 'isa-group-rows'); const columns = element('div', '', 'isa-project-columns'); columns.append(element('span', text.name), element('span', text.owner), element('span', text.creationDate)); - const status = element('p'); + const status = element('p', '', 'isa-group-announcement'); status.setAttribute('role','status'); - panel.append(heading,controls,alert,status,columns,list); + panel.append(heading,controls,columns,list); + mountProjectListSkeleton(panel); grid.append(activity,panel); const dialog = element('dialog', '', 'isa-project-create-dialog'); const title = element('h2', text.createTitle); @@ -102,7 +118,7 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm dialog.append(title,form,progress); if (!onOverview) root.append(header); else root.classList.add('isa-group-home-embedded'); - root.append(grid,dialog); + root.append(alert,grid,status,dialog); target.append(root); let projects = [], recents = [], loading = true, hasInventory = false, busy = false, alive = true; @@ -119,7 +135,7 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm row = button(); row.dataset.projectId = project.id; if (detailed) { - row.append(element('strong'), element('small'), element('time')); + row.append(element('span', '', 'isa-project-name'), element('small'), element('time')); } } existing.delete(project.id); @@ -127,7 +143,7 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm row.setAttribute('aria-busy', String(openingId === project.id)); const firstUse = project.hasInstance === false && project.canWrite && !project.archived; if (detailed) { - row.querySelector('strong').textContent = project.name; + row.querySelector('.isa-project-name').textContent = project.name; row.querySelector('small').textContent = project.hasInstance === false ? text.noInstance : project.instanceCreatorName || '—'; row.title = firstUse ? text.createInstance : ''; row.querySelector('time').textContent = Number.isFinite(Date.parse(project.instanceCreatedAt)) ? date.format(new Date(project.instanceCreatedAt)) : '—'; @@ -154,8 +170,9 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm } const recentProjects = recents.map(item => projects.find(project => project.id === item.id)).filter(Boolean); updateRows(recent, recentProjects, false); - projectCount.textContent = hasInventory ? String(visible.length) : ''; - recentCount.textContent = hasInventory ? String(recentProjects.length) : ''; + const unknownCount = onOverview ? '' : '—'; + projectCount.textContent = hasInventory ? String(onOverview ? visible.length : projects.length) : unknownCount; + recentCount.textContent = hasInventory ? String(recentProjects.length) : unknownCount; if (!recent.childElementCount && hasInventory) recent.append(element('p',text.noActivity)); syncControls(); } diff --git a/src/prepared-documents.js b/src/prepared-documents.js index d389777..c33dc17 100644 --- a/src/prepared-documents.js +++ b/src/prepared-documents.js @@ -19,7 +19,8 @@ export function isPrepared(doc) { async function verifiedText(session,path,hash) { const file = await session.readFile(path); if (file.status === 'absent') return null; - const text = typeof file.text === 'string' ? file.text : new TextDecoder('utf-8',{fatal:true}).decode(Uint8Array.from(atob(file.bytesBase64),c=>c.charCodeAt(0))); + const text = typeof file.bytesBase64 === 'string' + ? new TextDecoder('utf-8',{fatal:true,ignoreBOM:true}).decode(Uint8Array.from(atob(file.bytesBase64),c=>c.charCodeAt(0))) : file.text; if (await digest(text) !== hash) throw new Error('Prepared document integrity check failed'); return text; } diff --git a/src/project-list-skeleton.js b/src/project-list-skeleton.js new file mode 100644 index 0000000..0e1d93c --- /dev/null +++ b/src/project-list-skeleton.js @@ -0,0 +1,52 @@ +// Both the extension startup view and the live picker use these decorative rows. +const styles = ` +.isa-project-list-skeleton { + container-type:inline-size; + --skeleton-line:var(--isa-extension-border-subtle,ButtonBorder); + --skeleton-highlight:var(--isa-extension-panel-bg,Canvas); +} +.isa-project-list-skeleton > div { + display:grid; + grid-template-columns:minmax(0,1fr) minmax(8rem,24%) 7rem; + align-items:center; + gap:.375rem .75rem; + min-height:2rem; + padding:.375rem .5rem; + box-sizing:border-box; +} +.isa-project-list-skeleton > div + div {border-block-start:1px solid var(--skeleton-line)} +.isa-project-list-skeleton span { + width:75%; + height:.65rem; + border-radius:var(--isa-extension-radius-detail,.5rem); + background:linear-gradient(90deg,var(--skeleton-line) 25%,var(--skeleton-highlight) 50%,var(--skeleton-line) 75%); + background-size:200% 100%; +} +.isa-project-list-skeleton > div:nth-of-type(even) > span:first-child {width:55%} +.isa-project-list-skeleton span:last-child {width:58%;justify-self:end} +@container (max-width:34rem) { + .isa-project-list-skeleton > div {grid-template-columns:minmax(0,1fr) minmax(3rem,24%);padding-block:.5rem} + .isa-project-list-skeleton span:first-child {grid-column:1 / -1} +} +@media (prefers-reduced-motion:no-preference) { + .isa-project-list-skeleton span {animation:isa-project-list-shimmer 1.5s ease-in-out infinite} +} +@keyframes isa-project-list-shimmer {from {background-position:200% 0} to {background-position:0 0}} +`; + +export function mountProjectListSkeleton(target) { + const document = target.ownerDocument; + const skeleton = document.createElement('div'); + skeleton.className = 'isa-project-list-skeleton'; + skeleton.setAttribute('aria-hidden', 'true'); + const style = document.createElement('style'); + style.textContent = styles; + skeleton.append(style); + for (let index = 0; index < 4; index++) { + const row = document.createElement('div'); + row.append(document.createElement('span'), document.createElement('span'), document.createElement('span')); + skeleton.append(row); + } + target.append(skeleton); + return { destroy: () => skeleton.remove() }; +} diff --git a/src/styles.js b/src/styles.js index a92c9f7..2ae335b 100644 --- a/src/styles.js +++ b/src/styles.js @@ -104,31 +104,119 @@ export const styles = ` .isa-project-controls {width:100%} } -.isa-group-home {display:grid;gap:9px;padding:10px;min-height:75vh;grid-template-rows:auto 1fr;background:var(--isa-extension-app-bg,var(--isa-extension-panel-bg,Canvas))} -.isa-group-home > header,.isa-group-projects {background:var(--isa-extension-card-bg,Canvas);border:1px solid var(--isa-extension-border-subtle,GrayText);border-radius:14px;padding:14px 18px} -.isa-group-home header {display:flex;gap:12px;align-items:center;justify-content:space-between;flex-wrap:wrap} +/* Project launchers share these surfaces inside the extension iframe. */ +.isa-group-home { + display:grid; + align-content:start; + gap:.625rem; + padding:var(--isa-extension-shell-gutter,1rem); +} +.isa-group-home > header,.isa-group-grid > aside,.isa-group-projects { + min-width:0; + padding:.875rem 1rem; + border:1px solid var(--isa-extension-border-subtle,ButtonBorder); + border-radius:var(--isa-extension-radius-control,.75rem); + background:var(--isa-extension-panel-bg,Canvas); +} +.isa-group-home header {display:flex;align-items:center;flex-wrap:wrap;gap:.75rem 1.5rem} +.isa-group-home header > .isa-project-toolbar,.isa-group-projects header > button {margin-inline-start:auto} .isa-group-home h1,.isa-group-home h2,.isa-group-home p {margin:0} -.isa-group-home h1 {font-size:1.15rem} -.isa-group-home h2 {font-size:.86rem} +.isa-group-home h1 {font-size:var(--isa-extension-font-size-xl,1.25rem);line-height:1.15;letter-spacing:normal} +.isa-group-grid h2 {font-size:var(--isa-extension-font-size-base,1rem);letter-spacing:normal} +.isa-group-summary { + flex:1 1 20rem; + display:grid; + grid-template-columns:repeat(auto-fit,minmax(min(100%,10rem),1fr)); + max-width:32rem; + margin:0; + gap:.5rem; +} +.isa-group-summary > div { + display:flex; + align-items:center; + justify-content:space-between; + gap:.5rem; + padding:.5rem .75rem; + min-height:2.5rem; + border:1px solid var(--isa-extension-border-subtle,ButtonBorder); + border-radius:var(--isa-extension-radius-detail,.5rem); + background:var(--isa-extension-panel-bg-muted,ButtonFace); +} +.isa-group-summary dt {display:flex;align-items:center;gap:.5rem;font-size:var(--isa-extension-font-size-sm,.875rem)} +.isa-group-summary svg {color:var(--isa-extension-primary-strong,Highlight)} +.isa-group-summary dd {margin:0;font-weight:600;font-variant-numeric:tabular-nums} .isa-group-count:not(:empty) {display:inline-block;margin-inline-start:.5rem;padding:.1rem .45rem;border-radius:1rem;background:var(--isa-extension-panel-bg-muted,ButtonFace);font-size:.8em;letter-spacing:normal;vertical-align:middle} -.isa-group-grid {display:grid;grid-template-columns:minmax(140px, .42fr) minmax(0,1fr);gap:10px} -.isa-group-grid aside {padding:16px;color:var(--isa-extension-panel-muted,GrayText)} -.isa-group-grid aside div {display:grid;gap:4px;margin-top:10px} -.isa-group-grid aside button {border:0;background:transparent;padding-inline:0} -.isa-group-projects {display:flex;flex-direction:column;gap:14px;min-width:0} -.isa-group-projects h2 {text-transform:uppercase;letter-spacing:.08em} -.isa-group-projects select {font:inherit;color:inherit;background:var(--isa-extension-control-bg,Canvas);border:1px solid var(--isa-extension-border-subtle,GrayText);border-radius:.5rem;padding:.5rem;max-width:100%} -.isa-group-home.isa-group-home-embedded {min-height:0;grid-template-rows:auto;padding:0;background:transparent} -.isa-group-home-embedded .isa-group-projects,.isa-group-home-embedded aside {border:1px solid var(--isa-extension-border-subtle,GrayText);border-radius:var(--isa-extension-radius-md,.625rem);background:var(--isa-extension-card-bg,Canvas)} -.isa-group-rows {display:grid;gap:3px} -.isa-project-columns,.isa-group-rows button {box-sizing:border-box;display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr) minmax(0,.8fr);align-items:center;gap:8px;text-align:start;padding:6px 10px} -.isa-project-columns {font-size:.8em;font-weight:600;overflow-wrap:anywhere;border:1px solid transparent} +.isa-group-grid {display:grid;align-items:start;grid-template-columns:minmax(0,.42fr) minmax(0,1fr);gap:.625rem} +.isa-group-grid aside > div {display:grid;margin-top:.5rem;max-height:24rem;overflow:auto} +.isa-group-grid aside button,.isa-group-rows button { + min-width:0; + min-height:2rem; + padding:.375rem .5rem; + border:0; + border-radius:0; + background:transparent; + color:inherit; + font:inherit; + font-size:var(--isa-extension-font-size-sm,.875rem); + font-weight:400; + line-height:1.4; + text-align:start; + overflow-wrap:anywhere; +} +.isa-group-home [data-project-id]:is(:hover,:focus-visible,[aria-busy=true]) {background:var(--isa-extension-primary-soft,ButtonFace)} +.isa-group-home [data-project-id]:focus-visible {outline:2px solid var(--isa-extension-focus-outline,Highlight);outline-offset:-2px} +.isa-group-projects {container:isa-project-panel / inline-size;display:grid;align-content:start;gap:0} +.isa-project-ui .isa-group-projects > .isa-project-toolbar {display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.375rem;margin:.5rem 0} +.isa-group-projects input[type=search] {min-width:0;width:100%} +.isa-group-projects select {width:auto;max-width:100%;font:inherit;color:inherit;background:var(--isa-extension-control-bg,Canvas);border:1px solid var(--isa-extension-border-subtle,ButtonBorder);border-radius:var(--isa-extension-radius-control,.75rem);padding:.375rem .5rem} +.isa-group-home.isa-group-home-embedded {padding:0} +.isa-group-rows {display:grid} +.isa-project-columns,.isa-group-rows button { + box-sizing:border-box; + display:grid; + grid-template-columns:minmax(0,1fr) minmax(8rem,24%) 7rem; + align-items:center; + column-gap:.75rem; + padding:.375rem .5rem; +} +.isa-project-columns {font-size:var(--isa-extension-font-size-xs,.8125rem);font-weight:600;overflow-wrap:anywhere;color:var(--isa-extension-panel-muted,GrayText);background:var(--isa-extension-panel-bg-muted,ButtonFace)} .isa-project-columns[hidden] {display:none} .isa-project-columns span:last-child,.isa-group-rows time {text-align:end} -.isa-group-rows button {width:100%;border-radius:6px;border-color:var(--isa-extension-border-subtle,GrayText);background:var(--isa-extension-card-bg,Canvas)} -.isa-group-rows strong,.isa-group-rows small {display:block;overflow-wrap:anywhere} -.isa-group-rows small,.isa-group-rows time {color:var(--isa-extension-panel-muted,GrayText);font-size:.8em} +.isa-group-rows button + button,.isa-group-grid aside button + button {border-block-start:1px solid var(--isa-extension-border-subtle,ButtonBorder)} +.isa-group-rows .isa-project-name {font-weight:600} +.isa-group-home:not(.isa-group-home-embedded) .isa-group-projects h2 {font-size:var(--isa-extension-font-size-lg,1.125rem)} +@media (min-width:641px) { + .isa-group-home:not(.isa-group-home-embedded) {display:flex;flex-direction:column} + .isa-group-home:not(.isa-group-home-embedded) > .isa-group-grid { + flex:1; + align-items:stretch; + grid-template-columns:clamp(12rem,24%,21rem) minmax(0,1fr); + } + .isa-group-home:not(.isa-group-home-embedded) .isa-group-grid > aside { + background:color-mix(in srgb,var(--isa-extension-panel-bg,Canvas) 94%,var(--isa-extension-panel-muted,GrayText)); + } + .isa-group-home:not(.isa-group-home-embedded) .isa-group-grid aside > div {max-height:none} +} +.isa-group-rows small,.isa-group-rows time,.isa-group-grid aside p {margin:0;color:var(--isa-extension-panel-muted,GrayText);font-size:var(--isa-extension-font-size-xs,.8125rem)} .isa-group-home p:empty {display:none} +.isa-group-rows:not(:empty) + .isa-project-list-skeleton, +.isa-group-rows:not([aria-busy=true]) + .isa-project-list-skeleton {display:none} +.isa-group-announcement { + position:absolute; + width:1px; + height:1px; + overflow:hidden; + clip-path:inset(50%); + white-space:nowrap; +} +@container isa-project-panel (max-width:34rem) { + .isa-group-home .isa-project-columns {display:none} + .isa-group-home .isa-group-rows button {grid-template-columns:minmax(0,1fr) auto;row-gap:.125rem} + .isa-group-rows .isa-project-name {grid-column:1 / -1} +} +@container isa-project-panel (max-width:22rem) { + .isa-project-ui .isa-group-projects > .isa-project-toolbar {grid-template-columns:minmax(0,1fr)} +} .isa-group-home dialog form,.isa-group-home dialog label {display:grid;gap:10px} .isa-group-home dialog h2 {margin-bottom:14px} .isa-project-ui dialog.isa-project-create-dialog {box-sizing:border-box;width:min(28rem,calc(100% - 2rem));padding:1.5rem;border-radius:var(--modal-shell-radius,1rem);background:var(--modal-shell-bg,var(--isa-extension-panel-bg,Canvas));box-shadow:0 12px 48px rgb(0 0 0/.18)} @@ -139,5 +227,5 @@ export const styles = ` .isa-project-create-progress:not(:empty)::before {content:'';width:.85rem;height:.85rem;border:2px solid currentColor;border-inline-end-color:transparent;border-radius:50%;animation:isa-project-spin .8s linear infinite} @keyframes isa-project-spin {to {transform:rotate(360deg)}} @media(prefers-reduced-motion:reduce){.isa-project-create-progress::before {animation:none!important}} -@media(max-width:640px){.isa-group-grid {grid-template-columns:minmax(0,1fr)}.isa-group-projects {grid-row:1}.isa-group-home {min-height:0}.isa-group-home header {gap:8px}} +@media(max-width:640px){.isa-group-grid {grid-template-columns:minmax(0,1fr)}.isa-group-projects {grid-row:1}.isa-group-home {padding:.5rem}.isa-group-home header {gap:.5rem}.isa-group-summary {flex-basis:100%}.isa-group-home > header > .isa-project-toolbar {margin-inline-start:0}.isa-group-grid aside > div {max-height:12rem}} `; diff --git a/src/workspace-elements.js b/src/workspace-elements.js index 6afd534..bde1ced 100644 --- a/src/workspace-elements.js +++ b/src/workspace-elements.js @@ -1,5 +1,6 @@ const paths = { plus: 'M12 5v14 M5 12h14', + clock: 'M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0Z M12 6v6l4 2', refresh: 'M20 7v5h-5 M4 17v-5h5 M6 7a7 7 0 0 1 12-1l2 3 M4 15l2 3a7 7 0 0 0 12-1', folder: 'M3 7V5a1 1 0 0 1 1-1h5l2 3h9a1 1 0 0 1 1 1v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z', files: 'M7 3h9l4 4v11H7z M15 3v5h5 M4 7v14h12',