Use meaningful relationship ribbon icons and simplify Display

This commit is contained in:
Nick Beckley 2026-10-31 21:03:46 +00:00
parent a9ec410406
commit 7591edacaf
9 changed files with 83 additions and 39 deletions

View File

@ -32,7 +32,7 @@ Not included: cross-device layout storage, automatic importance suggestions, tim
The page is now a single bounded application surface beneath the existing ribbon in browser and PWA mode. A page-scoped shell class removes content-width limits and gutters. Height follows the actual ribbon and viewport via ResizeObserver; internal palettes, history and List scroll without extending the document. The application maximise mode has an explicit restore button and Escape fallback, with no browser fullscreen API.
The toolbar contains Map/List, a named focus chip with clear action, Auto-arrange, Layout and Display. The legend and original selectors are inside Display. The map's fit, zoom, centre and select/pan controls form a floating vertical toolbar. The right rail shares its space between Supporting characters and contextual detail. Character detail is built from the same canonical response and includes existing avatar, importance, relationship count and selectable connections/history. List is a separate workspace view; no standalone list remains beneath the map.
The toolbar contains Map/List, a named focus chip with clear action, Auto-arrange, Layout and Display. The colour key is pinned beneath the right rail. Display exposes network visibility, Story point and maximise/restore; the original selectors are in the Story point dialog. The map's fit, zoom, centre and select/pan controls form a floating vertical toolbar. The right rail shares its space between Supporting characters and contextual detail. Character detail is built from the same canonical response and includes existing avatar, importance, relationship count and selectable connections/history. List is a separate workspace view; no standalone list remains beneath the map.
The timeline retains its existing state resolver, range keyboard navigation and scene defaults. Presentation adds explicit Initial/End buttons, change dots, progress and selected-scene output. Relationship dialogs retain their form and save path, with avatar pairs and subordinate endpoint selectors. Graph nodes retain Cytoscape and category line colours, adding existing portrait paths or generated initials. Node, label, focus, palette and timeline surfaces use the application's semantic theme tokens and update when the active theme changes.
@ -45,3 +45,9 @@ Browser regression coverage additionally checks viewport bounds, complete mobile
Relationships declares its existing toolbar controls as normal `data-pwa-context` contributions. The shell binds commands and form fields to their live sources; there is no second focus, view or maximise state. Layout and Display request the existing compact ribbon menus. A small shared renderer extension honours `data-pwa-compact` for such contributions and copies explicitly declared passive legend content without IDs or interactive controls. Help uses the standard page-help contribution.
Only in standalone mode, accounted contributions suppress the entire secondary toolbar and remove its grid row. The existing viewport measurement gives the space to the canvas. Browser presentation and all importance thresholds, cast assignment, graph, timeline, dialog and persistence logic remain unchanged. PWA maximise keeps the ribbon reachable so its Restore command remains available. `relationships-ribbon.cjs` covers command/state binding, menus, recovered height, mobile overflow and navigation cleanup; the existing relationship and PWA browser suites remain regression gates.
## Ribbon presentation refinement
Workspace commands explicitly select distinct icons from the existing SVG icon catalogue, including new diagram/navigation glyphs where no suitable icon existed. Layout and Display summaries declare their own icons rather than inheriting the first child command's icon. The shared form renderer also honours an explicitly declared field icon.
Display now contains one network-visibility checkbox and two commands: Story point and maximise/restore. The previous GET selectors and update action remain available in a compact Story point dialog. Its network checkbox remains associated with that original GET form, so submitting the selectors preserves network visibility. The colour key is outside the ribbon and fixed beneath the right palette/detail rail. Both browser and PWA Display panels have no scroll container; focused browser tests assert distinct command glyphs and non-scrolling desktop/mobile menus.

View File

