Polish Current Focus scene navigation controls

This commit is contained in:
Nick Beckley 2026-11-20 15:06:34 +00:00
parent 62e32fb580
commit ef4abda5fa
4 changed files with 13 additions and 6 deletions

View File

@ -27,6 +27,8 @@ const base=process.env.PD_NARRATIVE_TEST_URL||'http://127.0.0.1:5238';
await p.locator('[data-focus-label]').evaluate(n=>n.textContent='Current Focus: Short');
assert(await toggle.evaluate(n=>{const label=n.querySelector('[data-focus-label]'),b=n.getBoundingClientRect(),l=label.getBoundingClientRect();return b.right-l.right<30;}),'chevron follows short label without unused width');
await open();await p.locator('[data-focus-search]').fill('Departure');await expectOpen();assert.equal(await p.locator('[data-focus-position] option').count(),2);
assert(await p.locator('[data-focus-step="-1"]').isDisabled());assert.equal(await p.locator('[data-focus-step="-1"]').getAttribute('aria-label'),'Previous Scene');
assert.equal(await p.locator('[data-focus-step="1"]').getAttribute('aria-label'),'Next Scene');
let release;const gate=new Promise(r=>release=r);await p.route('**/NarrativeFocus/Set',async r=>{await gate;await r.continue();});
await p.locator('[data-focus-position]').selectOption('22/32');await expectOpen();assert.match(await p.locator('[data-narrative-status]').textContent(),/Updating/);release();await closed();await p.unroute('**/NarrativeFocus/Set');assert.match(await toggle.textContent(),/Departure/);
await open();await p.locator('[data-focus-search]').fill('');await p.locator('[data-focus-step="-1"]').click();await closed();
@ -44,6 +46,8 @@ const base=process.env.PD_NARRATIVE_TEST_URL||'http://127.0.0.1:5238';
const after=await toggle.boundingBox();assert.equal(after.height,before.height);assert(after.width<=Math.max(before.width,448));
assert(await p.locator('[data-focus-label]').evaluate(n=>n.scrollWidth>n.clientWidth&&getComputedStyle(n).textOverflow==='ellipsis'));
await open();const box=await popup.boundingBox();assert(box.x>=0&&box.x+box.width<=width+1,'popup fits viewport');
const layout=await popup.evaluate(n=>{const elements=['[data-focus-search]','[data-focus-position]','.pd-focus-navigation','[data-focus-recent]'].map(s=>n.querySelector(s).getBoundingClientRect());const buttons=[...n.querySelectorAll('[data-focus-step]')].map(b=>{const r=b.getBoundingClientRect(),i=b.querySelector('svg').getBoundingClientRect();return {top:r.top,height:r.height,iconWidth:i.width,iconHeight:i.height};});return {aligned:elements.every(r=>Math.abs(r.left-elements[0].left)<1&&Math.abs(r.right-elements[0].right)<1),buttons};});
assert(layout.aligned,'popup fields and navigation row share horizontal edges');assert.equal(layout.buttons[0].top,layout.buttons[1].top);assert.equal(layout.buttons[0].height,layout.buttons[1].height);for(const b of layout.buttons){assert.equal(b.iconWidth,16);assert.equal(b.iconHeight,16);}
await p.screenshot({path:`/tmp/pd-focus-popup-${installed?'pwa':'browser'}-${width}-${theme}.png`});await p.keyboard.press('Escape');await closed();
}
await open();await p.goto(base+'/Timeline/Index?ProjectID=7&BookID=12');await p.waitForFunction(()=>window.PlotDirectorNarrativeFocus);await closed();

View File

