Introduce integrated ribbon shell, four account themes and refreshed series dashboard

This commit is contained in:
Nick Beckley 2026-10-28 20:25:03 +00:00
parent 66c771d417
commit bfa6a73e3f
20 changed files with 787 additions and 64 deletions

View File

@ -0,0 +1,40 @@
using PlotLine.Services;
using PlotLine.Data;
using PlotLine.Controllers;
using Microsoft.AspNetCore.Mvc;
internal static class AppearanceTests
{
public static void RegistryAndPersistence()
{
if (ApplicationAppearance.Themes.Count != 4 || ApplicationAppearance.IsValid("dark")) throw new Exception("Four explicit theme identifiers required.");
var store = new AppearanceMemoryPreferences();
var controller = new AppearanceController(new ToolbarTestUser(4), store);
controller.Theme("modern-dark").GetAwaiter().GetResult();
controller.Theme("warm-light", true).GetAwaiter().GetResult();
if (store.GetAsync(4).Result.ThemeKey != "modern-dark" || store.GetAsync(5).Result.ThemeKey is not null) throw new Exception("Legacy migration must preserve explicit choices and isolate users.");
controller.Ribbon(true).GetAwaiter().GetResult();
if (!store.GetAsync(4).Result.RibbonCollapsed || store.GetAsync(4).Result.ThemeKey != "modern-dark") throw new Exception("Ribbon preference must not overwrite theme.");
if (controller.Theme("invalid").Result is not BadRequestResult) throw new Exception("Invalid themes rejected.");
if (ApplicationRibbon.ActiveCategory("StoryCalendar", "Calendar") != "story" || ApplicationRibbon.ActiveCategory("Books", "Overview") != "book") throw new Exception("Category maps feature routes.");
foreach (var command in ApplicationRibbon.Categories.SelectMany(x => x.Groups).SelectMany(x => x.Commands))
{
_ = ApplicationRibbon.Icon(command.IconKey);
if (command.ToolbarKey is not null && !ToolbarCommands.All.Any(x => x.Key == command.ToolbarKey)) throw new Exception("Registry key invalid.");
var type = typeof(AppearanceController).Assembly.GetType($"PlotLine.Controllers.{command.Controller}Controller");
if (type is null || !type.GetMethods().Any(x => x.Name == command.Action)) throw new Exception($"Missing destination: {command.Controller}/{command.Action}");
}
}
}
internal sealed class AppearanceMemoryPreferences : IAppearanceRepository
{
private readonly System.Collections.Concurrent.ConcurrentDictionary<int, ApplicationAppearance> values = new();
public Task<ApplicationAppearance> GetAsync(int id) => Task.FromResult(values.GetOrAdd(id, _ => new()));
public Task SaveThemeAsync(int id, string theme, bool onlyIfUnset = false)
{
var value = GetAsync(id).Result;
lock(value) { if (!onlyIfUnset || value.ThemeKey is null) value.ThemeKey = theme; }
return Task.CompletedTask;
}
public Task SaveRibbonAsync(int id, bool collapsed) { GetAsync(id).Result.RibbonCollapsed = collapsed; return Task.CompletedTask; }
}

View File

@ -11,7 +11,7 @@ const assert = require('node:assert/strict');
const visible = () => page.locator('[data-toolbar-key]:visible').evaluateAll(items => items.map(item => item.dataset.toolbarKey));
const open = async () => {
await page.locator('#accountMenuButton').click();
await page.getByRole('button', { name: 'Customise toolbar…', exact: true }).click();
await page.getByRole('button', { name: 'Customise Quick Access Toolbar…', exact: true }).click();
await page.locator('#customiseToolbar.show').waitFor();
};
const close = async (name) => {
@ -28,11 +28,11 @@ const assert = require('node:assert/strict');
assert.match(await page.locator('[data-toolbar-key="calendar"]').getAttribute('href'), /projectId=7/);
assert.match(await page.locator('[data-toolbar-key="review"]').getAttribute('href'), /book\/12\/review-centre/);
const chrome = await page.locator('header').boundingBox();
assert(chrome.height < 100, 'Desktop chrome stays compact');
assert(chrome.height < 190, 'Desktop chrome stays compact');
await page.screenshot({ path: '/tmp/plotdirector-toolbar-desktop.png' });
await page.locator('#appStoryMenu').click();
assert(await page.locator('#appStoryMenu + ul').isVisible());
assert.match(await page.locator('#appStoryMenu + ul').getByText('Calendar', { exact: true }).getAttribute('href'), /projectId=7/);
await page.getByRole('tab', { name: 'Story', exact: true }).click();
assert(await page.locator('#ribbon-panel-story').isVisible());
assert.match(await page.locator('#ribbon-panel-story').getByRole('link', { name: 'Calendar', exact: true }).getAttribute('href'), /projectId=7/);
await page.locator('#appProjectMenu').click();
assert.equal(await page.getByText('Switch project…', { exact: true }).getAttribute('href'), '/Projects');
await page.keyboard.press('Escape');
@ -94,7 +94,7 @@ const assert = require('node:assert/strict');
await close('Save');
assert.deepEqual(await visible(), []);
await page.reload();
assert(await page.locator('[data-toolbar-empty]').isVisible());
assert(await page.locator('[data-app-toolbar] button').isVisible());
await open();
await page.getByRole('button', { name: 'Restore defaults', exact: true }).click();
await close('Cancel');
@ -106,21 +106,46 @@ const assert = require('node:assert/strict');
assert.equal(await page.locator('[data-toolbar-key="calendar"]').getAttribute('href'), null);
assert.equal(await page.locator('[data-toolbar-key="calendar"]').getAttribute('aria-disabled'), 'true');
await page.setViewportSize({ width: 390, height: 844 });
await page.locator('.navbar-toggler').click();
await page.locator('#applicationMenu.collapse.show').waitFor();
await page.locator('#accountMenuButton').click();
assert(await page.getByRole('button', { name: 'Customise toolbar…', exact: true }).isVisible());
assert(await page.getByRole('button', { name: 'Customise Quick Access Toolbar…', exact: true }).isVisible());
await page.keyboard.press('Escape');
await page.locator('.navbar-toggler').click();
await page.locator('#applicationMenu').waitFor({ state: 'hidden' });
await page.screenshot({ path: '/tmp/plotdirector-toolbar-mobile.png' });
assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), 'Mobile chrome does not overflow viewport');
await page.setViewportSize({ width: 1440, height: 1000 });
await page.goto(base + '/fixture');
await page.evaluate(() => { document.documentElement.dataset.theme = 'dark'; document.documentElement.dataset.bsTheme = 'dark'; });
await page.waitForTimeout(350); // Allow the existing theme colour transition to finish.
await page.screenshot({ path: '/tmp/plotdirector-toolbar-dark.png' });
await page.goto(base + '/fixture?page=dashboard');
assert.equal(await page.locator('.dashboard-summary-value').first().textContent(), '2');
assert.equal(await page.getByRole('tab', { name: 'Project', exact: true }).getAttribute('aria-selected'), 'true');
for (const theme of ['modern-light','modern-dark','warm-light','warm-dark']) {
const before = page.url();
await page.locator('#accountMenuButton').click();
await page.locator(`[data-app-theme-choice="${theme}"]`).click();
await page.waitForFunction(t => document.documentElement.dataset.appTheme === t && !document.querySelector('[data-app-theme-choice]').disabled, theme);
await page.keyboard.press('Escape');
assert.equal(page.url(), before);
await page.waitForTimeout(250);
await page.screenshot({ path: `/tmp/plotdirector-shell-${theme}.png` });
await page.reload();
assert.equal(await page.locator('html').getAttribute('data-app-theme'), theme);
}
await page.getByRole('tab', { name: 'Project', exact: true }).focus();
await page.keyboard.press('ArrowRight');
assert.equal(await page.getByRole('tab', { name: 'Book', exact: true }).getAttribute('aria-selected'), 'true');
await page.locator('[data-ribbon-collapse]').click();
await page.waitForFunction(() => !document.querySelector('[data-ribbon-collapse]').disabled);
await page.reload();
assert(await page.locator('#ribbon-surface').isHidden());
await page.getByRole('tab', { name: 'World', exact: true }).click();
assert(await page.locator('#ribbon-panel-world').isVisible());
assert.match(await page.locator('#ribbon-panel-world').getByRole('link', { name: 'Locations', exact: true }).getAttribute('href'), /projectId=7/);
// Category selection opens a collapsed ribbon temporarily; it does not erase the saved preference.
await page.reload();
assert(await page.locator('#ribbon-surface').isHidden());
await page.locator('[data-ribbon-collapse]').click();
await page.waitForFunction(() => !document.querySelector('[data-ribbon-collapse]').disabled);
await page.setViewportSize({ width: 390, height: 844 });
assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
await page.screenshot({ path: '/tmp/plotdirector-shell-dashboard-mobile.png' });
assert.deepEqual(errors, []);
console.log('PASS application toolbar: real Razor, default/custom order, show/hide, drag/keyboard, cancel/reset, fresh sessions, users, menus, project/book context, CSRF, desktop/mobile/dark');
console.log('PASS application toolbar: real Razor, default/custom order, show/hide, drag/keyboard, cancel/reset, fresh sessions, users, menus, project/book context, CSRF, desktop/mobile, four themes, theme persistence, ribbon keyboard/collapse, Dashboard');
} finally { await browser.close(); }
})().catch(error => { console.error(error); process.exitCode = 1; });

View File

@ -319,6 +319,7 @@ var tests = new (string Name, Action Test)[]
("Writing Intent route uses canonical story context and planning data", WritingIntentRouteUsesCanonicalStoryContextAndPlanningData),
("Writing Intent client uses shared writing follow helper", WritingIntentClientUsesSharedWritingFollowHelper),
("Obsolete global Word navigation is removed while writing windows remain live", GlobalWordNavigationIsRemoved),
("Appearance preferences and ribbon destinations", AppearanceTests.RegistryAndPersistence),
("Toolbar preferences, authorisation and contextual routes", ToolbarTests.PreferencesAndRoutes),
("Application navigation resolves authorised project and book context", ApplicationNavigationTests.ContextAndPermissions),
("Writing pair shares canonical follow infrastructure", WritingPairSharesCanonicalFollowInfrastructure),

