Match Review chapter navigation chevron icons

This commit is contained in:
Nick Beckley 2026-11-20 10:34:06 +00:00
parent b5e4de2626
commit c2e25438a5
3 changed files with 6 additions and 3 deletions

View File

@ -6,12 +6,13 @@ let p;if(installed){const tab=c.pages()[0];await tab.goto(base+'/fixture');const
await p.goto(base+'/Writer/Review?projectId=7&bookId=12&chapterId=21');
assert.equal(await p.locator('#ribbon-panel-writer [data-help-key="writer3.layout"]').count(),0);
assert(await p.locator('#ribbon-tab-help').isVisible());assert.equal(await p.locator('[data-ribbon-word] .pd-destination-badge').count(),3);
const mappings={'reader-prev':'back','reader-next':'next','reader-focus':'maximise','reader-audio':'headphones','reader-pause-toggle':'pause-circle','reader-apply-update':'refresh'};
const mappings={'reader-prev':'chevron-left','reader-next':'chevron-right','reader-focus':'maximise','reader-audio':'headphones','reader-pause-toggle':'pause-circle','reader-apply-update':'refresh'};
for(const [id,key]of Object.entries(mappings))assert.equal(await p.locator('#'+id).evaluate(n=>window.PlotDirectorCommands.iconKey(n)),key);
for(const [id,key]of [['reader-focus','minimise'],['reader-pause-toggle','play-circle']]){await p.locator('#'+id).evaluate(n=>{n.click()});assert.equal(await p.locator('#'+id).evaluate(n=>window.PlotDirectorCommands.iconKey(n)),key);}
await p.locator('#reader-focus').evaluate(n=>n.click());
assert.equal(await p.locator('[data-review-record]').evaluate(n=>window.PlotDirectorCommands.iconKey(n)),'comment-add');
if(installed)await p.locator('#ribbon-panel-writer [data-ribbon-icon=comment-add]').waitFor();
for(const theme of ['modern-light','modern-dark'])for(const width of [1666,800]){await p.setViewportSize({width,height:1050});await p.evaluate(t=>window.PlotDirectorApplyApplicationTheme(t),theme);assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2));fs.mkdirSync('/tmp/pd-icon-evidence',{recursive:true});await p.locator('[data-ribbon-shell]').screenshot({path:`/tmp/pd-icon-evidence/${installed?'pwa':'browser'}-${theme}-${width}.png`});}
if(installed){const pair=p.locator('#ribbon-panel-writer [data-ribbon-icon^=chevron-] svg');await pair.first().waitFor();const styles=await pair.evaluateAll(ns=>ns.map(n=>{const s=getComputedStyle(n);return[s.width,s.height,s.strokeWidth,s.color]}));assert.equal(styles.length,2);assert.deepEqual(styles[0],styles[1]);}
for(const theme of ['modern-light','modern-dark'])for(const width of [1666,800]){await p.setViewportSize({width,height:1050});await p.evaluate(t=>window.PlotDirectorApplyApplicationTheme(t),theme);await p.evaluate(()=>new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(r))));assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2));fs.mkdirSync('/tmp/pd-icon-evidence',{recursive:true});await p.locator('[data-ribbon-shell]').screenshot({path:`/tmp/pd-icon-evidence/${installed?'pwa':'browser'}-${theme}-${width}.png`});}
console.log('PASS '+(installed?'installed PWA':'browser')+' icon mappings, stateful icons, scoped Help removal, Word badges, themes and widths');
}finally{await c.close();await b.close();fs.rmSync(profile,{recursive:true,force:true});}})().catch(e=>{console.error(e);process.exitCode=1});

View File

@ -45,6 +45,8 @@ public static class RibbonPresentation
return null;
}
public static IReadOnlyList<RibbonIcon> AdditionalIcons { get; } = [
new("chevron-left", "M15 4l-8 8 8 8", "planning"),
new("chevron-right", "M9 4l8 8-8 8", "planning"),
new("minimise", "M3 9h6V3 M21 9h-6V3 M3 15h6v6 M21 15h-6v6", "planning"),
new("headphones", "M4 14v-3a8 8 0 0 1 16 0v3 M4 12H2v8h5v-8z M20 12h2v8h-5v-8z", "review"),
new("comment-add", "M21 14V3H3v14h5l4 4v-4h9z M8 10h8 M12 6v8", "review"),

View File

@ -59,7 +59,7 @@
return `${operation || 'navigate'}:${url.origin}:${path}:${JSON.stringify(values)}:${url.hash}`;
}
function iconKey(source) {
const readerIcons = { 'reader-prev':'back', 'reader-next':'next', 'reader-focus':source.getAttribute('aria-pressed')==='true'?'minimise':'maximise', 'reader-audio':'headphones', 'reader-pause-toggle':source.getAttribute('aria-pressed')==='true'?'play-circle':'pause-circle', 'reader-apply-update':'refresh' };
const readerIcons = { 'reader-prev':'chevron-left', 'reader-next':'chevron-right', 'reader-focus':source.getAttribute('aria-pressed')==='true'?'minimise':'maximise', 'reader-audio':'headphones', 'reader-pause-toggle':source.getAttribute('aria-pressed')==='true'?'play-circle':'pause-circle', 'reader-apply-update':'refresh' };
if (readerIcons[source.id]) return readerIcons[source.id];
if (source.matches('[data-review-new],[data-review-record]')) return 'comment-add';
if (source.matches('[data-pwa-label="Reading mode"]')) return 'bible';