@ -23,8 +23,16 @@ const base='http://127.0.0.1:5238';
for(const name of ['Map','List','Full cast','Details','Add relationship','Auto-arrange','Remove focused from map','Reset layout','Characters','Maximise workspace']) await command(name);
for(const name of ['View','Focus','Relationship','Arrange','Layout','Display']) assert(await shell.locator(`.pd-context-group[aria-label="${name}"]`).count(),name+' group');
assert(await shell.locator('[data-help-open]').count(),'Help uses ribbon help');
assert(await shell.locator('.relationship-map-legend-grid').count(),'Display includes existing legend');
assert(await shell.locator('select').count()>=4,'Display retains story selectors');
assert.equal(await shell.locator('.relationship-map-legend-grid').count(),0,'legend removed from ribbon');
assert(await app.locator('.rw-rail .rw-colour-key').isVisible(),'colour key at bottom of right panel');
await (await command('Story point…')).click(); assert(await app.locator('#rwStoryDialog').evaluate(e=>e.open));
assert(await app.locator('#rwStoryDialog select').count()>=4,'story selectors remain available in compact dialog'); await app.locator('#rwCloseStory').click();
const iconPaths=await shell.locator('button.pd-context-command').evaluateAll(nodes=>nodes.map(n=>n.querySelector('svg path')?.getAttribute('d')));
assert(iconPaths.every(Boolean),'every command has a relevant icon'); assert.equal(new Set(iconPaths).size,iconPaths.length,'command icons are distinct');
await command('Maximise workspace');
const display=shell.locator('.pd-context-group[aria-label="Display"] > details > .pd-context-menu-content');
assert(await display.evaluate(e=>e.scrollHeight<=e.clientHeight+1 && e.scrollWidth<=e.clientWidth+1),'Display has no scrolling');
assert(await (await command('Story point…')).isVisible()); assert(await (await command('Maximise workspace')).isVisible());
const geometry=await app.locator('#rwApp').evaluate(e=>({top:e.getBoundingClientRect().top,board:document.getElementById('rwBoard').getBoundingClientRect().top,rows:getComputedStyle(e).gridTemplateRows.split(' ').length}));
assert.equal(geometry.rows,1,'no reserved toolbar grid row');assert(Math.abs(geometry.board-geometry.top)<2,'palettes start immediately, recovered space used');
await (await command('List')).click();assert(await app.locator('#rwListPanel').isVisible());assert.equal(await (await command('List')).getAttribute('aria-pressed'),'true');
@ -44,6 +52,8 @@ const base='http://127.0.0.1:5238';
await (await command('Restore workspace')).click();assert(!(await app.locator('#rwApp').evaluate(e=>e.classList.contains('rw-maximised'))));
await app.setViewportSize({width:390,height:900});await (await command('Characters')).click();assert(await app.locator('.rw-navigation').isVisible(),'mobile cast opens via existing ribbon overflow');
assert(await app.locator('.rw-toolbar').isHidden());
await command('Maximise workspace');
assert(await display.evaluate(e=>e.scrollHeight<=e.clientHeight+1 && e.scrollWidth<=e.clientWidth+1),'mobile Display has no scrolling');
await app.goto(base+'/fixture');assert.equal(await app.locator('[data-pwa-context-controls]').getByRole('button',{name:'Add relationship',exact:true}).count(),0,'navigation clears relationship contributions');
assert.deepEqual(errors,[]);console.log('PASS Relationships ribbon: browser fallback, PWA controls/state/menus, recovered height, mobile overflow and navigation cleanup');
} finally {await browser.close();}

View File

@ -37,7 +37,7 @@ Drag empty canvas to pan. Use **+ / −**, Ctrl/Cmd-wheel, or a two-finger pinch
Installed PWA users can right-click palette characters, map characters, connections or canvas to access the existing application command menu. The same actions are available through buttons, with no right-click required. Select a connection to inspect its history or edit it at the timeline point. **Map / List** switches between workspace views of the same relationship state. The right rail switches between Supporting characters and contextual Details. Focusing a character shows their relationship count, connections, editing actions and history; selecting a connection shows its current state, notes and history.
Positions, focus, zoom, pan and palette collapse are remembered in this browser for the project/book. They do not sync to other devices. On smaller screens, **Characters** opens a searchable drawer containing the whole cast, and **Details** opens the contextual panel. Selecting a character closes the drawer and returns to the map. The canvas and timeline remain the primary surface. **Display** contains the compact relationship legend and the older book/chapter/scene selectors.
Positions, focus, zoom, pan and palette collapse are remembered in this browser for the project/book. They do not sync to other devices. On smaller screens, **Characters** opens a searchable drawer containing the whole cast, and **Details** opens the contextual panel. Selecting a character closes the drawer and returns to the map. The canvas and timeline remain the primary surface. **Display** contains Show full network, **Story point…**, and maximise/restore. Story point opens the existing book/chapter/scene and focus selectors in a separate dialog. The relationship colour key stays at the bottom of the right panel.
# Example