View File

@ -25,6 +25,8 @@ internal static class ToolbarBrowserHost
builder.Services.AddControllersWithViews().AddApplicationPart(typeof(ToolbarController).Assembly);
builder.Services.AddSingleton<IToolbarPreferenceRepository, ToolbarMemoryPreferences>();
builder.Services.AddHttpContextAccessor();
builder.Services.AddSingleton<IAppearanceRepository, AppearanceMemoryPreferences>();
builder.Services.AddScoped<ApplicationNavigation>(_ => new ApplicationNavigation(null!, null!, null!));
builder.Services.AddSingleton<IHelpService, HelpService>();
builder.Services.AddScoped<ICurrentUserService>(services => new ToolbarTestUser(int.Parse(services.GetRequiredService<IHttpContextAccessor>().HttpContext!.User.FindFirstValue(ClaimTypes.NameIdentifier)!)));
var app = builder.Build();
@ -48,7 +50,10 @@ internal static class ToolbarBrowserHost
model.Book = new Book { BookID = 12, ProjectID = 7, BookTitle = "A Distant Shore", BookNumber = 1 };
model.Books = [model.Book, new Book { BookID = 13, ProjectID = 7, BookTitle = "The Return", BookNumber = 2 }];
}
var route = new RouteData(); route.Values["controller"] = "StoryCalendar"; route.Values["action"] = "Index";
var dashboardPage = context.Request.Query["page"] == "dashboard";
if (dashboardPage) model.ActiveSection = "Overview";
var appearance = await context.RequestServices.GetRequiredService<IAppearanceRepository>().GetAsync(int.Parse(context.User.FindFirstValue(ClaimTypes.NameIdentifier)!));
var route = new RouteData(); route.Values["controller"] = dashboardPage ? "Projects" : "StoryCalendar"; route.Values["action"] = dashboardPage ? "Details" : "Index";
var action = new ActionContext(context, route, new ActionDescriptor());
async Task<string> Render(string name, object? viewModel = null)
{
@ -56,12 +61,13 @@ internal static class ToolbarBrowserHost
if (!view.Success) throw new Exception(string.Join(",", view.SearchedLocations));
using var writer = new StringWriter();
var data = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()) { Model = viewModel ?? model };
data["ApplicationAppearance"] = appearance;
var temp = new TempDataDictionary(context, context.RequestServices.GetRequiredService<ITempDataProvider>());
await view.View.RenderAsync(new ViewContext(action, view.View, data, temp, writer, new HtmlHelperOptions()));
return writer.ToString();
}
var menu = await Render("Shared/_ApplicationNavigation");
var toolbar = await Render("Shared/_ApplicationToolbar");
var menu = await Render("Shared/_ApplicationShell");
var toolbar = "";
var calendar = new StoryCalendarViewModel { Project = model.Project ?? new(), SelectedBookID = model.Book?.BookID,
SelectedMonth = new DateOnly(2026, 10, 1), EarliestStoryDate = new DateOnly(2026, 10, 3), LatestStoryDate = new DateOnly(2026, 10, 3),
BookOptions = [new SelectListItem("A Distant Shore", "12"), new SelectListItem("The Return", "13")],
@ -71,9 +77,22 @@ internal static class ToolbarBrowserHost
Days = Enumerable.Range(0, 7).Select(day => new StoryCalendarDayViewModel { Date = new DateOnly(2026, 9, 28).AddDays(week * 7 + day), IsInSelectedMonth = week * 7 + day >= 3 }).ToList()
}).ToList()
};
var surface = await Render("StoryCalendar/_StoryCalendarSurface", calendar);
var surface = dashboardPage ? "" : await Render("StoryCalendar/_StoryCalendarSurface", calendar);
if (dashboardPage)
{
surface = await Render("Projects/Details", new ProjectDetailViewModel {
Project = model.Project ?? new(),
Summary = new() { TotalBooks = 2, DraftingBooks = 1, PlanningBooks = 1, TotalWords = 68420, CharacterCount = 18, LocationCount = 12, ActivePlotThreadCount = 7, ContinuityWarningCount = 3 },
SeriesProgress = new() { Percentage = 42, SupportingLine = "68,420 of 160,000 planned words", CalculationLabel = "Word count" },
Books = [new() { BookID = 12, BookNumber = 1, BookTitle = "A Distant Shore", Subtitle = "The Glass Harbour · Book One", Status = "Drafting", CurrentWordCount = 68420, TargetWordCount = 80000, ProgressPercentage = 85.5m, ChapterCount = 24, SceneCount = 72, UpdatedDate = new DateTime(2026,10,28) }],
RecentActivity = [new() { ActivityType = "Updated", EntityType = "Scene", EntityName = "An unexpected arrival", Description = "Chapter 12 · A change of direction", TimeLabel = "Today", UserLabel = "Fixture Author", IconLabel = "Scene" }],
NeedsAttention = new() { Warnings = [new() { SeverityName = "Review", WarningTypeName = "Chronology", Message = "Check the order of events at the harbour.", LocationLabel = "Book 1 · Chapter 12" }] }
});
}
var initialTheme = appearance.ThemeKey ?? "warm-light";
var appearanceScript = "<script>window.plotdirectorAppearance=" + System.Text.Json.JsonSerializer.Serialize(new { theme = initialTheme, migrate = false, collapsed = appearance.RibbonCollapsed }) + ";</script>";
context.Response.ContentType = "text/html; charset=utf-8";
await context.Response.WriteAsync("<!doctype html><html lang='en' data-theme='light'><head><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1'><link rel='stylesheet' href='/lib/bootstrap/dist/css/bootstrap.min.css'><link rel='stylesheet' href='/css/site.css'><link rel='stylesheet' href='/css/plotline-theme.css'><link rel='stylesheet' href='/css/application-navigation.css'></head><body class='app-layout'><header>" + menu + toolbar + "</header><main class='plotline-help-main container-fluid'>" + surface + "</main><script src='/lib/bootstrap/dist/js/bootstrap.bundle.min.js'></script><script src='/js/application-navigation.js'></script><script src='/js/application-toolbar.js'></script></body></html>");
await context.Response.WriteAsync("<!doctype html><html lang='en' data-app-theme='" + initialTheme + "' data-theme='" + (initialTheme.EndsWith("dark") ? "dark" : "light") + "'><head><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1'><link rel='stylesheet' href='/lib/bootstrap/dist/css/bootstrap.min.css'><link rel='stylesheet' href='/css/site.css'><link rel='stylesheet' href='/css/plotline-theme.css'><link rel='stylesheet' href='/css/application-navigation.css'><link rel='stylesheet' href='/css/application-shell.css'></head><body class='app-layout'><header>" + menu + toolbar + "</header><main class='plotline-help-main container-fluid plotline-shell pd-dashboard-shell'>" + surface + "</main><script src='/lib/bootstrap/dist/js/bootstrap.bundle.min.js'></script><script src='/js/application-navigation.js'></script><script src='/js/application-toolbar.js'></script>" + appearanceScript + "<script src='/js/application-shell.js'></script></body></html>");
});
await app.RunAsync();
}

View File

@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PlotLine.Data;
using PlotLine.Services;
namespace PlotLine.Controllers;
[Authorize]
public sealed class AppearanceController(ICurrentUserService user, IAppearanceRepository preferences) : Controller
{
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Theme(string themeKey, bool onlyIfUnset = false)
{
if (user.UserId is not int id) return Unauthorized();
if (!ModelState.IsValid || !ApplicationAppearance.IsValid(themeKey)) return BadRequest();
await preferences.SaveThemeAsync(id, themeKey, onlyIfUnset);
return Json(await preferences.GetAsync(id));
}
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Ribbon(bool collapsed)
{
if (user.UserId is not int id) return Unauthorized();
if (!ModelState.IsValid) return BadRequest();
await preferences.SaveRibbonAsync(id, collapsed);
return Ok();
}
}

View File

@ -0,0 +1,29 @@
using System.Data;
using Dapper;
using PlotLine.Services;
namespace PlotLine.Data;
public interface IAppearanceRepository
{
Task<ApplicationAppearance> GetAsync(int userId);
Task SaveThemeAsync(int userId, string themeKey, bool onlyIfUnset = false);
Task SaveRibbonAsync(int userId, bool collapsed);
}
public sealed class AppearanceRepository(ISqlConnectionFactory connections) : IAppearanceRepository
{
public async Task<ApplicationAppearance> GetAsync(int userId)
{
using var connection = connections.CreateConnection();
return await connection.QuerySingleOrDefaultAsync<ApplicationAppearance>("dbo.UserAppearance_Get", new { UserID = userId }, commandType: CommandType.StoredProcedure) ?? new();
}
public async Task SaveThemeAsync(int userId, string themeKey, bool onlyIfUnset = false)
{
using var connection = connections.CreateConnection();
await connection.ExecuteAsync("dbo.UserAppearance_SaveTheme", new { UserID = userId, ThemeKey = themeKey, OnlyIfUnset = onlyIfUnset }, commandType: CommandType.StoredProcedure);
}
public async Task SaveRibbonAsync(int userId, bool collapsed)
{
using var connection = connections.CreateConnection();
await connection.ExecuteAsync("dbo.UserAppearance_SaveRibbon", new { UserID = userId, Collapsed = collapsed }, commandType: CommandType.StoredProcedure);
}
}

View File

@ -113,6 +113,7 @@ public class Program
builder.Services.AddScoped<IProjectRepository, ProjectRepository>();
builder.Services.AddScoped<ApplicationNavigation>();
builder.Services.AddScoped<IToolbarPreferenceRepository, ToolbarPreferenceRepository>();
builder.Services.AddScoped<IAppearanceRepository, AppearanceRepository>();
builder.Services.AddScoped<IBookRepository, BookRepository>();
builder.Services.AddScoped<IManuscriptDocumentRepository, ManuscriptDocumentRepository>();
builder.Services.AddScoped<IChapterRepository, ChapterRepository>();

View File

@ -0,0 +1,13 @@
namespace PlotLine.Services;
public sealed class ApplicationAppearance
{
public string? ThemeKey { get; set; }
public bool RibbonCollapsed { get; set; }
public static IReadOnlyDictionary<string, string> Themes { get; } = new Dictionary<string, string>
{
["modern-light"] = "Modern Light", ["modern-dark"] = "Modern Dark",
["warm-light"] = "Warm Light", ["warm-dark"] = "Warm Dark"
};
public static bool IsValid(string? theme) => theme is not null && Themes.ContainsKey(theme);
}