@ -7,7 +7,7 @@
<p class="small">Current narrative location. Saved objectives and local Scene Explorers keep their own targets.</p>
<label>Find chapter or scene<input type="search" data-focus-search placeholder="Search this book" autocomplete="off" /></label>
<label>Chapter / scene<select data-focus-position aria-label="Current narrative chapter or scene"></select></label>
<div class="button-row"><button type="button" data-focus-step="-1" title="Previous scene in manuscript order"><svg class="pd-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="@RibbonPresentation.Icons.Single(x=>x.Key=="chevron-left").IconPath" /></svg> Previous Scene</button><button type="button" data-focus-step="1" title="Next scene in manuscript order">Next Scene <svg class="pd-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="@RibbonPresentation.Icons.Single(x=>x.Key=="chevron-right").IconPath" /></svg></button></div>
<div class="button-row pd-focus-navigation" role="group" aria-label="Navigate scenes"><button class="btn btn-outline-secondary btn-sm" type="button" data-focus-step="-1" aria-label="Previous Scene" title="Previous scene in manuscript order"><svg class="pd-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="@RibbonPresentation.Icons.Single(x=>x.Key=="chevron-left").IconPath" /></svg> Previous</button><button class="btn btn-outline-secondary btn-sm" type="button" data-focus-step="1" aria-label="Next Scene" title="Next scene in manuscript order">Next <svg class="pd-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="@RibbonPresentation.Icons.Single(x=>x.Key=="chevron-right").IconPath" /></svg></button></div>
<label>Recent focus<select data-focus-recent><option value="">Recent chapter / scene…</option></select></label>
<p role="status" data-narrative-status></p>
@Html.AntiForgeryToken()

View File

@ -368,7 +368,7 @@ html[data-app-theme] .app-layout :is(
background-color: var(--pd-section);
border-color: var(--pd-border);
}
html[data-app-theme] .app-layout :is(.workspace-heading .button-row, .timeline-filter) .btn {
html[data-app-theme] .app-layout :is(.workspace-heading .button-row, .timeline-filter, .pd-focus-navigation) .btn {
--bs-btn-color: var(--pd-text);
--bs-btn-bg: transparent;
--bs-btn-border-color: var(--pd-border);
@ -385,17 +385,17 @@ html[data-app-theme] .app-layout :is(.workspace-heading .button-row, .timeline-f
border-color: var(--bs-btn-border-color);
color: var(--bs-btn-color);
}
html[data-app-theme] .app-layout :is(.workspace-heading .button-row, .timeline-filter) .btn:is(:hover, :focus-visible) {
html[data-app-theme] .app-layout :is(.workspace-heading .button-row, .timeline-filter, .pd-focus-navigation) .btn:is(:hover, :focus-visible) {
background: var(--bs-btn-hover-bg);
border-color: var(--bs-btn-hover-border-color);
color: var(--bs-btn-hover-color);
}
html[data-app-theme] .app-layout :is(.workspace-heading .button-row, .timeline-filter) .btn:is(:active, .active, .show) {
html[data-app-theme] .app-layout :is(.workspace-heading .button-row, .timeline-filter, .pd-focus-navigation) .btn:is(:active, .active, .show) {
background: var(--bs-btn-active-bg);
border-color: var(--bs-btn-active-border-color);
color: var(--bs-btn-active-color);
}
html[data-app-theme] .app-layout :is(.workspace-heading .button-row, .timeline-filter) .btn:disabled {
html[data-app-theme] .app-layout :is(.workspace-heading .button-row, .timeline-filter, .pd-focus-navigation) .btn:disabled {
background: var(--bs-btn-disabled-bg);
border-color: var(--bs-btn-disabled-border-color);
color: var(--bs-btn-disabled-color);

View File

@ -8,7 +8,10 @@
.pd-shell .pd-narrative-focus .app-context-label{min-width:0;max-width:none;text-align:start;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.pd-narrative-focus>.dropdown-toggle::after{flex-shrink:0;}
.pd-focus-picker{width:min(32rem,88vw);padding:1rem;}
.pd-focus-picker label{display:block;margin-block:.5rem;}
.pd-focus-picker label{display:block;margin-block:.75rem;}
.pd-focus-navigation{flex-wrap:nowrap;gap:.5rem;margin-block:.75rem;}
.pd-focus-navigation .btn{display:inline-flex;align-items:center;justify-content:center;gap:.25rem;}
.pd-focus-navigation .pd-icon{width:16px;height:16px;}
.pd-focus-picker select,.pd-focus-picker input{display:block;width:100%;min-width:0;background:var(--bs-body-bg);color:var(--bs-body-color);border:1px solid var(--bs-border-color);border-radius:.25rem;padding:.3rem;}
@media(max-width:900px){.pd-narrative-focus{max-width:12rem;}}