View File

@ -41,6 +41,14 @@ public static class RibbonPresentation
return null;
}
public static IReadOnlyList<RibbonIcon> AdditionalIcons { get; } = [
new("map", "M3 5l6-2 6 2 6-2v16l-6 2-6-2-6 2z M9 3v16 M15 5v16", "relationships"),
new("focus", "M12 2v4 M12 18v4 M2 12h4 M18 12h4 M19 12a7 7 0 1 0-14 0 7 7 0 0 0 14 0 M14 12a2 2 0 1 0-4 0 2 2 0 0 0 4 0", "relationships"),
new("details", "M4 3h16v18H4z M8 7h8 M8 11h8 M8 15h5", "books"),
new("auto-arrange", "M3 3h6v6H3z M15 3h6v6h-6z M3 15h6v6H3z M15 15h6v6h-6z M11 6h2 M6 11v2 M18 11v2 M11 18h2", "planning"),
new("layout", "M3 3h18v18H3z M3 8h18 M8 8v13 M16 8v13", "planning"),
new("display", "M3 4h18v14H3z M8 22h8 M12 18v4", "planning"),
new("maximise", "M9 3H3v6 M15 3h6v6 M3 15v6h6 M21 15v6h-6", "planning"),
new("hide-node", "M5 5h14v14H5z M9 12h6 M2 12h3 M19 12h3", "relationships"),
new("save", "M4 3h13l4 4v14H3V3z M7 3v6h10V3 M7 21v-7h10v7", "planning"),
new("close", "M5 5l14 14 M19 5L5 19", "planning"),
new("cut", "M4 3l16 18 M20 3L9 14 M8 17a3 3 0 1 0-6 0 3 3 0 0 0 6 0 M22 17a3 3 0 1 0-6 0 3 3 0 0 0 6 0", "planning"),

View File

@ -9,22 +9,33 @@
<header class="rw-toolbar" data-pd-context="workspace">
<h1 data-pwa-help>Relationships <help-icon key="relationshipMap.overview" /></h1>
<div class="rw-view-switch" data-pwa-context="View" role="group" aria-label="Workspace view">
<button type="button" class="btn btn-sm" id="rwMapView" aria-pressed="true">Map</button>
<button type="button" class="btn btn-sm" id="rwListView" aria-pressed="false">List</button>
<button type="button" class="btn btn-sm" id="rwMapView" data-ribbon-icon="map" aria-pressed="true">Map</button>
<button type="button" class="btn btn-sm" id="rwListView" data-ribbon-icon="list" aria-pressed="false">List</button>
</div>
<div class="rw-focus-chip" data-pwa-context="Focus"><button type="button" id="rwFocusName" title="Centre focused character">Full cast</button><button type="button" id="rwClearFocus" aria-label="Clear character focus" hidden>×</button></div>
<div class="rw-focus-chip" data-pwa-context="Focus"><button type="button" id="rwFocusName" data-ribbon-icon="focus" title="Centre focused character">Full cast</button><button type="button" id="rwClearFocus" data-ribbon-icon="close" aria-label="Clear character focus" hidden>×</button></div>
<div class="rw-toolbar-actions">
<button type="button" class="btn btn-outline-secondary btn-sm rw-mobile-only" id="rwCharacters" aria-expanded="false">Characters</button>
<button type="button" class="btn btn-outline-secondary btn-sm" data-pwa-context="Relationship" id="rwInfo" aria-expanded="false">Details</button>
<button type="button" class="btn btn-outline-secondary btn-sm" data-pwa-context="Relationship" id="rwConnect">Add relationship</button>
<button class="btn btn-outline-secondary btn-sm rw-arrange" type="button" data-map-reset data-pwa-context="Arrange">Auto-arrange</button>
<details class="rw-menu" data-pwa-context="Layout" data-pwa-compact="true"><summary class="btn btn-outline-secondary btn-sm">Layout</summary><div class="rw-menu-panel">
<button class="btn btn-outline-secondary btn-sm" type="button" id="rwRemove">Remove focused from map</button>
<button class="btn btn-outline-secondary btn-sm" type="button" id="rwReset">Reset layout</button>
<button type="button" class="btn btn-outline-secondary btn-sm" id="rwPalettes" aria-expanded="true">Characters</button>
<button type="button" class="btn btn-outline-secondary btn-sm" data-pwa-context="Relationship" id="rwInfo" data-ribbon-icon="details" aria-expanded="false">Details</button>
<button type="button" class="btn btn-outline-secondary btn-sm" data-pwa-context="Relationship" id="rwConnect" data-ribbon-icon="add">Add relationship</button>
<button class="btn btn-outline-secondary btn-sm rw-arrange" type="button" data-map-reset data-ribbon-icon="auto-arrange" data-pwa-context="Arrange">Auto-arrange</button>
<details class="rw-menu" data-pwa-context="Layout" data-pwa-menu-icon="layout" data-pwa-compact="true"><summary class="btn btn-outline-secondary btn-sm">Layout</summary><div class="rw-menu-panel">
<button class="btn btn-outline-secondary btn-sm" type="button" id="rwRemove" data-ribbon-icon="hide-node">Remove focused from map</button>
<button class="btn btn-outline-secondary btn-sm" type="button" id="rwReset" data-ribbon-icon="restore">Reset layout</button>
<button type="button" class="btn btn-outline-secondary btn-sm" id="rwPalettes" data-ribbon-icon="characters" aria-expanded="true">Characters</button>
</div></details>
<details class="rw-menu rw-display" data-pwa-context="Display" data-pwa-scope="Display" data-pwa-compact="true"><summary class="btn btn-outline-secondary btn-sm">Display</summary><div class="rw-menu-panel">
<form class="relationship-map-controls" method="get" asp-action="Index">
<details class="rw-menu rw-display" data-pwa-context="Display" data-pwa-menu-icon="display" data-pwa-scope="Display" data-pwa-compact="true"><summary class="btn btn-outline-secondary btn-sm">Display</summary><div class="rw-menu-panel">
<form id="rwNetworkForm"> <label class="form-check relationship-map-check">
<input class="form-check-input" type="checkbox" name="showFullNetwork" form="rwStoryForm" data-ribbon-icon="relationships" value="true" checked="@Model.ShowFullNetwork" />
<span class="form-check-label">Show full network</span>
</label>
</form>
<button type="button" class="btn btn-outline-secondary btn-sm" id="rwStoryPoint" data-ribbon-icon="point">Story point…</button>
</div></details>
<button type="button" data-pwa-context="Display" data-pwa-compact="true" id="rwMaximise" data-ribbon-icon="maximise" class="btn btn-outline-secondary btn-sm" aria-label="Maximise workspace" aria-pressed="false" title="Maximise workspace">⛶</button>
</div>
</header>
<dialog id="rwStoryDialog" aria-labelledby="rwStoryTitle"><h2 id="rwStoryTitle">Story point and focus</h2>
<form id="rwStoryForm" class="relationship-map-controls" method="get" asp-action="Index">
<input type="hidden" name="projectId" value="@Model.Project.ProjectID" />
<div>
<label class="form-label" for="bookId">Book</label>
@ -50,27 +61,10 @@
<option value="">Full cast</option>
</select>
</div>
<label class="form-check relationship-map-check">
<input class="form-check-input" type="checkbox" name="showFullNetwork" value="true" checked="@Model.ShowFullNetwork" />
<span class="form-check-label">Show full network</span>
</label>
<button class="btn btn-primary btn-sm" type="submit">Update Map</button>
<a class="btn btn-outline-secondary btn-sm" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID">Project Start</a>
</form>
<div class="relationship-map-legend-grid" data-pwa-ribbon-content>
@foreach (var category in Model.Categories)
{
<span class="relationship-map-legend-item @category.CssClass">
<span class="relationship-map-legend-line" aria-hidden="true"></span>
<span>@category.CategoryName</span>
</span>
}
</div>
</div></details>
<button type="button" data-pwa-context="Display" data-pwa-compact="true" id="rwMaximise" class="btn btn-outline-secondary btn-sm" aria-label="Maximise workspace" aria-pressed="false" title="Maximise workspace">⛶</button>
</div>
</header>
<button type="button" class="btn btn-outline-secondary btn-sm" id="rwCloseStory">Close</button>
</form></dialog>
<partial name="_Workspace" model="Model" />
<div id="rwListPanel" class="rw-list-panel" hidden aria-label="Relationship list">
<h2>Relationships at the current story point</h2>

View File

@ -40,7 +40,17 @@
</div>
}
</div>
@if (side == "right") { <partial name="_Details" model="Model" /> }
@if (side == "right") { <partial name="_Details" model="Model" /><section class="rw-colour-key" aria-label="Relationship colour key"><h3>Relationship key</h3><div class="relationship-map-legend-grid">
@foreach (var category in Model.Categories)
{
<span class="relationship-map-legend-item @category.CssClass">
<span class="relationship-map-legend-line" aria-hidden="true"></span>
<span>@category.CategoryName</span>
</span>
}
</div>
</section> }
@if (side == "left" || side == "right") { @:</aside>
}
}