View File

@ -0,0 +1,58 @@
using PlotLine.ViewModels;
namespace PlotLine.Services;
public sealed record RibbonCommand(string Label, string IconKey, string Controller, string Action,
string Scope = "project", bool OwnerOnly = false, string? ToolbarKey = null)
{
public bool Available(ApplicationNavigationViewModel model) => (Scope == "global" || model.Project is not null)
&& (Scope != "book" && Scope != "chapter" || model.Book is not null) && (!OwnerOnly || model.Project?.IsOwner == true);
public object Values(ApplicationNavigationViewModel model) => Scope switch
{
"global" => new { }, "id" => new { id = model.Project?.ProjectID },
"book" => new { id = model.Book?.BookID }, "chapter" => new { bookId = model.Book?.BookID },
_ => new { projectId = model.Project?.ProjectID }
};
public static RibbonCommand Shortcut(string key)
{
var command = ToolbarCommands.All.Single(x => x.Key == key);
return new(command.Label, key, command.Controller, command.Action, ToolbarKey: key);
}
}
public sealed record RibbonGroup(string Label, params RibbonCommand[] Commands);
public sealed record RibbonCategory(string Key, string Label, params RibbonGroup[] Groups);
public static class ApplicationRibbon
{
private static RibbonCommand S(string key) => RibbonCommand.Shortcut(key);
public static IReadOnlyList<RibbonCategory> Categories { get; } = [
new("project", "Project",
new("Workspace", S("overview"), S("projects"), S("writer"), new("Import", "assets", "Imports", "Index", "global")),
new("Project", new("Edit project", "writer", "Projects", "Edit", "id"), new("Add book", "bible", "Books", "Create"), new("Activity", "metrics", "Projects", "Activity", "id")),
new("Manage", new("Collaborators", "characters", "ProjectCollaborators", "Index", OwnerOnly: true), new("Backup", "archive", "Exports", "ProjectBackup", OwnerOnly: true), new("Restore points", "archive", "ProjectRestorePoints", "Index"))),
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("calendar"), S("threads"), S("point")), new("Analysis & planning", S("review"), S("scenarios"), S("continuity")), new("Writing", S("writer"))),
new("characters", "Characters", new("Cast", S("characters"), S("names")), new("Connections", S("relationships"))),
new("world", "World", new("Setting", S("locations"), 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"))),
new("help", "Help", new RibbonGroup("Support", new("Help Centre", "bible", "Help", "Index", "global"), new("Feature Requests", "review", "FeatureRequests", "Index", "global")))
];
public static string ActiveCategory(string controller, string section) => controller switch
{
"Books" or "Chapters" or "Scenes" => "book", "Help" or "FeatureRequests" => "help",
"Onboarding" => "story",
_ => section switch
{
"Timeline" or "Calendar" or "At This Point" or "Threads" or "Scenarios" or "Continuity Explorer" => "story",
"Characters" or "Names" or "Relationships" => "characters",
"Locations" or "Assets" or "Floor Plans" => "world",
"Story Bible" or "Metrics" or "Health" or "Warnings" or "Archive" => "tools", _ => "project"
}
};
public static ToolbarCommand Icon(string key) => ToolbarCommands.All.Single(x => x.Key == key);
public static string Tone(string key) => key switch
{
"calendar" or "point" => "calendar", "characters" or "names" => "characters", "locations" or "floorplans" => "locations",
"relationships" => "relationships", "warnings" => "warning", "review" => "review", "bible" or "overview" or "projects" => "books", _ => "planning"
};
}

View File

@ -0,0 +1,33 @@
SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO
IF COL_LENGTH(N'dbo.AppUser', N'ApplicationThemeKey') IS NULL
ALTER TABLE dbo.AppUser ADD ApplicationThemeKey nvarchar(32) NULL;
IF COL_LENGTH(N'dbo.AppUser', N'RibbonCollapsed') IS NULL
ALTER TABLE dbo.AppUser ADD RibbonCollapsed bit NOT NULL CONSTRAINT DF_AppUser_RibbonCollapsed DEFAULT 0;
GO
CREATE OR ALTER PROCEDURE dbo.UserAppearance_Get @UserID int
AS
BEGIN
SET NOCOUNT ON;
SELECT ApplicationThemeKey AS ThemeKey, RibbonCollapsed FROM dbo.AppUser WHERE UserID = @UserID;
END;
GO
CREATE OR ALTER PROCEDURE dbo.UserAppearance_SaveTheme @UserID int, @ThemeKey nvarchar(32), @OnlyIfUnset bit = 0
AS
BEGIN
SET NOCOUNT ON;
IF @ThemeKey NOT IN ('modern-light','modern-dark','warm-light','warm-dark') OR @ThemeKey IS NULL
THROW 50001, 'Unknown application theme', 1;
UPDATE dbo.AppUser SET ApplicationThemeKey = @ThemeKey
WHERE UserID = @UserID AND (@OnlyIfUnset = 0 OR ApplicationThemeKey IS NULL);
END;
GO
CREATE OR ALTER PROCEDURE dbo.UserAppearance_SaveRibbon @UserID int, @Collapsed bit
AS
BEGIN
SET NOCOUNT ON;
UPDATE dbo.AppUser SET RibbonCollapsed = @Collapsed WHERE UserID = @UserID;
END;
GO

View File

