diff --git a/PlotLine.Tests/Browser/writer-ribbon-style.cjs b/PlotLine.Tests/Browser/writer-ribbon-style.cjs new file mode 100644 index 00000000..f2ef20b6 --- /dev/null +++ b/PlotLine.Tests/Browser/writer-ribbon-style.cjs @@ -0,0 +1,34 @@ +// Compare real rendered chrome, including legacy dark link rules and keyboard focus. +const {chromium}=require('playwright'); +const assert=require('node:assert/strict'); +(async()=>{ + const browser=await chromium.launch(); + const style=locator=>locator.evaluate(el=>{const s=getComputedStyle(el);return Object.fromEntries(['color','backgroundColor','fontWeight','borderRadius','outlineColor','outlineStyle','outlineWidth','outlineOffset','textDecorationLine'].map(key=>[key,s[key]]));}); + try{for(const pwa of [false,true]){ + const context=await browser.newContext(); + if(pwa)await context.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true})); + const page=await context.newPage(); + for(const theme of ['modern-light','modern-dark','warm-light','warm-dark']){ + await page.goto('http://127.0.0.1:5238/fixture?page=writer&layout=full&bookId=12'); + await page.evaluate(theme=>window.PlotDirectorApplyApplicationTheme(theme),theme); + await page.waitForFunction(theme=>document.documentElement.dataset.appTheme===theme,theme); + const writer=page.locator('#ribbon-tab-writer'),project=page.locator('#ribbon-tab-project'),book=page.locator('#ribbon-tab-book'); + const href=await writer.getAttribute('href'); + await page.mouse.move(0,0);const activeWriter=await style(writer); + await project.click();await page.mouse.move(0,0);await project.evaluate(el=>el.blur()); + assert.equal(await writer.getAttribute('aria-selected'),'false'); + assert.deepEqual(await style(writer),await style(book),`${theme} inactive`); + assert.deepEqual(activeWriter,await style(project),`${theme} active`); + await writer.hover();const hoverWriter=await style(writer);await book.hover(); + assert.deepEqual(hoverWriter,await style(book),`${theme} hover`); + await page.mouse.move(0,0);await page.keyboard.press('Tab');await writer.focus(); + assert(await writer.evaluate(el=>el.matches(':focus-visible'))); + const focusWriter=await style(writer);await book.focus(); + assert.deepEqual(focusWriter,await style(book),`${theme} focus`); + assert.equal(await writer.getAttribute('href'),href,'Writer navigation remains unchanged'); + } + await context.close(); + } + console.log('PASS Writer ribbon styles: inactive, active, hover and keyboard focus match standard tabs in all four themes, browser and simulated PWA'); + }finally{await browser.close();} +})().catch(error=>{console.error(error);process.exitCode=1;}); diff --git a/PlotLine/Views/Shared/_ApplicationShell.cshtml b/PlotLine/Views/Shared/_ApplicationShell.cshtml index cbec23cd..32cab431 100644 --- a/PlotLine/Views/Shared/_ApplicationShell.cshtml +++ b/PlotLine/Views/Shared/_ApplicationShell.cshtml @@ -118,7 +118,7 @@ { @if (category.Key == "writer") { - Writer + Writer continue; } diff --git a/PlotLine/wwwroot/css/application-shell.css b/PlotLine/wwwroot/css/application-shell.css index 8b089d21..fa8f149a 100644 --- a/PlotLine/wwwroot/css/application-shell.css +++ b/PlotLine/wwwroot/css/application-shell.css @@ -119,10 +119,10 @@ html[data-app-theme] .app-layout { .pd-shell .app-toolbar-empty { display: none; } .pd-ribbon-heading { display: flex; align-items: center; padding: 0 20px; gap: 12px; } .pd-ribbon-tabs { display: flex; align-items: center; gap: 4px; overflow-x: auto; flex: 1; } -.pd-ribbon-tabs :is([role="tab"], .pd-ribbon-navigation) { position: relative; border: 0; background: transparent; color: var(--pd-muted); padding: 8px 16px 10px; font-size: 13px; line-height: 18px; white-space: nowrap; } -.pd-ribbon-tabs :is([role="tab"], .pd-ribbon-navigation):hover { color: var(--pd-text); background: var(--pd-hover); } -.pd-ribbon-tabs :is([aria-selected="true"], [aria-current="page"]) { color: var(--pd-text); font-weight: 650; background: var(--pd-chrome-secondary); border-radius: 5px 5px 0 0; } -.pd-ribbon-tabs :is([aria-selected="true"], [aria-current="page"])::after { content: ''; position: absolute; height: 2px; width: 14px; border-radius: 2px; background: var(--pd-accent); left: calc(50% - 7px); bottom: 5px; } +html[data-app-theme] .pd-shell .pd-ribbon-tabs :is([role="tab"], .pd-ribbon-navigation) { position: relative; border: 0; background: transparent; color: var(--pd-muted); padding: 8px 16px 10px; font-size: 13px; line-height: 18px; white-space: nowrap; } +html[data-app-theme] .pd-shell .pd-ribbon-tabs :is([role="tab"], .pd-ribbon-navigation):hover { color: var(--pd-text); background: var(--pd-hover); } +html[data-app-theme] .pd-shell .pd-ribbon-tabs [aria-selected="true"] { color: var(--pd-text); font-weight: 650; background: var(--pd-chrome-secondary); border-radius: 5px 5px 0 0; } +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; } @@ -487,7 +487,7 @@ html[data-app-theme] .app-layout .metric-toggle-pill:is(:hover, :focus-within) { .pd-presence { display: none; } .pd-shell .app-account-label { max-width: 100px; } .pd-ribbon-heading { padding-inline: 8px; gap: 4px; } - .pd-ribbon-tabs :is([role="tab"], .pd-ribbon-navigation) { padding-inline: 12px; } + html[data-app-theme] .pd-shell .pd-ribbon-tabs :is([role="tab"], .pd-ribbon-navigation) { padding-inline: 12px; } .pd-ribbon-collapse { width: 32px; overflow: hidden; font-size: 0; } .pd-ribbon-collapse span { font-size: 16px; } .pd-ribbon-surface { padding-inline: 10px; } @@ -713,7 +713,6 @@ html[data-standalone="true"] .story-calendar-toolbar .button-row .btn { /* Direct workspace navigation shares the ribbon presentation. */ .pd-ribbon-navigation { text-decoration: none; } -.pd-ribbon-navigation:focus-visible { outline: 2px solid var(--pd-focus); outline-offset: -2px; } /* Writing windows use the same semantic palette in browser, PWA and Companion. */ html[data-app-theme] .writing-context-page :is(h1, h2, h3, .eyebrow) { color: var(--pd-heading); } diff --git a/PlotLine/wwwroot/js/application-shell.js b/PlotLine/wwwroot/js/application-shell.js index d2763caa..236eb9e2 100644 --- a/PlotLine/wwwroot/js/application-shell.js +++ b/PlotLine/wwwroot/js/application-shell.js @@ -52,6 +52,7 @@ collapse.innerHTML = value ? 'Expand ribbon ' : 'Collapse ribbon '; } function select(tab) { + shell.querySelector(".pd-ribbon-navigation")?.setAttribute("aria-selected", "false"); tabs.forEach(item => { const selected = item === tab; item.setAttribute('aria-selected', String(selected)); item.tabIndex = selected ? 0 : -1; }); shell.querySelectorAll('[role="tabpanel"]').forEach(panel => panel.hidden = panel.id !== tab.getAttribute('aria-controls')); // A collapsed preference stays collapsed on the next page; selecting a category opens it temporarily.