Promote Writer navigation and share writing window theme tokens
This commit is contained in:
parent
2497f45592
commit
0ef2e9cf62
52
PlotLine.Tests/Browser/writer-navigation-themes.cjs
Normal file
52
PlotLine.Tests/Browser/writer-navigation-themes.cjs
Normal file
@ -0,0 +1,52 @@
|
||||
// Production Razor layouts and shared theme tokens; isolated fixture repositories.
|
||||
const {chromium}=require('playwright');
|
||||
const assert=require('node:assert/strict');
|
||||
const base='http://127.0.0.1:5238';
|
||||
(async()=>{const browser=await chromium.launch();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();
|
||||
await page.goto(base+'/fixture?page=writer&layout=full&bookId=12');
|
||||
const nav=page.locator('.pd-ribbon-navigation').filter({hasText:/^Writer$/});
|
||||
assert.equal(await nav.count(),1);
|
||||
assert.equal(await nav.getAttribute('aria-current'),'page');
|
||||
assert.equal(new URL(await nav.getAttribute('href'),base).searchParams.get('projectId'),'7');
|
||||
assert.equal(new URL(await nav.getAttribute('href'),base).searchParams.get('bookId'),'12');
|
||||
assert.equal(await page.locator('#ribbon-panel-story a').filter({hasText:/^Writer$/}).count(),0);
|
||||
assert.equal(await page.locator('#appStoryMenu + ul a').filter({hasText:/Writer/}).count(),0);
|
||||
assert(await nav.evaluate(a=>a.matches('.pd-ribbon-navigation')?a.nextElementSibling?.dataset.ribbonTab==='story':a.parentElement.nextElementSibling?.querySelector('#appStoryMenu')!==null));
|
||||
for(const embedded of [false,true])for(const role of ['Context','Intent']){
|
||||
await page.goto(base+`/Writing/${role}?bookId=12${embedded?'&embedded=true':''}`);
|
||||
// Exercise real populated cards and controls without a database or native session.
|
||||
const fragment=await (await page.request.get(base+`/writing-desk-fixture/${role.toLowerCase()}?fragment=true`)).text();
|
||||
await page.locator(`[data-writing-${role.toLowerCase()}-content]`).evaluate((el,html)=>el.innerHTML=html,fragment);
|
||||
if(role==='Intent')await page.locator('.writing-workspace-role-indicator span').evaluate(el=>el.textContent='Saved PlotDirector snapshot · manual navigation · no automatic save');
|
||||
const sender=await context.newPage();await sender.goto(base+'/fixture');
|
||||
for(const theme of ['modern-light','modern-dark','warm-light','warm-dark']){
|
||||
await sender.evaluate(theme=>localStorage.setItem('plotdirector.applicationTheme',theme),theme);
|
||||
await page.waitForFunction(theme=>document.documentElement.dataset.appTheme===theme,theme);
|
||||
for(const width of [390,1440]){
|
||||
await page.setViewportSize({width,height:1000});
|
||||
const result=await page.evaluate(()=>{
|
||||
const main=document.querySelector('.writing-context-page'),card=main.querySelector('.writing-context-card');
|
||||
const probe=document.createElement('span');main.append(probe);
|
||||
const resolve=token=>{probe.style.color=`var(${token})`;return getComputedStyle(probe).color;};
|
||||
const result={body:getComputedStyle(document.body).backgroundColor,workspace:resolve('--pd-workspace'),text:getComputedStyle(main).color,expectedText:resolve('--pd-text'),card:getComputedStyle(card).backgroundColor,surface:resolve('--pd-surface'),overflow:document.documentElement.scrollWidth>innerWidth+2};probe.remove();return result;
|
||||
});
|
||||
assert.equal(result.body,result.workspace,`${role} ${theme} background`);
|
||||
assert.equal(result.text,result.expectedText,`${role} ${theme} text`);
|
||||
assert.equal(result.card,result.surface,`${role} ${theme} card`);
|
||||
assert.equal(result.overflow,false,`${role} ${theme} ${width} overflow`);
|
||||
const active=page.locator('.writing-context-tabs button.active');
|
||||
if(await active.count())assert(await active.evaluate(el=>{
|
||||
const probe=document.createElement('span');el.append(probe);probe.style.color='var(--pd-on-accent)';const expected=getComputedStyle(probe).color;probe.remove();return getComputedStyle(el).color===expected;
|
||||
}),`${role} ${theme} selected text`);
|
||||
}
|
||||
}
|
||||
await sender.close();
|
||||
}
|
||||
await context.close();
|
||||
}
|
||||
console.log('PASS Writer direct navigation/order/context/active state, Story removal; Context and Intent shared palettes and live cross-window changes in all four themes, browser/PWA, full/embedded and 390/1440 layouts.');
|
||||
}finally{await browser.close();}})().catch(e=>{console.error(e);process.exitCode=1;});
|
||||
@ -31,7 +31,7 @@ public static class ApplicationRibbon
|
||||
new("book", "Book",
|
||||
new("Selected book", new("Book overview", "bible", "Books", "Details", "book"), new("Edit book", "writer", "Books", "Edit", "book"), new("Add chapter", "threads", "Chapters", "Create", "chapter")),
|
||||
new("Manuscript review", S("review")), new("Library", S("overview"), new("Add book", "bible", "Books", "Create"))),
|
||||
new("story", "Story", new("Story structure", S("timeline"), S("plotlines"), S("threads"), S("calendar"), S("point")), new("Analysis & planning", S("review"), S("scenarios"), S("continuity")), new("Writing", S("writer"))),
|
||||
new("story", "Story", new("Story structure", S("timeline"), S("plotlines"), S("threads"), S("calendar"), S("point")), new("Analysis & planning", S("review"), S("scenarios"), S("continuity"))),
|
||||
new("characters", "Characters", new("Cast", S("characters"), S("names")), new("Connections", S("relationships"))),
|
||||
new("world", "World", new("Setting", S("locations"), S("maps"), S("floorplans")), new("Story world", S("assets"))),
|
||||
new("tools", "Tools", new("Reference", S("bible")), new("Insights", S("metrics"), S("health"), S("warnings")), new("Organisation", S("archive"))),
|
||||
@ -46,6 +46,7 @@ public static class ApplicationRibbon
|
||||
"Timeline" or "Calendar" or "At This Point" or "Plot Lines" or "Threads" or "Scenarios" or "Continuity Explorer" => "story",
|
||||
"Characters" or "Names" or "Relationships" => "characters",
|
||||
"Locations" or "Assets" or "Maps" or "Floor Plans" => "world",
|
||||
"Writer" => "writer",
|
||||
"Story Bible" or "Metrics" or "Health" or "Warnings" or "Archive" => "tools", _ => "project"
|
||||
}
|
||||
};
|
||||
|
||||
@ -74,6 +74,10 @@
|
||||
</li>
|
||||
<partial name="_ApplicationSectionMenus" model="Model" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<li class="nav-item"><a class="nav-link @(Model.ActiveSection == "Writer" ? "active" : null)" aria-current="@(Model.ActiveSection == "Writer" ? "page" : null)" asp-controller="Writer" asp-action="Index">Writer</a></li>
|
||||
}
|
||||
<li class="nav-item dropdown">
|
||||
<button class="nav-link dropdown-toggle @(controller is "Help" or "FeatureRequests" ? "active" : null)" type="button" id="appHelpMenu" data-bs-toggle="dropdown" aria-expanded="false">Help</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="appHelpMenu">
|
||||
|
||||
@ -3,6 +3,9 @@
|
||||
var projectId = Model.Project!.ProjectID;
|
||||
string ActiveClass(string section) => string.Equals(Model.ActiveSection, section, StringComparison.OrdinalIgnoreCase) ? "active" : string.Empty;
|
||||
}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @(ActiveClass("Writer"))" aria-current="@(Model.ActiveSection == "Writer" ? "page" : null)" asp-controller="Writer" asp-action="Index" asp-route-projectId="@projectId" asp-route-bookId="@Model.Book?.BookID">Writer</a>
|
||||
</li>
|
||||
@{ var storyActive = Model.ActiveSection == "Overview" || Model.ActiveSection == "Timeline" || Model.ActiveSection == "Calendar" || Model.ActiveSection == "At This Point" || Model.ActiveSection == "Threads" || Model.ActiveSection == "Scenarios" || Model.ActiveSection == "Continuity Explorer"; }
|
||||
<li class="nav-item dropdown">
|
||||
<button class="nav-link dropdown-toggle @(storyActive ? "active" : string.Empty)" type="button" id="appStoryMenu" data-bs-toggle="dropdown" aria-expanded="false">Story</button>
|
||||
|
||||
@ -117,6 +117,10 @@
|
||||
<div class="pd-ribbon-tabs" role="tablist" aria-label="Command categories">
|
||||
@foreach (var category in ApplicationRibbon.Categories)
|
||||
{
|
||||
@if (category.Key == "story")
|
||||
{
|
||||
<a class="pd-ribbon-navigation" aria-current="@(Model.ActiveSection == "Writer" ? "page" : null)" asp-controller="Writer" asp-action="Index" asp-route-projectId="@project?.ProjectID" asp-route-bookId="@book?.BookID">Writer</a>
|
||||
}
|
||||
<button type="button" role="tab" id="ribbon-tab-@category.Key" aria-controls="ribbon-panel-@category.Key" aria-selected="@(category.Key == selectedCategory ? "true" : "false")" tabindex="@(category.Key == selectedCategory ? "0" : "-1")" data-ribbon-tab="@category.Key">@category.Label</button>
|
||||
}
|
||||
</div>
|
||||
|
||||
@ -4,5 +4,5 @@
|
||||
var userID=int.TryParse(User.FindFirstValue(ClaimTypes.NameIdentifier),out var author)?author:0;
|
||||
var appearance=userID>0?await AppearancePreferences.GetAsync(userID):new ApplicationAppearance();
|
||||
}
|
||||
<!DOCTYPE html><html lang="en" data-theme="light" data-bs-theme="light"><head><meta charset="utf-8" /><partial name="_ApplicationThemeBootstrap" model="appearance" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>@ViewData["Title"] · PlotDirector</title><link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /><link rel="stylesheet" href="~/css/site.css" asp-append-version="true" /><link rel="stylesheet" href="~/css/plotline-theme.css" asp-append-version="true" /></head>
|
||||
<body class="writing-embedded" data-pd-user-id="@User.FindFirstValue(ClaimTypes.NameIdentifier)"><div class="writing-window-bar"><a href="/Writer" target="_blank" rel="noopener">PlotDirector</a><button type="button" id="native-companion-status" class="pd-presence" aria-haspopup="dialog" aria-controls="writing-connection-details" data-word-companion-presence><span class="word-companion-presence-dot"></span><span id="native-companion-status-text">Checking Word…</span></button></div><partial name="_WritingConnectionDetails" />@RenderBody()<script src="https://cdn.jsdelivr.net/npm/@@microsoft/signalr@8.0.7/dist/browser/signalr.min.js"></script><script src="~/js/application-theme-sync.js" asp-append-version="true"></script><script src="~/js/story-position.js" asp-append-version="true"></script><script src="~/js/native-companion-status.js" asp-append-version="true" defer></script>@await RenderSectionAsync("Scripts",required:false)</body></html>
|
||||
<!DOCTYPE html><html lang="en" data-theme="light" data-bs-theme="light"><head><meta charset="utf-8" /><partial name="_ApplicationThemeBootstrap" model="appearance" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>@ViewData["Title"] · PlotDirector</title><link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /><link rel="stylesheet" href="~/css/site.css" asp-append-version="true" /><link rel="stylesheet" href="~/css/plotline-theme.css" asp-append-version="true" /><link rel="stylesheet" href="~/css/application-shell.css" asp-append-version="true" /></head>
|
||||
<body class="app-layout writing-embedded" data-pd-user-id="@User.FindFirstValue(ClaimTypes.NameIdentifier)"><div class="writing-window-bar"><a href="/Writer" target="_blank" rel="noopener">PlotDirector</a><button type="button" id="native-companion-status" class="pd-presence" aria-haspopup="dialog" aria-controls="writing-connection-details" data-word-companion-presence><span class="word-companion-presence-dot"></span><span id="native-companion-status-text">Checking Word…</span></button></div><partial name="_WritingConnectionDetails" />@RenderBody()<script src="https://cdn.jsdelivr.net/npm/@@microsoft/signalr@8.0.7/dist/browser/signalr.min.js"></script><script src="~/js/application-theme-sync.js" asp-append-version="true"></script><script src="~/js/story-position.js" asp-append-version="true"></script><script src="~/js/native-companion-status.js" asp-append-version="true" defer></script>@await RenderSectionAsync("Scripts",required:false)</body></html>
|
||||
|
||||
@ -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 [role="tab"] { 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 [role="tab"]:hover { color: var(--pd-text); background: var(--pd-hover); }
|
||||
.pd-ribbon-tabs [aria-selected="true"] { color: var(--pd-text); font-weight: 650; background: var(--pd-chrome-secondary); border-radius: 5px 5px 0 0; }
|
||||
.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-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; }
|
||||
.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 [role="tab"] { padding-inline: 12px; }
|
||||
.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; }
|
||||
@ -710,3 +710,31 @@ html[data-standalone="true"] .story-calendar-toolbar .button-row .btn {
|
||||
.pd-writer .writer-queue-card h3 { font-family: var(--pd-font-ui); }
|
||||
.pd-writer :is(.story-bible-section, .writer-dashboard-grid) { margin-bottom: 16px; }
|
||||
.pd-writer .story-bible-section > :last-child { margin-bottom: 0; }
|
||||
|
||||
/* 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); }
|
||||
html[data-app-theme] .writing-context-tabs button:is(:hover, :focus-visible) { background: var(--pd-hover); color: var(--pd-text); }
|
||||
html[data-app-theme] .writing-context-tabs button.active,
|
||||
html[data-app-theme] .writing-plot-row > button[aria-current="location"] { background: var(--pd-accent); color: var(--pd-on-accent); }
|
||||
html[data-app-theme] .writing-context-page .btn-primary {
|
||||
--bs-btn-color: var(--pd-on-accent); --bs-btn-hover-color: var(--pd-on-accent); --bs-btn-active-color: var(--pd-on-accent);
|
||||
--bs-btn-bg: var(--pd-accent); --bs-btn-border-color: var(--pd-accent);
|
||||
--bs-btn-hover-bg: var(--pd-accent-hover); --bs-btn-hover-border-color: var(--pd-accent-hover);
|
||||
}
|
||||
html[data-app-theme] .writing-context-page :is(.btn-outline-primary, .btn-outline-secondary) {
|
||||
--bs-btn-color: var(--pd-text); --bs-btn-border-color: var(--pd-border);
|
||||
--bs-btn-hover-color: var(--pd-text); --bs-btn-hover-bg: var(--pd-hover); --bs-btn-hover-border-color: var(--pd-focus);
|
||||
--bs-btn-active-color: var(--pd-text); --bs-btn-active-bg: var(--pd-selected); --bs-btn-active-border-color: var(--pd-focus);
|
||||
background: var(--pd-control);
|
||||
}
|
||||
html[data-app-theme] .writing-context-page :is(.btn-outline-primary, .btn-outline-secondary):is(:hover, :focus-visible) { background: var(--pd-hover); }
|
||||
html[data-app-theme] .writing-context-page :is(button, a, input, select, summary):focus-visible { outline: 2px solid var(--pd-focus); outline-offset: 2px; }
|
||||
html[data-app-theme] .writing-context-page :is(.btn-outline-primary, .btn-outline-secondary):is(:active, .active) { background: var(--pd-selected); }
|
||||
html[data-app-theme] .writing-context-page .writing-workspace-role-indicator {
|
||||
max-width: 100%; white-space: normal;
|
||||
border-color: var(--pd-border); background: var(--pd-selected); color: var(--pd-text);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user