@ -2,6 +2,9 @@
@{
ViewData["Title"] = Model.Project.ProjectName;
ViewData["ProjectSection"] = "Overview";
ViewData["ShellClass"] = "pd-dashboard-shell";
var statIcons = new[] { "bible", "bible", "writer", "threads", "metrics", "characters", "locations", "threads", "warnings" };
var statIndex = 0;
var summaryCards = new[]
{
@ -17,6 +20,7 @@
};
}
<div class="pd-dashboard">
<nav class="breadcrumb-trail" aria-label="Breadcrumb">
<a asp-controller="Projects" asp-action="Index">Projects</a>
<span>@Model.Project.ProjectName</span>
@ -74,9 +78,12 @@
<div class="dashboard-summary-grid">
@foreach (var card in summaryCards)
{
var iconKey = statIcons[statIndex++];
var icon = ApplicationRibbon.Icon(iconKey);
<div>
<div class="card h-100 dashboard-summary-card @card.Item3">
<div class="card-body dashboard-summary-body">
<svg class="pd-icon dashboard-stat-icon" data-tone="@ApplicationRibbon.Tone(iconKey)" viewBox="0 0 24 24" aria-hidden="true"><path d="@icon.IconPath" /></svg>
<p class="eyebrow dashboard-summary-label">@card.Item1</p>
<strong class="dashboard-summary-value">@card.Item2</strong>
</div>
@ -122,8 +129,8 @@
<div class="row g-4">
@foreach (var book in Model.Books)
{
<div class="col-12 col-md-6 col-lg-4">
<article class="card h-100 overflow-hidden">
<div class="col-12 col-xl-6 col-xxl-4">
<article class="card h-100 overflow-hidden dashboard-book-card">
<div class="row g-0 h-100">
<div class="col-4 d-flex align-items-center justify-content-center" style="aspect-ratio:2 / 3; background:var(--plotline-soft);">
<img src="@book.CoverThumbnailPath"
@ -186,7 +193,7 @@
<section aria-label="Dashboard attention">
<div class="row g-4">
<div class="col-12 col-xl-7">
<article class="card h-100">
<article class="card h-100 dashboard-activity-card">
<div class="card-body">
<div class="d-flex align-items-center justify-content-between gap-3 flex-wrap mb-3">
<h2 class="h5 mb-0">Recent Activity</h2>
@ -230,7 +237,7 @@
</div>
<div class="col-12 col-xl-5">
<article class="card h-100">
<article class="card h-100 dashboard-attention-card">
<div class="card-body">
<h2 class="h5 mb-3">Worth a look</h2>
@ -334,3 +341,5 @@
</div>
</div>
</section>
</div>

View File

@ -0,0 +1,146 @@
@model ApplicationNavigationViewModel
@{
var project = Model.Project;
var book = Model.Book;
var controller = ViewContext.RouteData.Values["controller"]?.ToString() ?? "";
var action = ViewContext.RouteData.Values["action"]?.ToString() ?? "";
var selectedCategory = ApplicationRibbon.ActiveCategory(controller, Model.ActiveSection);
var appearance = ViewData["ApplicationAppearance"] as ApplicationAppearance ?? new();
}
<section class="pd-shell" aria-label="Application commands" data-app-navigation data-ribbon-shell data-collapsed="@appearance.RibbonCollapsed.ToString().ToLowerInvariant()">
<div class="pd-titlebar">
<a class="pd-brand" asp-controller="Projects" asp-action="Index">PlotDirector<span class="pd-brand-mark" aria-hidden="true">.</span></a>
<partial name="_ApplicationToolbar" model="Model" />
<ul class="pd-context-menus">
<li class="nav-item dropdown">
<button class="nav-link dropdown-toggle @(controller == "Projects" ? "active" : null)" type="button" id="appProjectMenu" data-bs-toggle="dropdown" aria-expanded="false" title="@(project?.ProjectName ?? "Project")">
<span class="app-context-label">@(project?.ProjectName ?? "Project")</span>
</button>
<ul class="dropdown-menu" aria-labelledby="appProjectMenu">
@if (project is not null)
{
<li><h2 class="dropdown-header">@project.ProjectName</h2></li>
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Details" asp-route-id="@project.ProjectID">Project overview</a></li>
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Edit" asp-route-id="@project.ProjectID">Edit project</a></li>
<li><a class="dropdown-item" asp-controller="Books" asp-action="Create" asp-route-projectId="@project.ProjectID">Add book</a></li>
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Activity" asp-route-id="@project.ProjectID">Activity</a></li>
@if (project.IsOwner)
{
<li><a class="dropdown-item" asp-controller="ProjectCollaborators" asp-action="Index" asp-route-projectId="@project.ProjectID">Collaborators</a></li>
<li><a class="dropdown-item" asp-controller="Exports" asp-action="ProjectBackup" asp-route-projectId="@project.ProjectID">Download Project Backup</a></li>
}
<li><a class="dropdown-item" asp-controller="ProjectRestorePoints" asp-action="Index" asp-route-projectId="@project.ProjectID">Restore Points</a></li>
<li><hr class="dropdown-divider" /></li>
}
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Index">@(project is null ? "Projects" : "Switch project…")</a></li>
<li><a class="dropdown-item" asp-controller="Writer" asp-action="Index">Writer Workspace</a></li>
<li><a class="dropdown-item" asp-controller="Imports" asp-action="Index">Import</a></li>
</ul>
</li>
@if (project is not null)
{
<li class="nav-item dropdown">
<button class="nav-link dropdown-toggle @(controller is "Books" or "Chapters" or "Scenes" ? "active" : null)" type="button" id="appBookMenu" data-bs-toggle="dropdown" aria-expanded="false" title="@(book?.BookDisplayTitle ?? "Book")">
<span class="app-context-label app-book-label" data-app-book-label>@(book?.BookDisplayTitle ?? "Book")</span>
</button>
<ul class="dropdown-menu app-book-menu" aria-labelledby="appBookMenu">
<li><h2 class="dropdown-header" data-app-book-heading>@(book?.BookDisplayTitle ?? "Books in this project")</h2></li>
<li hidden="@(book is null)" data-app-book-action><a class="dropdown-item" data-app-book-url="@Url.Action("Details", "Books", new { id = (int?)null })" asp-controller="Books" asp-action="Details" asp-route-id="@book?.BookID">Book overview</a></li>
<li hidden="@(book is null)" data-app-book-action><a class="dropdown-item" data-app-book-url="@Url.Action("Edit", "Books", new { id = (int?)null })" asp-controller="Books" asp-action="Edit" asp-route-id="@book?.BookID">Edit book</a></li>
<li hidden="@(book is null)" data-app-book-action><a class="dropdown-item" data-app-book-url="@Url.Action("Create", "Chapters", new { id = (int?)null })" data-app-book-param="bookId" asp-controller="Chapters" asp-action="Create" asp-route-bookId="@book?.BookID">Add chapter</a></li>
<li hidden="@(book is null)" data-app-book-action><a class="dropdown-item" data-app-review-link data-review-url="@Url.Action("StoryIntelligenceBookReviewCentre", "Onboarding", new { bookId = 0 })" asp-controller="Onboarding" asp-action="StoryIntelligenceBookReviewCentre" asp-route-bookId="@book?.BookID">Review Centre</a></li>
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Details" asp-route-id="@project.ProjectID">All books / project overview</a></li>
<li><hr class="dropdown-divider" /></li>
@foreach (var choice in Model.Books)
{
<li><a class="dropdown-item @(choice.BookID == book?.BookID ? "active" : null)" aria-current="@(choice.BookID == book?.BookID ? "page" : null)" data-app-book-choice="@choice.BookID" data-app-book-title="@choice.BookDisplayTitle" asp-controller="Books" asp-action="Details" asp-route-id="@choice.BookID">Book @choice.BookNumber: @choice.BookDisplayTitle</a></li>
}
@if (Model.Books.Count == 0)
{
<li><span class="dropdown-item-text text-muted">No books yet</span></li>
}
</ul>
</li>
}
</ul>
<div class="pd-titlebar-end">
@if (Model.ShowCompanionPresence)
{
<span class="pd-presence" data-word-companion-presence data-word-companion-status="Offline" title="Word Companion status" role="status" aria-live="polite"><span class="word-companion-presence-dot" data-word-companion-status-dot></span><span data-word-companion-status-label>Offline</span></span>
}
<div class="nav-item dropdown app-account-menu">
<button class="nav-link dropdown-toggle" type="button" id="accountMenuButton" data-bs-toggle="dropdown" aria-expanded="false" title="@User.Identity?.Name">
<span class="app-account-label">@User.Identity?.Name</span>
</button>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="accountMenuButton">
<li><h2 class="dropdown-header">@User.Identity?.Name</h2></li>
<li><a class="dropdown-item" asp-controller="ManageAccount" asp-action="Index">Manage Account</a></li>
<li><a class="dropdown-item" asp-controller="Onboarding" asp-action="Index">Setup preferences</a></li>
@if (!(ViewData["ShellClass"] as string ?? "").Contains("marketing-shell", StringComparison.OrdinalIgnoreCase))
{
<li><button type="button" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#customiseToolbar">Customise Quick Access Toolbar…</button></li>
}
<li><a class="dropdown-item" asp-controller="ManageAccount" asp-action="Subscription">Billing / Subscription</a></li>
@if (Model.IsAdmin)
{
<li><hr class="dropdown-divider" /></li>
<li><a class="dropdown-item" asp-controller="Admin" asp-action="Index">Admin @if (Model.AdminFeatureRequestAttentionCount > 0) { <span class="badge text-bg-danger ms-1">@Model.AdminFeatureRequestAttentionCount</span> }</a></li>
}
<li><hr class="dropdown-divider" /></li>
<li><div class="px-3 py-2">
<div class="small text-muted mb-2">Theme</div>
<div class="pd-theme-picker" role="group" aria-label="Theme selection">
@foreach (var theme in ApplicationAppearance.Themes)
{
<button type="button" data-app-theme-choice="@theme.Key" aria-pressed="false"><span class="pd-theme-swatch" data-swatch="@theme.Key" aria-hidden="true"></span>@theme.Value</button>
}
</div>
<p class="small mb-0" role="status" data-appearance-status></p>
</div></li>
<li><hr class="dropdown-divider" /></li>
<li><form asp-controller="Account" asp-action="Logout" method="post" class="m-0"><button class="dropdown-item" type="submit">Logout</button></form></li>
</ul>
</div>
</div>
</div>
<div class="pd-ribbon-heading">
<div class="pd-ribbon-tabs" role="tablist" aria-label="Command categories">
@foreach (var category in ApplicationRibbon.Categories)
{
<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>
<button type="button" class="pd-ribbon-collapse" data-ribbon-collapse aria-expanded="@(!appearance.RibbonCollapsed ? "true" : "false")" aria-controls="ribbon-surface" title="Collapse or expand ribbon">@(appearance.RibbonCollapsed ? "Expand ribbon" : "Collapse ribbon") <span aria-hidden="true">⌃</span></button>
</div>
<div id="ribbon-surface" class="pd-ribbon-surface" hidden="@appearance.RibbonCollapsed">
@foreach (var category in ApplicationRibbon.Categories)
{
<div class="pd-ribbon-panel" id="ribbon-panel-@category.Key" role="tabpanel" aria-labelledby="ribbon-tab-@category.Key" hidden="@(category.Key != selectedCategory)">
@foreach (var group in category.Groups)
{
<div class="pd-ribbon-group" role="group" aria-label="@group.Label">
<div class="pd-ribbon-commands">
@foreach (var command in group.Commands.Where(x => !x.OwnerOnly || project?.IsOwner == true))
{
var shortcut = command.ToolbarKey is null ? null : ToolbarCommands.All.Single(x => x.Key == command.ToolbarKey);
var available = shortcut?.IsAvailable(Model) ?? command.Available(Model);
var url = available ? Url.Action(command.Action, command.Controller, shortcut?.RouteValues(Model) ?? command.Values(Model)) : null;
var active = available && (shortcut?.IsActive(controller, action, Model.ActiveSection) ?? (controller == command.Controller && action == command.Action));
var bookScoped = command.Scope is "book" or "chapter";
var icon = ApplicationRibbon.Icon(command.IconKey);
<a class="pd-ribbon-command" href="@url" aria-disabled="@(!available ? "true" : null)" aria-current="@(active ? "page" : null)"
data-review-url="@(command.ToolbarKey == "review" ? Url.Action(command.Action, command.Controller, new { bookId = 0 }) : null)"
data-ribbon-book-url="@(bookScoped ? Url.Action(command.Action, command.Controller, new { id = (int?)null, bookId = (int?)null }) : null)" data-book-param="@(command.Scope == "chapter" ? "bookId" : "id")"
title="@(available ? command.Label : bookScoped || shortcut?.RequiresBook == true ? "Select a book to use this command" : "Select a project to use this command")">
<svg viewBox="0 0 24 24" class="pd-icon" data-tone="@ApplicationRibbon.Tone(command.IconKey)" aria-hidden="true" focusable="false"><path d="@icon.IconPath" /></svg><span>@command.Label @if (command.Controller == "FeatureRequests" && Model.FeatureRequestAttentionCount > 0) { <span class="badge text-bg-warning">@Model.FeatureRequestAttentionCount</span> }</span>
</a>
}
</div>
<span class="pd-ribbon-group-label">@group.Label</span>
</div>
}
</div>
}
</div>
<form hidden data-appearance-form data-theme-url="@Url.Action("Theme", "Appearance")" data-ribbon-url="@Url.Action("Ribbon", "Appearance")">@Html.AntiForgeryToken()</form>
</section>

View File

@ -9,30 +9,30 @@
var controller = ViewContext.RouteData.Values["controller"]?.ToString() ?? "";
var action = ViewContext.RouteData.Values["action"]?.ToString() ?? "";
}
<nav class="app-toolbar" aria-label="Your toolbar" data-app-toolbar>
<nav class="app-toolbar" aria-label="Quick Access Toolbar" data-app-toolbar>
<div class="app-toolbar-commands" data-toolbar-commands>
@foreach (var command in ordered)
{
var available = command.IsAvailable(Model);
var active = available && command.IsActive(controller, action, Model.ActiveSection);
<a class="app-toolbar-command @(active ? "active" : null)" data-toolbar-key="@command.Key"
<a aria-label="@command.Label" class="app-toolbar-command @(active ? "active" : null)" data-toolbar-key="@command.Key"
data-review-url="@(command.RequiresBook ? Url.Action(command.Action, command.Controller, new { bookId = 0 }) : null)"
hidden="@(!keys.Contains(command.Key))" href="@(available ? Url.Action(command.Action, command.Controller, command.RouteValues(Model)) : null)"
aria-current="@(active ? "page" : null)" aria-disabled="@(!available ? "true" : null)"
title="@(available ? command.Label : command.RequiresBook && Model.Project is not null ? "Select a book to open Review Centre" : "Select a project to use this tool")">
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="@command.IconPath" /></svg><span>@command.Label</span>
<svg class="pd-icon" data-tone="@ApplicationRibbon.Tone(command.Key)" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="@command.IconPath" /></svg><span>@command.Label</span>
</a>
}
<span class="app-toolbar-empty" data-toolbar-empty hidden="@(keys.Length != 0)">Choose shortcuts from Customise toolbar…</span>
<span class="app-toolbar-empty" data-toolbar-empty hidden="@(keys.Length != 0)">Choose shortcuts from Customise Quick Access Toolbar…</span>
</div>
<button type="button" class="app-toolbar-customise" data-bs-toggle="modal" data-bs-target="#customiseToolbar" title="Customise toolbar" aria-label="Customise toolbar">⋯</button>
<button type="button" class="app-toolbar-customise" data-bs-toggle="modal" data-bs-target="#customiseToolbar" title="Customise Quick Access Toolbar" aria-label="Customise Quick Access Toolbar">⋯</button>
</nav>
<div class="modal fade" id="customiseToolbar" tabindex="-1" aria-labelledby="customiseToolbarTitle" aria-hidden="true" data-toolbar-dialog>
<div class="modal-dialog modal-dialog-scrollable">
<form class="modal-content" action="@Url.Action("Save", "Toolbar")" method="post" data-toolbar-form>
@Html.AntiForgeryToken()
<div class="modal-header">
<h2 class="modal-title fs-5" id="customiseToolbarTitle">Customise toolbar</h2>
<h2 class="modal-title fs-5" id="customiseToolbarTitle">Customise Quick Access Toolbar</h2>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Cancel"></button>
</div>
<div class="modal-body">

View File

@ -4,6 +4,7 @@
@inject IConfiguration Configuration
@inject IFeatureRequestService FeatureRequestService
@inject ApplicationNavigation Navigation
@inject PlotLine.Data.IAppearanceRepository AppearancePreferences
@inject IOnboardingService OnboardingService
@inject IStoryIntelligenceGlobalProgressService StoryIntelligenceGlobalProgress
@{
@ -28,6 +29,9 @@
appNavigation.ShowCompanionPresence = showWordCompanionHeader;
appNavigation.FeatureRequestAttentionCount = featureRequestAttentionCount;
appNavigation.AdminFeatureRequestAttentionCount = adminFeatureRequestAttentionCount;
var isApplication = User.Identity?.IsAuthenticated == true && !isMarketingPage;
var appearance = isApplication && userId.HasValue ? await AppearancePreferences.GetAsync(userId.Value) : new ApplicationAppearance();
ViewData["ApplicationAppearance"] = appearance;
var seoMetadata = ViewData["Seo"] as SeoMetadata;
var defaultTitle = PublicSeo.DisplayTitle(ViewData["Title"] as string);
var seoTitle = ViewData["SeoTitle"] is string seoTitleValue ? seoTitleValue : defaultTitle;
@ -87,8 +91,24 @@
{
<link rel="canonical" href="@canonicalUrl" />
}
@if (isApplication)
{
<script>
(() => {
const saved = @Html.Raw(System.Text.Json.JsonSerializer.Serialize(appearance.ThemeKey));
let legacy = null;
try { legacy = localStorage.getItem('plotline.theme'); } catch { }
const theme = saved || (legacy === 'dark' ? 'warm-dark' : 'warm-light');
document.documentElement.dataset.appTheme = theme;
document.documentElement.dataset.theme = theme.endsWith('-dark') ? 'dark' : 'light';
document.documentElement.dataset.bsTheme = document.documentElement.dataset.theme;
window.plotdirectorAppearance = { theme, migrate: !saved, collapsed: @(appearance.RibbonCollapsed ? "true" : "false") };
})();
</script>
}
<script>
(() => {
if (document.documentElement.dataset.appTheme) return;
let savedTheme = null;
try {
savedTheme = localStorage.getItem("plotline.theme");
@ -123,15 +143,22 @@
<meta name="msapplication-TileColor" content="#1F2A44" />
<meta name="theme-color" content="#1F2A44" />
<link rel="stylesheet" href="~/css/application-navigation.css" asp-append-version="true" />
@if (isApplication)
{
<link rel="stylesheet" href="~/css/application-shell.css" asp-append-version="true" />
}
</head>
<body class="@(User.Identity?.IsAuthenticated == true && !isMarketingPage ? "app-layout" : null)">
<header>
@if (User.Identity?.IsAuthenticated == true)
{
<partial name="_ApplicationNavigation" model="appNavigation" />
@if (!isMarketingPage)
@if (isApplication)
{
<partial name="_ApplicationToolbar" model="appNavigation" />
<partial name="_ApplicationShell" model="appNavigation" />
}
else
{
<partial name="_ApplicationNavigation" model="appNavigation" />
}
}
else
@ -331,6 +358,7 @@
@if (!isMarketingPage)
{
<script src="~/js/application-toolbar.js" asp-append-version="true"></script>
<script src="~/js/application-shell.js" asp-append-version="true"></script>
}
<script src="~/js/word-companion-presence.js" asp-append-version="true"></script>
<script src="~/js/story-intelligence-global-progress.js" asp-append-version="true"></script>

View File

@ -0,0 +1,185 @@
/* Shared semantic palette. Legacy light/dark remains a compatibility layer for feature pages. */
html[data-app-theme] {
--pd-workspace: #f6f1e8; --pd-surface: #fffdf8; --pd-surface-2: #f4ebdd; --pd-elevated: #fffdf9;
--pd-chrome: #f2e9dc; --pd-chrome-secondary: #fbf6ef; --pd-border: #d8ccbb; --pd-border-subtle: #e9dfd2;
--pd-text: #30291f; --pd-muted: #726454; --pd-heading: #30291f; --pd-accent: #86532e; --pd-accent-hover: #6e4020;
--pd-selected: #eaddcb; --pd-hover: #eee3d5; --pd-focus: #985b28; --pd-on-accent: #fff;
--pd-danger: #b4313c; --pd-warning: #936010; --pd-success: #327557; --pd-info: #326e9f;
--pd-icon-books: #376caa; --pd-icon-planning: #377e82; --pd-icon-calendar: #a95734; --pd-icon-characters: #7756a5;
--pd-icon-locations: #3e7c50; --pd-icon-relationships: #a34876; --pd-icon-review: #976318;
--pd-font-ui: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
--pd-radius: 5px; --pd-shadow: 0 3px 12px rgb(35 27 15 / 5%);
}
html[data-app-theme="modern-light"] {
--pd-workspace: #f4f5f7; --pd-surface: #fff; --pd-surface-2: #f0f2f5; --pd-elevated: #fff;
--pd-chrome: #f0f1f3; --pd-chrome-secondary: #fafbfc; --pd-border: #d4d8df; --pd-border-subtle: #e7e9ed;
--pd-text: #292e36; --pd-muted: #626b78; --pd-heading: #20252d; --pd-accent: #875330; --pd-accent-hover: #714023;
--pd-selected: #ece3dc; --pd-hover: #e5e8ed; --pd-focus: #98552b; --pd-shadow: 0 3px 14px rgb(20 30 45 / 4%);
}
html[data-app-theme="modern-dark"] {
--pd-workspace: #1d1f23; --pd-surface: #25282d; --pd-surface-2: #2d3036; --pd-elevated: #32363d;
--pd-chrome: #24272c; --pd-chrome-secondary: #2b2e34; --pd-border: #484d57; --pd-border-subtle: #383d45;
--pd-text: #e4e7ec; --pd-muted: #aab2bf; --pd-heading: #f4f5f7; --pd-accent: #dfa979; --pd-accent-hover: #efbd92;
--pd-selected: #44403d; --pd-hover: #3a3f48; --pd-focus: #edb787; --pd-on-accent: #211a15; --pd-shadow: none;
}
html[data-app-theme="warm-dark"] {
--pd-workspace: #171310; --pd-surface: #231e19; --pd-surface-2: #30271f; --pd-elevated: #382e25;
--pd-chrome: #251e18; --pd-chrome-secondary: #30271f; --pd-border: #5c4a3b; --pd-border-subtle: #44382e;
--pd-text: #eee3d4; --pd-muted: #c4af99; --pd-heading: #faecdc; --pd-accent: #dda872; --pd-accent-hover: #f0c18e;
--pd-selected: #4a3524; --pd-hover: #43362b; --pd-focus: #edb787; --pd-on-accent: #211a15; --pd-shadow: none;
}
html[data-app-theme$="dark"] {
--pd-danger: #f08c97; --pd-warning: #efbf68; --pd-success: #80c7a5; --pd-info: #8cb9f0;
--pd-icon-books: #88b5f3; --pd-icon-planning: #76c3c9; --pd-icon-calendar: #ecab83; --pd-icon-characters: #c0a3ec;
--pd-icon-locations: #8bc695; --pd-icon-relationships: #e298bc; --pd-icon-review: #e5be75;
}
/* Bridge established component tokens without independently redesigning feature pages. */
html[data-app-theme] .app-layout {
--plotline-bg: var(--pd-workspace); --plotline-bg-warm: var(--pd-workspace); --plotline-surface: var(--pd-surface);
--plotline-surface-elevated: var(--pd-elevated); --plotline-text: var(--pd-text); --plotline-text-muted: var(--pd-muted);
--plotline-ink: var(--pd-text); --plotline-muted: var(--pd-muted); --plotline-soft: var(--pd-surface-2);
--plotline-accent: var(--pd-accent); --plotline-accent-dark: var(--pd-accent); --plotline-accent-soft: var(--pd-selected);
--plotline-border-soft: var(--pd-border-subtle); --app-text: var(--pd-text); --app-text-muted: var(--pd-muted);
--app-bg: var(--pd-workspace); --app-surface: var(--pd-surface); --app-surface-2: var(--pd-surface-2);
--app-surface-alt: var(--pd-elevated); --app-card-bg: var(--pd-surface); --app-border: var(--pd-border); --app-timeline-bg: var(--pd-surface-2);
--plotline-paper: var(--pd-surface); --plotline-panel: var(--pd-surface); --plotline-line: var(--pd-border-subtle);
--plotline-danger: var(--pd-danger); --plotline-warning: var(--pd-warning); --plotline-success: var(--pd-success);
--app-link: var(--pd-accent); --app-input-bg: var(--pd-surface); --app-input-text: var(--pd-text);
--bs-body-bg: var(--pd-workspace); --bs-body-color: var(--pd-text); --bs-secondary-color: var(--pd-muted);
--bs-border-color: var(--pd-border); --bs-tertiary-bg: var(--pd-surface-2);
--bs-card-bg: var(--pd-surface); --bs-card-color: var(--pd-text); --bs-modal-bg: var(--pd-elevated);
--bs-dropdown-bg: var(--pd-elevated); --bs-link-color: var(--pd-accent); --bs-link-hover-color: var(--pd-accent-hover);
background: var(--pd-workspace); color: var(--pd-text);
}
.app-layout .pd-shell {
background: var(--pd-chrome); color: var(--pd-text); border-bottom: 1px solid var(--pd-border);
font-family: var(--pd-font-ui); margin-bottom: 18px; position: relative;
}
.pd-shell *, .pd-shell *::before, .pd-shell *::after { box-sizing: border-box; }
.pd-shell [hidden] { display: none !important; }
.pd-shell button, .pd-shell input, .pd-shell .dropdown-header { font-family: var(--pd-font-ui); }
.pd-titlebar { display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 4px 20px; }
.pd-brand { font: 650 15px var(--pd-font-ui); letter-spacing: -.45px; color: var(--pd-text) !important; text-decoration: none; flex-shrink: 0; }
.pd-brand-mark { color: var(--pd-accent); font-size: 24px; line-height: 0; }
.pd-context-menus { display: flex; align-items: center; gap: 4px; padding: 0 0 0 12px; margin: 0; list-style: none; border-left: 1px solid var(--pd-border); min-width: 0; }
.pd-shell .nav-link { display: flex; align-items: center; gap: 5px; border: 0; background: transparent; color: var(--pd-text); font-size: 12px; padding: 7px 8px; border-radius: 4px; white-space: nowrap; }
.pd-shell .nav-link:hover, .pd-shell .nav-link.show { background: var(--pd-hover); color: var(--pd-text); }
.pd-shell .app-context-label { max-width: 190px; }
.pd-shell .app-book-label { max-width: 140px; }
.pd-titlebar-end { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.pd-presence { display: inline-flex; align-items: center; gap: 5px; color: var(--pd-muted); font-size: 11px; }
.pd-shell .app-account-label { max-width: 130px; }
.pd-shell .dropdown-menu { background: var(--pd-elevated) !important; color: var(--pd-text); border: 1px solid var(--pd-border); border-radius: var(--pd-radius); box-shadow: var(--pd-shadow); max-height: 70vh; overflow-y: auto; min-width: 220px; max-width: min(360px, 94vw); }
.pd-shell .dropdown-item, .pd-shell .dropdown-header { color: var(--pd-text) !important; font-size: 13px; white-space: normal; }
.pd-shell .dropdown-item:hover, .pd-shell .dropdown-item:focus, .pd-shell .dropdown-item.active { background: var(--pd-hover) !important; color: var(--pd-text) !important; }
.pd-shell .app-toolbar { background: transparent; border: 0; padding: 0; margin: 0; min-height: 30px; flex: 0 1 auto; max-width: 32vw; }
.pd-shell .app-toolbar-command { padding: 5px 7px; line-height: 18px; border: 0; border-radius: 3px; box-shadow: none; color: var(--pd-text); }
.pd-shell .app-toolbar-command > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.pd-shell .app-toolbar-command:hover { background: var(--pd-hover); }
.pd-shell .app-toolbar-command.active { background: var(--pd-selected); box-shadow: none; }
.pd-shell .app-toolbar-customise { font-size: 18px; padding: 0 6px; border: 0; color: var(--pd-muted); }
.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-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-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: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-shell .pd-ribbon-command:hover { background: var(--pd-hover); }
.pd-shell .pd-ribbon-command[aria-current="page"] { background: var(--pd-selected); }
.pd-ribbon-group-label { display: block; text-align: center; color: var(--pd-muted); font-size: 10px; letter-spacing: .03em; padding-top: 4px; }
.pd-shell [aria-disabled="true"] { opacity: .45; cursor: default; }
.pd-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
[data-tone="books"] { color: var(--pd-icon-books); } [data-tone="planning"] { color: var(--pd-icon-planning); }
[data-tone="calendar"] { color: var(--pd-icon-calendar); } [data-tone="characters"] { color: var(--pd-icon-characters); }
[data-tone="locations"] { color: var(--pd-icon-locations); } [data-tone="relationships"] { color: var(--pd-icon-relationships); }
[data-tone="review"] { color: var(--pd-icon-review); } [data-tone="warning"] { color: var(--pd-warning); }
.pd-shell :is(button,a,input):focus-visible, .pd-dashboard :is(a,button,input):focus-visible { outline: 2px solid var(--pd-focus); outline-offset: 2px; }
.pd-theme-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pd-theme-picker button { display: flex; align-items: center; gap: 6px; font-size: 11px; padding: 8px 6px; border: 1px solid var(--pd-border); border-radius: 4px; background: var(--pd-surface); color: var(--pd-text); white-space: nowrap; }
.pd-theme-picker [aria-pressed="true"] { border-color: var(--pd-accent); background: var(--pd-selected); }
.pd-theme-swatch { width: 13px; height: 13px; border-radius: 50%; border: 1px solid #8a8a8a; flex-shrink: 0; }
[data-swatch="modern-light"] { background: #f4f5f7; } [data-swatch="modern-dark"] { background: #25282d; }
[data-swatch="warm-light"] { background: #f4ebdd; } [data-swatch="warm-dark"] { background: #30271f; }
.pd-shell .modal-content { background: var(--pd-elevated) !important; color: var(--pd-text); border: 1px solid var(--pd-border); border-radius: 7px; }
.pd-shell .modal-title { font: 600 17px var(--pd-font-ui); }
.pd-shell .modal-dialog { max-width: 510px; }
.pd-shell .text-muted { color: var(--pd-muted) !important; }
.pd-shell .toolbar-choice { border-color: var(--pd-border-subtle); }
.pd-shell .btn, .pd-dashboard .btn { border-radius: 4px; font-family: var(--pd-font-ui); font-weight: 500; box-shadow: none; }
.pd-shell .btn-primary, .pd-dashboard .btn-primary { background: var(--pd-accent) !important; border-color: var(--pd-accent) !important; color: var(--pd-on-accent) !important; }
.pd-shell .btn-primary:hover, .pd-dashboard .btn-primary:hover { background: var(--pd-accent-hover) !important; }
.pd-shell .btn-outline-secondary, .pd-dashboard .btn-outline-secondary, .pd-dashboard .pw-actions__toggle { background: transparent !important; border-color: var(--pd-border) !important; color: var(--pd-text) !important; }
.pd-shell .btn-outline-secondary:hover, .pd-dashboard .btn-outline-secondary:hover { background: var(--pd-hover) !important; }
/* Series Dashboard is the Phase 1 reference workspace. */
.app-layout .plotline-shell.pd-dashboard-shell { max-width: none; padding-inline: clamp(20px, 2.6vw, 54px); }
.pd-dashboard { padding-bottom: 28px; font-family: var(--pd-font-ui); }
.pd-dashboard .breadcrumb-trail { margin-bottom: 20px; }
.pd-dashboard .page-heading { margin-bottom: 28px; align-items: center; }
.pd-dashboard h1 { font-size: clamp(30px, 2.6vw, 42px); font-weight: 500; letter-spacing: -.7px; margin-bottom: 8px; }
.pd-dashboard h1, .pd-dashboard h3 a { color: var(--pd-heading) !important; }
.pd-dashboard .eyebrow { font: 600 10px var(--pd-font-ui); letter-spacing: .12em; color: var(--pd-muted); }
.pd-dashboard .lead-text { font: 14px/1.6 var(--pd-font-ui); color: var(--pd-muted) !important; max-width: 760px; }
.pd-dashboard .card { background: var(--pd-surface) !important; border: 0 !important; border-radius: 7px; box-shadow: var(--pd-shadow); color: var(--pd-text); }
.pd-dashboard .card-body { padding: 22px; }
.pd-dashboard .dashboard-summary-grid { display: grid; grid-template-columns: repeat(9,minmax(0,1fr)); gap: 1px; background: var(--pd-border-subtle); border-radius: 7px; overflow: hidden; }
.pd-dashboard .dashboard-summary-card { box-shadow: none; border-radius: 0; height: 100%; }
.pd-dashboard .dashboard-summary-body { padding: 18px 14px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.pd-dashboard .dashboard-summary-label { grid-column: 1 / -1; grid-row: 2; margin: 0; font-size: 10px; letter-spacing: .01em; text-transform: none; white-space: normal; color: var(--pd-muted) !important; }
.pd-dashboard .dashboard-summary-value { grid-column: 1; grid-row: 1; font: 600 clamp(19px,1.8vw,28px)/1.2 var(--pd-font-ui); color: var(--pd-text); }
.pd-dashboard .dashboard-stat-icon { grid-column: 2; grid-row: 1; width: 21px; height: 21px; }
.pd-dashboard .dashboard-progress-card { background: transparent !important; box-shadow: none; }
.pd-dashboard .dashboard-progress-body { padding: 18px 0 12px; }
.pd-dashboard .dashboard-progress-title { font: 600 18px var(--pd-font-ui); color: var(--pd-text); }
.pd-dashboard .dashboard-progress-heading { margin-bottom: 12px; }
.pd-dashboard .dashboard-series-progress, .pd-dashboard .progress { height: 5px; border-radius: 3px; background: var(--pd-border-subtle); }
.pd-dashboard .progress-bar { background: var(--pd-accent); }
.pd-dashboard .status-pill { border: 0; border-radius: 4px; padding: 3px 7px; background: var(--pd-surface-2) !important; color: var(--pd-muted) !important; font: 500 11px var(--pd-font-ui); }
.pd-dashboard .dashboard-status-published, .pd-dashboard .dashboard-status-ready { color: var(--pd-success) !important; }
.pd-dashboard .dashboard-status-drafting { color: var(--pd-info) !important; }
.pd-dashboard .dashboard-status-revising, .pd-dashboard .dashboard-status-editing { color: var(--pd-icon-characters) !important; }
.pd-dashboard .dashboard-attention-soft { color: var(--pd-warning) !important; }
.pd-dashboard .list-group-item { background: transparent !important; color: var(--pd-text); border-color: var(--pd-border-subtle) !important; padding-block: 14px; }
.pd-dashboard .border-top { border-color: var(--pd-border-subtle) !important; }
.pd-dashboard .text-muted, .pd-dashboard .muted { color: var(--pd-muted) !important; }
.pd-dashboard .dashboard-book-card .card-body { padding: 20px; }
.pd-dashboard .dashboard-book-card h3 { font-size: 23px; line-height: 1.25; }
.pd-dashboard .dashboard-book-subtitle { color: var(--pd-muted); font-size: 13px; }
.pd-dashboard .dashboard-book-card .btn { font-size: 12px; }
.pd-dashboard .dashboard-attention-card h2, .pd-dashboard .dashboard-activity-card h2 { font: 600 17px var(--pd-font-ui); }
.pd-dashboard .dashboard-attention-card h3 { font: 600 13px var(--pd-font-ui); color: var(--pd-text); }
@media (max-width: 1199px) {
.pd-titlebar { gap: 8px; padding-inline: 12px; flex-wrap: wrap; }
.pd-shell .app-toolbar { max-width: 40vw; }
.pd-shell .app-context-label { max-width: 140px; }
.pd-shell .app-book-label { max-width: 110px; }
.pd-dashboard .dashboard-summary-grid { grid-template-columns: repeat(5,minmax(0,1fr)); }
}
@media (max-width: 767px) {
.pd-titlebar { gap: 5px; }
.pd-titlebar > .app-toolbar { order: 3; flex: 1 1 100%; max-width: 100%; padding-bottom: 3px; }
.pd-context-menus { order: 4; width: 100%; border: 0; padding-left: 0; }
.pd-titlebar-end { margin-left: auto; }
.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-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-dashboard .dashboard-summary-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
.pd-dashboard .dashboard-summary-body { padding: 14px 10px; }
}
@media (prefers-reduced-motion: reduce) {
.app-layout *, .app-layout *::before, .app-layout *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

View File

@ -35,6 +35,19 @@
link.title = 'Select a book to open Review Centre';
}
});
navigation.querySelectorAll('[data-ribbon-book-url]').forEach(link => {
if (!link.dataset.ribbonBookUrl) return;
if (selected) {
const url = new URL(link.dataset.ribbonBookUrl, location.origin);
url.searchParams.set(link.dataset.bookParam, id);
link.href = url.pathname + url.search;
link.removeAttribute('aria-disabled');
link.title = link.textContent.trim();
} else {
link.removeAttribute('href'); link.setAttribute('aria-disabled', 'true');
link.title = 'Select a book to use this command';
}
});
navigation.querySelectorAll('[data-app-book-action]').forEach(item => {
item.hidden = !selected;
const link = item.querySelector('[data-app-book-url]');

View File

@ -0,0 +1,75 @@
(() => {
const shell = document.querySelector('[data-ribbon-shell]');
if (!shell) return;
const appearance = window.plotdirectorAppearance || { theme: 'warm-light', migrate: false };
const form = shell.querySelector('[data-appearance-form]');
const status = shell.querySelector('[data-appearance-status]');
const tabs = [...shell.querySelectorAll('[data-ribbon-tab]')];
const surface = shell.querySelector('#ribbon-surface');
const collapse = shell.querySelector('[data-ribbon-collapse]');
const choices = [...shell.querySelectorAll('[data-app-theme-choice]')];
let theme = appearance.theme, busy = false;
function applyTheme(value) {
theme = value;
document.documentElement.dataset.appTheme = value;
document.documentElement.dataset.theme = value.endsWith('-dark') ? 'dark' : 'light';
document.documentElement.dataset.bsTheme = document.documentElement.dataset.theme;
choices.forEach(button => button.setAttribute('aria-pressed', String(button.dataset.appThemeChoice === value)));
window.dispatchEvent(new CustomEvent('plotdirector:theme-changed', { detail: { theme: value } }));
}
async function save(url, values) {
const data = new FormData(form);
Object.entries(values).forEach(([key, value]) => data.append(key, String(value)));
const response = await fetch(url, { method: 'POST', body: data, headers: { 'X-Requested-With': 'XMLHttpRequest' } });
if (!response.ok || response.redirected) throw new Error('Could not save appearance. Please try again.');
return response;
}
async function choose(value, migrate = false) {
if (busy) return;
busy = true;
const previous = theme;
applyTheme(value);
choices.forEach(button => button.disabled = true);
status.textContent = '';
try {
const result = await (await save(form.dataset.themeUrl, { themeKey: value, onlyIfUnset: migrate })).json();
applyTheme(result.themeKey);
status.textContent = migrate ? '' : 'Theme saved';
} catch (error) { applyTheme(previous); status.textContent = error.message; }
finally { busy = false; choices.forEach(button => button.disabled = false); }
}
applyTheme(theme);
choices.forEach(button => button.addEventListener('click', () => choose(button.dataset.appThemeChoice)));
if (appearance.migrate) choose(theme, true);
function setCollapsed(value) {
shell.dataset.collapsed = String(value);
surface.hidden = value;
collapse.setAttribute('aria-expanded', String(!value));
collapse.innerHTML = value ? 'Expand ribbon <span aria-hidden="true">⌄</span>' : 'Collapse ribbon <span aria-hidden="true">⌃</span>';
}
function select(tab) {
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.
setCollapsed(false);
}
tabs.forEach((tab, index) => {
tab.addEventListener('click', () => select(tab));
tab.addEventListener('keydown', event => {
let next;
if (event.key === 'ArrowRight') next = (index + 1) % tabs.length;
if (event.key === 'ArrowLeft') next = (index + tabs.length - 1) % tabs.length;
if (event.key === 'Home') next = 0;
if (event.key === 'End') next = tabs.length - 1;
if (next === undefined) return;
event.preventDefault(); tabs[next].focus(); select(tabs[next]);
});
});
collapse.addEventListener('click', async () => {
const previous = surface.hidden;
setCollapsed(!previous); collapse.disabled = true;
try { await save(form.dataset.ribbonUrl, { collapsed: !previous }); }
catch (error) { setCollapsed(previous); status.textContent = error.message; collapse.title = error.message; }
finally { collapse.disabled = false; }
});
})();

View File

@ -1,4 +1,4 @@
(() => {
(() => {if(document.documentElement.dataset.appTheme)return;
const storageKey = "plotline.theme";
const choices = document.querySelectorAll("[data-theme-choice]");

File diff suppressed because one or more lines are too long

View File

@ -1,51 +1,73 @@
# Authenticated application toolbar
# Application shell, ribbon and Quick Access
The existing `ApplicationNavigation` service remains the authority for project/book context. It uses the user-scoped project repository, rejects inaccessible projects and limits book selection to that project's non-archived books. The Bootstrap application menus, account/status controls and mobile menu collapse remain in place. Public navigation and feature page content are unchanged.
The authenticated, non-marketing branch of `_Layout.cshtml` renders `_ApplicationShell.cshtml`. It contains one title/Quick Access/context row, a command category row and a compact grouped command surface. Public pages retain `_ApplicationNavigation` and their existing styling/theme behaviour. Feature page layouts and business logic are unchanged; the Series Dashboard (`Projects/Details`) is the Phase 1 reference workspace.
`_ApplicationToolbar.cshtml` renders immediately below the application menu only for authenticated, non-marketing pages. It uses the existing Bootstrap modal/dropdown facilities and theme variables, with small inline SVG icons consistent with the existing codebase (there is no shared icon package). The strip is approximately 40px high; on narrow screens its labelled links scroll horizontally and the existing application menu collapses. Unavailable shortcuts are disabled without an href. Menus remain the comprehensive navigation mechanism.
## Navigation and permissions
## Command registry
`ApplicationNavigation` continues to resolve project context through the current user's project repository and restrict book choices to that project's non-archived books. Project switching still leads to Projects; the project and book dropdowns retain the existing actions. Account, subscription, admin, logout and Word Companion status controls remain available.
`PlotLine/Services/ToolbarCommands.cs` defines stable keys, labels, SVG paths, destination controllers/actions, default membership, project/book requirements, route values and active-state detection. Current defaults, in order:
`ApplicationRibbon.Categories` defines categories, groups and commands. Most commands refer to `ToolbarCommands` by stable key and share its icon, destination and context rules. Ribbon-only commands specify controller/action, scope (`global`, project ID, route `id`, book ID, or chapter creation's `bookId`) and owner-only visibility. Destination controllers retain their own authorisation checks. An unavailable command has no href and exposes `aria-disabled`; no book is silently selected.
- Overview, Timeline, Calendar, Characters, Threads, Relationships, Review Centre.
| Category | Groups and commands |
| --- | --- |
| Project | Workspace: Overview, Projects, Writer, Import. Project: Edit project, Add book, Activity. Manage: Collaborators, Backup, Restore points. |
| Book | Selected book: Book overview, Edit book, Add chapter. Manuscript review: Review Centre. Library: Overview, Add book. |
| Story | Story structure: Timeline, Calendar, Threads, At This Point. Analysis & planning: Review Centre, Scenarios, Continuity. Writing: Writer. |
| Characters | Cast: Characters, Names. Connections: Relationships. |
| World | Setting: Locations, Floor Plans. Story world: Assets. |
| Tools | Reference: Story Bible. Insights: Metrics, Health, Warnings. Organisation: Archive. |
| Help | Support: Help Centre, Feature Requests (including attention count). |
Other commands:
No nonexistent Plot Lines landing page or new AI command was invented. Threads uses the established PlotThreads route; Review Centre uses the existing book review action. Owner-only collaborators/backup remain owner-only.
- Locations, Assets, Names, At This Point, Scenarios, Floor Plans, Story Bible, Continuity, Metrics, Health, Warnings, Archive, Projects, Writer.
`ApplicationRibbon.ActiveCategory` uses the controller and existing `ActiveSection`, not URL substring matching. Category selection changes the visible commands without navigation. ARIA tabs expose selection and support arrows, Home and End; Tab reaches actual commands. Links independently mark the current feature with `aria-current`. `application-navigation.js` still follows Calendar/At This Point asynchronous book changes and updates book-scoped links using only authorised menu choices.
Threads uses the existing PlotThreads destination. There is no independent project-wide Plot Lines or Knowledge landing page to expose. Review Centre uses the existing book review route; it requires a selected book and does not choose one implicitly. Review Centre is also in the Book menu. No new AI or review preparation operation was added. All registered destinations use existing access checks; there are no owner/admin-only toolbar commands. Adding a restricted command must include its visibility/availability check here as well as the destination's normal server-side authorisation.
To add a ribbon command, add it to a category/group in `ApplicationRibbon`. Reuse a Quick Access key when possible. Extend scoped route generation for new parameter shapes, and include required availability/permission checks. Each command has a meaningful inline SVG and text. No icon or drag/drop framework was added.
To add a command, add a `ToolbarCommand` to `All`, choose a unique stable key and set the actual MVC destination and section. Supply a 24x24 SVG path; labels remain visible. Set `IsDefault` if new/default users should see it. Array order determines default order. `RouteValues` handles project destinations, overview IDs and book review IDs; extend it for a destination with different parameters. Never store URLs in preferences. The registry and rendering partial are separate from the preference model, so future command execution can extend dispatch without changing stored identifiers. No speculative context commands are implemented.
## Quick Access Toolbar
## Preferences and migration
The former standalone toolbar is now embedded in the title row. `_ApplicationToolbar.cshtml`, its editor, stable registry keys, `ToolbarController.Save` and `IToolbarPreferenceRepository` are retained. Compact icons have full accessible names and native tooltips; the ribbon retains visible labels. The account menu and ellipsis button open **Customise Quick Access Toolbar**.
Apply `PlotLine/Sql/201_UserToolbarPreferences.sql` **before deploying this code**, following the repository's backup and manual migration procedure. This work does not apply it to shared development or production.
Default keys/order remain Overview, Timeline, Calendar, Characters, Threads, Relationships and Review Centre. Optional commands remain Locations, Assets, Names, At This Point, Scenarios, Floor Plans, Story Bible, Continuity, Metrics, Health, Warnings, Archive, Projects and Writer.
The nullable `dbo.AppUser.ToolbarCommandKeysJson` column is accessed exclusively through `dbo.UserToolbar_Get` and `dbo.UserToolbar_Save` and `IToolbarPreferenceRepository`. It belongs to the existing account row and is removed naturally when the account is deleted. No preference rows are created by rendering a page.
`dbo.AppUser.ToolbarCommandKeysJson`, introduced by migration 201, is unchanged. NULL follows current defaults; an ordered JSON key array is a complete custom configuration (membership = enabled, absence = disabled). An empty array intentionally hides all shortcuts. Newly introduced commands are not appended to custom arrays. Removed keys are ignored, remaining order retained, malformed JSON falls back to defaults. URLs are never persisted.
- SQL NULL means follow the current system defaults.
- A JSON array of stable keys is an explicit custom configuration. Array position is display order; membership means enabled and absence means disabled. An empty array deliberately hides every command.
- New commands are never appended to an existing custom array. Removed keys are ignored; remaining order is preserved. Malformed stored JSON falls back to defaults.
- Restore defaults previews current defaults, then Save writes NULL. Cancel (including Escape/backdrop/close) leaves the persisted configuration and toolbar unchanged.
- `ToolbarController.Save` requires authentication and antiforgery, obtains the user ID from the authenticated identity, validates command keys/duplicates and never accepts a target user ID or URL.
- Preferences are loaded from SQL on each authenticated application page, so they survive logout, browser changes and app restarts. Concurrent browser saves use last-save-wins behavior.
The editor retains native drag/drop, named up/down controls, checkboxes, scrolling, Restore Defaults, Cancel and Save. Changes update the visible toolbar only after successful persistence. Cancel/Escape/backdrop leaves the saved toolbar unchanged. Save requires authentication and antiforgery and never accepts a target user ID. To add a Quick Access command, extend `ToolbarCommands.All` with a unique key, label, 24x24 SVG path, actual destination, context requirements, section and default membership. Registry order determines default order.
The modal uses native drag/drop and named up/down buttons, with no new JavaScript dependencies. It updates the current toolbar only after a successful save, keeps errors in the dialog and prevents closing during the save. Unavailable commands can still be configured for use when the relevant project/book context becomes available.
## Four-theme architecture
## Active feature and book changes
`ApplicationAppearance.Themes` is the source for the four named choices:
The existing `ApplicationNavigationViewModel.ActiveSection` identifies whole features across actions. Registry matching uses it rather than matching URL substrings. Review Centre additionally recognises the Onboarding Story Intelligence action family; ordinary onboarding setup does not activate it. Projects uses the Projects/Index destination explicitly.
| UI label | Stored identifier | Character |
| --- | --- | --- |
| Modern Light | `modern-light` | Neutral white/light grey, charcoal text, restrained copper accent. |
| Modern Dark | `modern-dark` | Neutral charcoal, differentiated dark surfaces, amber accent. |
| Warm Light | `warm-light` | Existing parchment/editorial character. |
| Warm Dark | `warm-dark` | Existing brown-black surfaces and warm text. |
`application-navigation.js` already observes Calendar/At This Point partial replacements. The same hook updates Review Centre's book URL using only a book present in the authorised menu choices, or disables the shortcut when the page shows all books. Project switching continues through the existing project menu.
`application-shell.css` defines one component system. Themes primarily override semantic `--pd-*` tokens: workspace, surface, secondary/elevated surface, chrome/secondary chrome, borders, text/muted/heading, accent/hover, focus, status colours and functional icon colours. UI typography uses the existing Segoe/system sans-serif family; literary headings retain the shared serif family. Functional icon tones (books, planning, calendar, characters, locations, relationships, review and warning) are shared between Quick Access, ribbon and statistics.
## Validation
`html[data-app-theme]` selects the application theme. `data-theme` and Bootstrap `data-bs-theme` remain `light`/`dark` for compatibility with existing pages. Scoped token aliases bridge the existing `--plotline-*`, `--app-*` and Bootstrap variables. The legacy binary theme script exits only when an application theme is active; public pages retain their original script and browser-local preference. Update tokens rather than copying component rules to add/change palette values.
Migration **202_UserApplicationAppearance.sql** adds nullable `AppUser.ApplicationThemeKey` and `RibbonCollapsed` (default false), plus `UserAppearance_Get`, `UserAppearance_SaveTheme` and `UserAppearance_SaveRibbon`. `AppearanceRepository` uses only stored procedures. Appearance belongs to the account and is removed with account deletion; Quick Access JSON is never modified by appearance changes. Apply migration 202 before deploying this shell.
The layout reads the account preference and applies it before CSS paints. When no account choice exists, the existing `plotline.theme` browser value maps `dark` → Warm Dark and `light`/unset → Warm Light (preserving the prior default). The client then saves that choice with `OnlyIfUnset`, so a legacy browser cannot overwrite an explicit account choice made elsewhere. No old browser preference is deleted or overwritten. All later explicit changes persist to SQL, apply immediately without navigation, and survive browser sessions. Authentication, antiforgery and allowlisted identifiers protect writes. Failures revert the visible theme and show an error in the appearance picker. Concurrent explicit saves are last-save-wins.
The ribbon collapse control persists independently per user. Selecting a category while collapsed temporarily reveals its commands; the saved collapsed state returns on the next page. Explicit Expand changes the saved preference. Failure restores the prior state.
## Reference Dashboard and responsive behaviour
`Projects/Details` uses a `pd-dashboard` wrapper and a wide `pd-dashboard-shell` container. All counts, actions, warnings, progress calculations and book data are unchanged. A nine-stat band adds functional icons, preserves labels and uses subtle separators instead of individual bordered cards. The reference components use restrained surfaces, modest corner radii, small status badges, clear project actions, lighter progress treatment, serif book/project headings, and consistent Recent Activity/Worth a Look presentation. Other feature pages are not independently redesigned.
On smaller screens, title/context rows adapt, Quick Access scrolls horizontally, category tabs scroll and each ribbon panel keeps its command groups on a horizontally scrollable row. No command is removed for screen size. Dashboard statistics reduce to five/three columns. Focus outlines, ARIA-selected/expanded/current states, labelled icon controls and keyboard reorder alternatives are retained. Reduced-motion preferences disable transitions/animation in application scope.
## Verification
- `dotnet build PlotLine.slnx`
- `dotnet run --project PlotLine.Tests/PlotLine.Tests.csproj`
- In one terminal at the repository root: `dotnet run --project PlotLine.Tests -- --toolbar-browser-host`
- In `PlotLine.Tests/Browser`: `npm run test:toolbar`
- Start the isolated host from the repository root: `dotnet run --project PlotLine.Tests -- --toolbar-browser-host`
- In `PlotLine.Tests/Browser`, run `npm run test:toolbar`.
The loopback-only browser host renders the real compiled navigation, toolbar, modal and Calendar surface with isolated fixtures and an in-memory preference repository. It starts no application workers and accesses no live database. Tests cover menu links/project switching, active Calendar, authorised project/book links and asynchronous book changes, show/hide, keyboard/native-drag ordering, cancel/reset, fresh browser sessions and independent identities, CSRF rejection, no-project pages, desktop/mobile and dark theme. Screenshots go to `/tmp`, never the repository. It does not replace a live authenticated smoke test after deployment.
The loopback fixture host renders the real compiled shell, editor, Calendar surface and Series Dashboard with in-memory preferences. It starts no application workers and accesses no live database. Browser coverage includes existing Quick Access behaviour, save failures/empty configuration, independent users/sessions, project/book links, asynchronous book changes, CSRF, category switching/keyboard access, collapse persistence, four themes, Dashboard values and narrow layouts. Screenshots go to `/tmp` and are not committed. Migration 202 is also tested twice in a disposable database, including preservation of Quick Access and explicit themes; the database is removed afterwards.
SQL was separately checked in a disposable verification database: migration applied twice, SQL NULL defaults, ordered/empty preferences, independent user records, retrieval through a fresh repository and restoring defaults. The disposable database was dropped after verification; shared databases were unchanged.
Phase 2: migrate individual feature-page components systematically to the new tokens after visual approval. Existing legacy feature-specific CSS remains intentionally outside this reference-page refresh. Audit the pre-existing Pkcs dependency advisories separately from visual work.