From eef4803c38e1431ba98193abd228d6109566aec4 Mon Sep 17 00:00:00 2001 From: Nick Beckley Date: Wed, 18 Nov 2026 21:26:28 +0000 Subject: [PATCH] Compact shared PWA ribbons with centred two-line labels and practical selectors --- PlotLine.Tests/Browser/ribbon-compact.cjs | 3 ++ PlotLine/wwwroot/css/application-shell.css | 39 +++++++++++-------- .../wwwroot/js/application-page-context.js | 4 +- 3 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 PlotLine.Tests/Browser/ribbon-compact.cjs diff --git a/PlotLine.Tests/Browser/ribbon-compact.cjs b/PlotLine.Tests/Browser/ribbon-compact.cjs new file mode 100644 index 00000000..95a64632 --- /dev/null +++ b/PlotLine.Tests/Browser/ribbon-compact.cjs @@ -0,0 +1,3 @@ +const {chromium}=require('playwright'),assert=require('node:assert/strict'),fs=require('node:fs'),cp=require('node:child_process'); +(async()=>{const b=await chromium.launch();try{let baseline;const evidence=[];for(const before of [true,false]){const c=await b.newContext({viewport:{width:1666,height:1050}});await c.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true}));if(before){const css=cp.execFileSync('git',['show','f228d40:PlotLine/wwwroot/css/application-shell.css'],{encoding:'utf8'});await c.route('**/css/application-shell.css*',r=>r.fulfill({contentType:'text/css',body:css}));}const p=await c.newPage();await p.goto('http://127.0.0.1:5238/fixture?page=maps');await p.waitForSelector('[data-pwa-context-controls] .pd-context-command');const toggle=p.locator('[data-ribbon-collapse]');if(await toggle.getAttribute('aria-expanded')==='false')await toggle.click();await p.waitForTimeout(200);const facts=await p.evaluate(()=>{const panel=document.querySelector('.pd-ribbon-panel:not([hidden])'),bounds=panel.getBoundingClientRect(),commands=[...panel.querySelectorAll('.pd-ribbon-command')].filter(n=>n.getBoundingClientRect().width&&n.getBoundingClientRect().height);return{width:panel.clientWidth,scrollWidth:panel.scrollWidth,identities:[...new Set([...panel.querySelectorAll('[data-command-identity],[data-command-operation]')].map(n=>n.dataset.commandIdentity||n.dataset.commandOperation))].sort(),fitting:commands.filter(n=>n.getBoundingClientRect().right<=bounds.right+1).length,lines:commands.map(n=>{const span=n.querySelector(':scope>span');return{label:n.textContent.trim(),height:n.clientHeight,lines:span?Math.round(span.scrollHeight/parseFloat(getComputedStyle(span).lineHeight)):0};})}});if(before)baseline=facts;else{assert.equal(facts.identities.length,baseline.identities.length,'no commands removed');assert(facts.scrollWidthbaseline.fitting,'more commands fit at 1666px');for(const x of facts.lines)assert(x.lines<=2,x.label+' exceeds two lines');}const out=process.env.PD_RIBBON_SCREENSHOTS;if(out){fs.mkdirSync(out,{recursive:true});await p.screenshot({path:out+'/Maps-1666-'+(before?'before':'after')+'.png'});}evidence.push({before,...facts}); +if(!before)for(const width of [1666,1366,1024,800]){await p.setViewportSize({width,height:1050});for(const category of ['project','book','writer','story','characters','world','tools']){const tab=p.locator('#ribbon-tab-'+category);if(!await tab.count())continue;await tab.click();assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2),category+' page overflow '+width);const heights=await p.locator('#ribbon-panel-'+category+' .pd-ribbon-command:visible').evaluateAll(ns=>ns.filter(n=>!n.closest('.pd-context-menu-content')).map(n=>Math.round(n.getBoundingClientRect().height)));assert(heights.every(h=>h===68),category+' inconsistent command heights '+heights);}}await c.close();}if(process.env.PD_RIBBON_SCREENSHOTS)fs.writeFileSync(process.env.PD_RIBBON_SCREENSHOTS+'/qualification.json',JSON.stringify(evidence,null,2));console.log('PASS shared ribbon: command preservation, greater 1666px Maps fit, two-line labels, uniform heights and primary tabs at 1666/1366/1024/800px; actual Chromium simulated PWA');}finally{await b.close();}})().catch(e=>{console.error(e.stack);process.exitCode=1;}); diff --git a/PlotLine/wwwroot/css/application-shell.css b/PlotLine/wwwroot/css/application-shell.css index 02f224ba..fb2b5397 100644 --- a/PlotLine/wwwroot/css/application-shell.css +++ b/PlotLine/wwwroot/css/application-shell.css @@ -125,13 +125,14 @@ html[data-app-theme] .pd-shell .pd-ribbon-tabs [aria-selected="true"] { color: v html[data-app-theme] .pd-shell .pd-ribbon-tabs [aria-selected="true"]::after { content: ''; position: absolute; height: 2px; width: 14px; border-radius: 2px; background: var(--pd-accent); left: calc(50% - 7px); bottom: 5px; } .pd-ribbon-collapse { border: 0; background: transparent; color: var(--pd-muted); font-size: 11px; white-space: nowrap; padding: 5px 7px; } .pd-ribbon-collapse span { margin-left: 6px; } -.pd-ribbon-surface { background: var(--pd-chrome-secondary); padding: 8px 20px 6px; } +.pd-ribbon-surface { background: var(--pd-chrome-secondary); padding: 8px 12px 6px; } .pd-ribbon-panel { display: flex; overflow-x: auto; gap: 0; min-height: 84px; } -.pd-ribbon-group { display: flex; flex-direction: column; padding: 0 18px; border-right: 1px solid var(--pd-border-subtle); flex-shrink: 0; } +.pd-ribbon-group { display: flex; flex-direction: column; padding: 0 7px; border-right: 1px solid var(--pd-border-subtle); flex-shrink: 0; } .pd-ribbon-group:first-child { padding-left: 0; } .pd-ribbon-group:last-child { border: 0; } -.pd-ribbon-commands { display: flex; gap: 4px; flex: 1; align-items: flex-start; } -.pd-shell .pd-ribbon-command { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 6px 10px; min-width: 65px; border-radius: 4px; text-decoration: none; color: var(--pd-text) !important; font-size: 12px; white-space: nowrap; line-height: 18px; } +.pd-ribbon-commands { display: flex; gap: 2px; flex: 1; align-items: flex-start; } +.pd-shell .pd-ribbon-command { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 4px; min-width: 54px; max-width: 104px; height: 68px; text-align: center; border-radius: 4px; text-decoration: none; color: var(--pd-text) !important; font-size: 12px; white-space: normal; line-height: 16px; } +.pd-shell .pd-ribbon-command > span { max-width: 15ch; white-space: normal; text-wrap: balance; overflow-wrap: anywhere; } .pd-shell button.pd-ribbon-command { border: 0; background: none; font-family: inherit; } .pd-shell .pd-ribbon-command:hover { background: var(--pd-hover); } .pd-shell .pd-ribbon-command[aria-current="page"] { background: var(--pd-selected); } @@ -491,7 +492,7 @@ html[data-app-theme] .app-layout .metric-toggle-pill:is(:hover, :focus-within) { .pd-ribbon-collapse { width: 32px; overflow: hidden; font-size: 0; } .pd-ribbon-collapse span { font-size: 16px; } .pd-ribbon-surface { padding-inline: 10px; } - .pd-ribbon-group { padding-inline: 12px; } + .pd-ribbon-group { padding-inline: 6px; } .pd-dashboard .dashboard-summary-grid { grid-template-columns: repeat(3,minmax(0,1fr)); } .pd-dashboard .dashboard-summary-body { padding: 14px 10px; } } @@ -514,7 +515,7 @@ html[data-standalone="true"] .app-layout > .pd-application-header > .pd-shell { .pd-page-context, .pd-page-context-controls { display: contents; } .pd-page-context[hidden] { display: none; } .pd-ribbon-panel > .pd-ribbon-group:has(+ [data-pwa-context-host][hidden]) { border-right: 0; } -.pd-page-context-controls > .pd-ribbon-group:first-child { padding-left: 18px; } +.pd-page-context-controls > .pd-ribbon-group:first-child { padding-left: 7px; } .pd-ribbon-panel:has([data-pwa-context-host]:not([hidden])) { overflow-y: clip; } .pd-ribbon-group:has(> .pd-context-menu) > .pd-ribbon-group-label { margin-top: auto; } .pd-context-menu { margin: 0; min-width: 0; } @@ -532,7 +533,7 @@ html[data-standalone="true"] .app-layout > .pd-application-header > .pd-shell { } .pd-context-menu[data-compact="true"]:not([open]) > .pd-context-menu-content { display: none; } .pd-shell .pd-context-menu[data-compact="true"] > .pd-context-menu-content > .pd-ribbon-command { - flex-direction: row; justify-content: flex-start; gap: 8px; text-align: left; width: 100%; white-space: normal; + flex-direction: row; justify-content: flex-start; gap: 8px; text-align: left; width: 100%; max-width: none; height: auto; min-height: 32px; white-space: normal; } .pd-shell .pd-context-command, .pd-shell .pd-context-submit { border: 0; background: transparent; font-family: var(--pd-font-ui); } .pd-shell .pd-context-command:hover, .pd-shell .pd-context-submit:hover { background: var(--pd-hover); } @@ -540,16 +541,16 @@ html[data-standalone="true"] .app-layout > .pd-application-header > .pd-shell { .pd-context-command[aria-disabled="true"] { pointer-events: none; } .pd-context-command[hidden] { display: none !important; } .pd-context-form { display: flex; align-items: flex-start; gap: 4px; margin: 0; } -.pd-context-field { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 0; padding: 3px 6px 0; min-width: 95px; max-width: 165px; color: var(--pd-text); font-size: 11px; line-height: 13px; } +.pd-context-field { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 0; padding: 3px 3px 0; min-width: 78px; max-width: 132px; color: var(--pd-text); font-size: 11px; line-height: 13px; } .pd-context-field > .pd-icon { width: 20px; height: 20px; } .pd-context-select, .pd-context-input, .pd-context-selector > summary { - width: 100%; max-width: 150px; min-width: 85px; height: 24px; margin: 0; + width: 100%; max-width: 128px; min-width: 76px; height: 24px; margin: 0; border: 1px solid var(--pd-border); border-radius: 3px; padding: 2px 5px; background: var(--pd-control); color: var(--pd-text); font: 12px var(--pd-font-ui); } .pd-context-select { padding-right: 2px; } -.pd-context-input { width: 140px; } -.pd-context-selector > summary { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.pd-context-input { width: 124px; } +.pd-context-selector > summary { max-width: 128px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .pd-context-selector > summary::after { content: ' ⌄'; } .pd-context-selector .pd-context-menu-content { gap: 6px; } .pd-context-selector select.pd-context-select { min-height: 140px; width: 100%; max-width: none; } @@ -557,8 +558,8 @@ html[data-standalone="true"] .app-layout > .pd-application-header > .pd-shell { .pd-context-status { color: var(--pd-muted); font-size: 12px; align-self: center; } .pd-shell :is(summary, select):focus-visible { outline: 2px solid var(--pd-focus); outline-offset: 2px; } @media (max-width: 1199px) { - .pd-ribbon-panel:has([data-pwa-context-host]:not([hidden])) .pd-ribbon-group { padding-inline: 10px; } - .pd-page-context-controls > .pd-ribbon-group:first-child { padding-left: 10px; } + .pd-ribbon-panel:has([data-pwa-context-host]:not([hidden])) .pd-ribbon-group { padding-inline: 5px; } + .pd-page-context-controls > .pd-ribbon-group:first-child { padding-left: 5px; } .pd-context-field { min-width: 85px; max-width: 135px; padding-inline: 3px; } .pd-context-select, .pd-context-input { max-width: 125px; } } @@ -567,13 +568,13 @@ html[data-standalone="true"] .app-layout > .pd-application-header > .pd-shell { .pd-context-search { align-self: stretch; align-items: center; } .pd-context-search .pd-context-field { gap: 5px; max-width: 210px; align-items: stretch; padding: 4px 6px; } .pd-context-search .pd-context-field > span:first-child { text-align: left; } -.pd-context-search-field { display: flex; align-items: center; border: 1px solid var(--pd-border); border-radius: 3px; background: var(--pd-control); width: 190px; } -.pd-context-search-field .pd-context-input { flex: 1; min-width: 0; max-width: none; width: 155px; border: 0; background: transparent; } +.pd-context-search-field { display: flex; align-items: center; border: 1px solid var(--pd-border); border-radius: 3px; background: var(--pd-control); width: 154px; } +.pd-context-search-field .pd-context-input { flex: 1; min-width: 0; max-width: none; width: 119px; border: 0; background: transparent; } .pd-context-search-submit { display: flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--pd-icon-planning); padding: 3px 5px; border-radius: 3px; } .pd-context-search-submit .pd-icon { width: 17px; height: 17px; } .pd-context-search-submit:hover { background: var(--pd-hover); } .pd-context-search-field:focus-within { outline: 2px solid var(--pd-focus); outline-offset: 2px; } -@media (max-width:1199px) { .pd-context-search-field { width: 150px; } } +@media (max-width:1199px) { .pd-context-search-field { width: 132px; } } /* House-theme primitives. Scope excludes public pages, including ordinary web login. */ html[data-app-theme="plotdirector"] .app-layout { @@ -745,3 +746,9 @@ html[data-app-theme] .writing-context-page .writing-workspace-role-indicator { #ribbon-surface>.pd-ribbon-panel{flex:1;min-width:0;position:relative} .pd-ribbon-history{padding-left:0;margin-right:12px;justify-content:space-between} .pd-shell .pd-ribbon-back:disabled{opacity:.4;cursor:default;background:transparent} + +/* Dropdown contents retain natural rows; the two-line icon layout belongs to the ribbon surface. */ +.pd-shell .pd-context-menu-content .pd-ribbon-command > span{max-width:none;text-wrap:initial} + +.pd-shell [data-word-ribbon-status]{max-width:210px;white-space:normal;font-size:11px;line-height:15px} +.pd-shell [data-word-ribbon-status]:empty{display:none} diff --git a/PlotLine/wwwroot/js/application-page-context.js b/PlotLine/wwwroot/js/application-page-context.js index 0410a4cd..2eea28a1 100644 --- a/PlotLine/wwwroot/js/application-page-context.js +++ b/PlotLine/wwwroot/js/application-page-context.js @@ -75,7 +75,9 @@ function decorate(node, text, key) { const svg = icons?.querySelector(`[data-icon-key="${key}"]`)?.cloneNode(true); if (svg) { svg.removeAttribute('data-icon-key'); node.append(svg); } - node.append(make('span', '', text)); + const short = {'Position geographically':'Geographic position','Arrange from relationships':'Arrange relationships','Open in separate window':'Separate window','Maximise workspace':'Maximise','Minimise workspace':'Restore workspace'}[text] || text; + if(short!==text){node.title ||= text;if(!node.hasAttribute('aria-label'))node.setAttribute('aria-label',text);} + node.append(make('span', '', short)); } let fitQueued = false; const activePanel = () => shell.querySelector('.pd-ribbon-panel:not([hidden])');