View File

@ -138,3 +138,15 @@ html[data-standalone="true"] .rw-app.rw-maximised { top: var(--rw-ribbon-bottom,
[data-pwa-context-controls] .relationship-map-legend-grid { display:flex; flex-wrap:wrap; gap:8px; max-width:310px; padding:8px; }
/* Ribbon dropdowns must stay above the maximised application surface. */
html[data-standalone="true"] .rw-app.rw-maximised { z-index: 1010; }
.rw-colour-key { flex-shrink: 0; border-top: 1px solid var(--pd-border); padding: 8px; background: var(--pd-nested); }
.rw-colour-key h3 { margin-bottom: 5px; }
.rw-colour-key .relationship-map-legend-grid { display: flex; flex-wrap: wrap; gap: 5px 10px; font-size: 10px; }
.rw-colour-key .relationship-map-legend-item > span:last-child { color: var(--pd-text); }
.rw-display > .rw-menu-panel { max-height: none; overflow: visible; }
body.rw-page [data-pwa-context-controls] .pd-context-group[aria-label="Display"] > details > .pd-context-menu-content { max-height: none; overflow: visible; }
body.rw-page [data-pwa-context-controls] .pd-context-group[aria-label="Display"] .pd-context-form { display: block; }
body.rw-page [data-pwa-context-controls] .pd-context-group[aria-label="Display"] .pd-context-field { flex-direction: row; justify-content: flex-start; max-width: none; padding: 7px; gap: 8px; }
body.rw-page [data-pwa-context-controls] .pd-context-group[aria-label="Display"] input[type="checkbox"] { width: 16px; min-width: 16px; height: 16px; margin-left: auto; }
#rwStoryDialog { width: min(440px,95vw); max-height: 90dvh; overflow: auto; background: var(--pd-elevated); color: var(--pd-text); border: 1px solid var(--pd-border); border-radius: 6px; padding: 15px; }
#rwStoryDialog::backdrop { background: rgb(0 0 0 / 45%); }
#rwStoryDialog h2 { font-size: 17px; margin-bottom: 12px; }

View File

@ -259,7 +259,7 @@
for (const source of fields) {
const label = source.dataset.pwaLabel || source.getAttribute('aria-label') || source.labels?.[0]?.textContent.trim() || source.placeholder || source.name;
const wrapper = make(isSearch ? 'div' : 'label', 'pd-context-field');
if (isSearch) wrapper.append(make('span', '', label)); else decorate(wrapper, label, source.matches('select') ? /project/i.test(source.name) ? 'projects' : /book/i.test(source.name) ? 'bible' : 'point' : 'search');
if (isSearch) wrapper.append(make('span', '', label)); else decorate(wrapper, label, source.dataset.ribbonIcon || (source.matches('select') ? /project/i.test(source.name) ? 'projects' : /book/i.test(source.name) ? 'bible' : 'point' : 'search'));
const target = make(source.tagName.toLowerCase(), source.matches('select') ? 'pd-context-select' : 'pd-context-input');
if (source.matches('select')) [...source.options].forEach(option => { const copy = new Option(option.text, option.value, false, option.selected); copy.disabled = option.disabled; target.add(copy); });
else { target.type = source.type === 'checkbox' ? 'checkbox' : source.type === 'search' ? 'search' : 'text'; target.placeholder = source.placeholder; }
@ -344,6 +344,7 @@
for (const region of contributions) {
if (region.parentElement?.closest('[data-pwa-header], [data-pwa-context]')) continue;
const label = region.dataset.pwaContext || region.dataset.pwaTools || 'Page tools';
if (region.dataset.pwaMenuIcon) group(label, 50, region.dataset.pwaCompact === 'true').icon = region.dataset.pwaMenuIcon;
if (region.matches('[data-pwa-help]')) { helpSource ||= region.querySelector(region.matches('h1') ? '[data-help-icon]' : 'h1 [data-help-icon]'); continue; }
const commands = region.matches('a, button') ? [region] : region.matches('[data-pwa-context]') ? [...region.querySelectorAll('a, button')] : [...region.querySelectorAll('a.btn, a.dropdown-item, button.btn, button.dropdown-item')];
const supported = commands.filter(node => !node.matches('[data-bs-toggle="dropdown"]'));
@ -353,7 +354,7 @@
helpSource ||= region.querySelector(region.matches('h1') ? '[data-help-icon]' : 'h1 [data-help-icon]');
const formFields = new Set(forms.filter(form => {
if (!form.querySelector('select, input:not([type="hidden"]), textarea')) return false;
const scopeLabel = form.querySelector('select') ? region.dataset.pwaScope || 'Scope' : 'Find';
const scopeLabel = region.dataset.pwaScope || (form.querySelector('select') ? 'Scope' : 'Find');
const target = group(scopeLabel, 10, region.dataset.pwaCompact === 'true').element;
target.parentElement.dataset.essential = 'true';
return renderForm(form, target);
@ -383,7 +384,7 @@
} else region.dataset.pwaAccounted = 'true';
}
for (const [label, entry] of groups) {
if (label !== 'Jump to' && label !== 'Export') { const icon = entry.element.querySelector('.pd-icon'); if (icon) entry.element.parentElement.querySelector(':scope > summary .pd-icon')?.replaceWith(icon.cloneNode(true)); }
if (label !== 'Jump to' && label !== 'Export') { const icon = entry.icon ? icons?.querySelector(`[data-icon-key="${entry.icon}"]`) : entry.element.querySelector('.pd-icon'); if (icon) { const copy = icon.cloneNode(true); copy.removeAttribute('data-icon-key'); entry.element.parentElement.querySelector(':scope > summary .pd-icon')?.replaceWith(copy); } }
if (!entry.element.childElementCount) { entry.element.closest('.pd-context-group').remove(); groups.delete(label); }
}
if (helpSource?.dataset.helpUrl) {

View File

@ -8,6 +8,9 @@
if (!app.classList.contains('rw-maximised')) app.style.height = `${Math.max(260, window.innerHeight - app.getBoundingClientRect().top - 5)}px`;
resizeGraph();
};
document.getElementById('rwStoryPoint').addEventListener('click', () => document.getElementById('rwStoryDialog').showModal());
document.getElementById('rwCloseStory').addEventListener('click', () => document.getElementById('rwStoryDialog').close());
document.getElementById('rwNetworkForm').addEventListener('submit', event => event.preventDefault());
sizeWorkspace();
window.addEventListener('resize', sizeWorkspace);
const chromeObserver = new ResizeObserver(sizeWorkspace);