PlotDirector/PlotLine/Services/RibbonPresentation.cs

133 lines
11 KiB
C#

namespace PlotLine.Services;
public sealed record RibbonIcon(string Key, string IconPath, string Tone, bool Filled = false);
// Presentation metadata only. Routes, permissions and command execution stay with their owners.
public static class RibbonPresentation
{
public static string Operation(string controller, string action) => $"{controller}.{action}".ToLowerInvariant();
public static string? IconFor(string operation, string? format = null)
{
operation = operation.ToLowerInvariant(); format = format?.ToLowerInvariant();
if (operation.StartsWith("exports."))
{
if (format == "markdown") return "markdown";
if (format == "text") return "text-export";
return operation switch {
"exports.storybible" => "print", "exports.narrativetimeline" => "timeline-export",
"exports.researchpack" => "research", "exports.projectbackup" => "backup",
"exports.writingsession" => "session", _ => "export"
};
}
if (operation == "bookrecovery.backup") return "backup";
if (operation == "bookrecovery.restore") return "restore";
if (operation == "maps.index") return "maps";
if (operation == "floorplans.index") return "floorplans";
if (operation == "timeline.settings" || operation is "manageaccount.index" or "manageaccount.subscription") return "settings";
if (operation == "plotlines.index") return "list";
if (operation == "acceptance.phase1") return "validate";
if (operation == "imports.sample") return "export";
if (operation == "dynamics.knowledge") return "knowledge";
if (operation == "dynamics.character") return "metrics";
if (operation == "dynamics.story") return "health";
if (operation.StartsWith("warnings.validate") || operation == "dynamics.runchecks") return "validate";
if (operation == "projectrestorepoints.index") return "restore";
var action = operation.Split('.').Last();
if (action.StartsWith("reanalyse") || action.StartsWith("retry") || action.StartsWith("regenerate")) return "refresh";
if (action == "save") return "save";
if (action == "edit") return "writer";
if (action.StartsWith("merge")) return "merge";
if (action.StartsWith("delete") || action.StartsWith("remove")) return "remove";
if (action.StartsWith("restore")) return "restore";
if (action.StartsWith("archive")) return "archive";
if (action == "create" && operation is not ("books.create" or "chapters.create")) return "add";
if (action.StartsWith("schedule") || action == "writingplans") return "calendar";
return null;
}
public static IReadOnlyList<RibbonIcon> AdditionalIcons { get; } = [
new("location-globe", "M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0 M2 12h20 M12 2c-6 6-6 14 0 20 6-6 6-14 0-20", "world"),
new("location-city", "M3 22V8h8v14 M11 22V2h10v20 M6 11h2 M6 15h2 M14 6h4 M14 10h4 M14 14h4 M14 18h4", "world"),
new("location-shop", "M3 10h18 M5 10v11h14V10 M2 10l3-7h14l3 7 M9 21v-7h6v7", "world"),
new("location-coffee", "M4 3h12v12a5 5 0 0 1-10 0V3 M16 5h3a3 3 0 0 1 0 6h-3 M2 22h19", "world"),
new("location-institution", "M2 8L12 2l10 6H2 M4 21h16 M6 10v8 M12 10v8 M18 10v8", "world"),
new("location-medical", "M3 22V7h18v15 M8 2v10 M3 7h10 M9 22v-7h6v7", "world"),
new("location-castle", "M3 22V3h4v4h3V3h4v4h3V3h4v19H3 M9 22v-7h6v7", "world"),
new("location-water", "M2 17q3-3 6 0t6 0t8 0 M2 22q3-3 6 0t6 0t8 0 M5 12l7-10 7 10H5", "world"),
new("location-rail", "M5 18V5q0-3 7-3t7 3v13H5 M5 10h14 M8 14h1 M15 14h1 M8 18l-3 4 M16 18l3 4", "world"),
new("location-plane", "M22 2L9 9 2 7l-1 3 6 4 4 9 3-1-1-7 9-13Z", "world"),
new("location-house", "M2 11L12 2l10 9 M5 9v13h14V9 M10 22v-8h4v8", "world"),
new("location-door", "M4 22h16 M6 22V2h12v20 M14 12h1", "world"),
new("location-tree", "M12 2l-6 8h3l-6 8h7v4h4v-4h7l-6-8h3z", "world"),
new("location-vehicle", "M4 17V8l2-5h12l2 5v9z M4 9h16 M7 13h1 M16 13h1 M6 17v4 M18 17v4", "world"),
new("location-street", "M12 2v20 M3 5h17l3 4-3 4H3z", "world"),
new("location-level", "M2 7l10-5 10 5-10 5z M2 12l10 5 10-5 M2 17l10 5 10-5", "world"),
new("location-mountain", "M2 21L10 3l5 10 3-5 5 13z M7 10l3 2 3-2", "world"),
new("name-available", "M22 12a10 10 0 1 1-5-8 M7 11l4 4 11-12", "characters"),
new("name-alias", "M3 3h18v18H3z M9 7a3 3 0 1 0 0 6 3 3 0 0 0 0-6 M5 19v-2a4 4 0 0 1 8 0v2 M16 8h3 M16 12h3 M16 16h3", "characters"),
new("attribute-paw", "M8 15c-5 3-2 8 1 6l3-1 3 1c3 2 6-3 1-6l-4-3z M6 5a2 3 0 1 0 0 6 2 3 0 0 0 0-6 M11 2a2 3 0 1 0 0 6 2 3 0 0 0 0-6 M17 3a2 3 0 1 0 0 6 2 3 0 0 0 0-6 M21 8a2 3 0 1 0 0 6 2 3 0 0 0 0-6", "characters"),
new("attribute-sparkles", "M12 2l3 7 7 3-7 3-3 7-3-7-7-3 7-3z M21 2v4 M19 4h4 M3 19v4 M1 21h4", "characters"),
new("attribute-robot", "M4 7h16v14H4z M12 3v4 M10 3h4 M8 11h1 M15 11h1 M8 17h8 M1 11v6 M23 11v6", "characters"),
new("attribute-star", "M12 2l3 6 7 1-5 5 1 7-6-3-6 3 1-7-5-5 7-1z", "characters"),
new("attribute-star-filled", "M12 2l3 6 7 1-5 5 1 7-6-3-6 3 1-7-5-5 7-1z", "characters", true),
new("attribute-star-half", "M12 2l3 6 7 1-5 5 1 7-6-3-6 3 1-7-5-5 7-1z M12.7 5.4l1.3 4 5 .8-3.7 3.5.8 4.6-3.4-1.7z", "characters", true),
new("sex-male", "M15 15a6 6 0 1 0-12 0 6 6 0 0 0 12 0 M13 11l8-8 M15 3h6v6", "characters"),
new("sex-female", "M17 7a5 5 0 1 0-10 0 5 5 0 0 0 10 0 M12 12v10 M8 18h8", "characters"),
new("sex-other", "M14 10a5 5 0 1 0-10 0 5 5 0 0 0 10 0 M9 15v7 M5 19h8 M12.5 6.5L21 2 M16 2h5v5", "characters"),
new("attribute-person", "M16 6a4 4 0 1 0-8 0 4 4 0 0 0 8 0 M4 22v-3a8 8 0 0 1 16 0v3z", "characters"),
new("attribute-heart", "M12 21L3 12C-3 4 7-1 12 6c5-7 15-2 9 6z", "characters"),
new("attribute-flower", "M12 22v-8 M12 19l6-3 M12 5c-6-9-10 2-5 4-8 3 0 10 5 5 5 5 13-2 5-5 5-2 1-13-5-4z", "characters"),
new("attribute-pin", "M8 3h8l-1 7 4 4H5l4-4z M12 14v8", "characters"),
new("attribute-unpin", "M8 3h8l-1 7 4 4H9 M12 14v8 M3 3l18 18", "characters"),
new("chevron-left", "M15 4l-8 8 8 8", "planning"),
new("chevron-right", "M9 4l8 8-8 8", "planning"),
new("minimise", "M3 9h6V3 M21 9h-6V3 M3 15h6v6 M21 15h-6v6", "planning"),
new("headphones", "M4 14v-3a8 8 0 0 1 16 0v3 M4 12H2v8h5v-8z M20 12h2v8h-5v-8z", "review"),
new("comment-add", "M21 14V3H3v14h5l4 4v-4h9z M8 10h8 M12 6v8", "review"),
new("pause-circle", "M21 12a9 9 0 1 0-18 0 9 9 0 0 0 18 0 M9 8v8 M15 8v8", "review"),
new("play-circle", "M21 12a9 9 0 1 0-18 0 9 9 0 0 0 18 0 M10 7l7 5-7 5z", "review"),
new("back", "M19 12H5m7-7-7 7 7 7", "planning"),
new("undo", "M9 4L3 10l6 6 M3 10h10a7 7 0 0 1 7 7v3", "planning"),
new("redo", "M15 4l6 6-6 6 M21 10H11a7 7 0 0 0-7 7v3", "planning"),
new("previous", "M15 4l-8 8 8 8 M4 4v16", "calendar"),
new("next", "M9 4l8 8-8 8 M20 4v16", "calendar"),
new("restore-workspace", "M8 3h13v13 M3 8h13v13H3z", "planning"),
new("separate-window", "M14 3h7v7 M21 3l-9 9 M10 5H3v16h16v-7", "planning"),
new("lock", "M6 11V7a6 6 0 0 1 12 0v4 M4 11h16v10H4z M12 15v3", "planning"),
new("unlock", "M6 11V7a6 6 0 0 1 12 0 M4 11h16v10H4z M12 15v3", "planning"),
new("map", "M3 5l6-2 6 2 6-2v16l-6 2-6-2-6 2z M9 3v16 M15 5v16", "relationships"),
new("focus", "M12 2v4 M12 18v4 M2 12h4 M18 12h4 M19 12a7 7 0 1 0-14 0 7 7 0 0 0 14 0 M14 12a2 2 0 1 0-4 0 2 2 0 0 0 4 0", "relationships"),
new("details", "M4 3h16v18H4z M8 7h8 M8 11h8 M8 15h5", "books"),
new("auto-arrange", "M3 3h6v6H3z M15 3h6v6h-6z M3 15h6v6H3z M15 15h6v6h-6z M11 6h2 M6 11v2 M18 11v2 M11 18h2", "planning"),
new("layout", "M3 3h18v18H3z M3 8h18 M8 8v13 M16 8v13", "planning"),
new("display", "M3 4h18v14H3z M8 22h8 M12 18v4", "planning"),
new("maximise", "M9 3H3v6 M15 3h6v6 M3 15v6h6 M21 15v6h-6", "planning"),
new("hide-node", "M5 5h14v14H5z M9 12h6 M2 12h3 M19 12h3", "relationships"),
new("save", "M4 3h13l4 4v14H3V3z M7 3v6h10V3 M7 21v-7h10v7", "planning"),
new("close", "M5 5l14 14 M19 5L5 19", "planning"),
new("cut", "M4 3l16 18 M20 3L9 14 M8 17a3 3 0 1 0-6 0 3 3 0 0 0 6 0 M22 17a3 3 0 1 0-6 0 3 3 0 0 0 6 0", "planning"),
new("copy", "M8 8h13v13H8z M3 16V3h13", "planning"),
new("paste", "M8 5H4v16h16V5h-4 M8 3h8v5H8z M8 12h8 M8 16h6", "planning"),
new("select-all", "M3 8V3h5 M16 3h5v5 M21 16v5h-5 M8 21H3v-5 M7 7h10v10H7z", "planning"),
new("search", "M20 20l-5-5 M17 10a7 7 0 1 0-14 0 7 7 0 0 0 14 0", "planning"),
new("help", "M21 12a9 9 0 1 0-18 0 9 9 0 0 0 18 0 M9.5 9a2.5 2.5 0 0 1 5 0c0 2-2.5 2-2.5 4 M12 17v.01", "books"),
new("print", "M6 8V3h12v5 M6 17H3V8h18v9h-3 M6 14h12v7H6z M17 11h1", "planning"),
new("markdown", "M4 3h11l5 5v13H4z M15 3v6h5 M7 13l-2 2 2 2 M16 13l2 2-2 2 M12 12l-2 6", "planning"),
new("text-export", "M5 3h10l5 5v13H5z M15 3v6h5 M8 12h9 M8 15h9 M8 18h6", "books"),
new("timeline-export", "M3 5h14 M3 10h14 M3 15h7 M7 3v4 M12 8v4 M17 13v8 M13 17l4 4 4-4", "calendar"),
new("research", "M3 6l8-3 8 3v8 M3 6v12l8 3 M3 6l8 4 8-4 M11 10v6 M22 22l-4-4 M20 16a4 4 0 1 0-8 0 4 4 0 0 0 8 0", "locations"),
new("export", "M4 3h10v7 M4 3v18h13v-7 M10 14L21 3 M15 3h6v6", "planning"),
new("backup", "M4 3h16v18H4z M8 3v6h8V3 M8 21v-7h8v7", "planning"),
new("restore", "M4 8a9 9 0 1 1-1 7 M4 3v5h5 M12 7v6l4 2", "calendar"),
new("settings", "M10 3h4l.6 3 2 .9 2.6-1.3 2 3.4-2.3 1.8v2.4l2.3 1.8-2 3.4-2.6-1.3-2 .9-.6 3h-4l-.6-3-2-.9-2.6 1.3-2-3.4L5 13.2v-2.4L2.7 9l2-3.4 2.6 1.3 2-.9z M15 12a3 3 0 1 0-6 0 3 3 0 0 0 6 0", "planning"),
new("validate", "M4 3h13v18H4z M8 12l3 3 9-9 M8 6h5", "review"),
new("refresh", "M20 9a8 8 0 0 0-14-4 L3 8 M3 3v5h5 M4 15a8 8 0 0 0 14 4l3-3 M16 16h5v5", "review"),
new("merge", "M4 3v4l8 7 M20 3v4l-8 7v7 M8 17l4 4 4-4", "relationships"),
new("remove", "M3 6h18 M9 6V3h6v3 M5 6l1 15h12l1-15 M10 10v7 M14 10v7", "warning"),
new("add", "M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18 M12 7v10 M7 12h10", "planning"),
new("list", "M8 5h13 M8 12h13 M8 19h13 M3 5h.01 M3 12h.01 M3 19h.01", "planning"),
new("knowledge", "M9 18h6 M10 21h4 M8 14a7 7 0 1 1 8 0l-1 4H9z", "review"),
new("session", "M3 4h12v16H3z M7 8h4 M7 12h4 M17 10l4 3-4 3z", "review")
];
public static IEnumerable<RibbonIcon> Icons => ToolbarCommands.All.Select(command => new RibbonIcon(command.Key, command.IconPath, ApplicationRibbon.Tone(command.Key))).Concat(AdditionalIcons);
}