diff --git a/frontend/administration.js b/frontend/administration.js index 80024df1..2cc8364b 100644 --- a/frontend/administration.js +++ b/frontend/administration.js @@ -275,15 +275,15 @@ function ComponentCard({ record, revision }) { const help = !ui.getSnapshot().snapshot.apply_enabled ? "On-demand installation is disabled for this deployment." : record.component === "webui" ? !ui.getSnapshot().snapshot.webui_storage_configured ? "Configure WebUI Storage to enable installation." : "" : !observed?.self_update_enabled ? "Self-update is not enabled or the running component could not be verified." : ""; - return h(Paper, { component: "section", withBorder: true, className: "administration-card" }, - h("div", { className: "card-body" }, + return h(Paper, { component: "section", withBorder: true, className: "sf-card administration-card" }, + h("div", { className: "sf-card-body" }, h("div", { className: "administration-card-heading" }, - h("div", null, h("h2", { className: "card-title" }, record.component.toUpperCase()), + h("div", null, h("h2", { className: "sf-card-title" }, record.component.toUpperCase()), h("p", { className: "muted" }, { api: "Dashboard service", bot: "Discord moderation", webui: "Browser workspace" }[record.component])), ...heading), h("div", { className: "administration-info" }, content), h("details", { className: "administration-technical" }, h("summary", null, "Version & technical details"), h("div", null, details)), h("p", { className: "muted administration-help", hidden: !help }, help), - h("div", { className: "card-actions administration-actions" }, + h("div", { className: "sf-card-actions administration-actions" }, action("Check now", record.component, item => request("/api/updates/check", { component: item.component }), { disabled: (ui.getSnapshot().activity === "busy") || (ui.getSnapshot().freshness === "stale") }), action(record.component === "webui" ? "Update WebUI" : "Update", record.component, item => request("/api/updates/install", { component: item.component, digest: item.candidate.digest }), @@ -322,15 +322,15 @@ function AlertChannelCard({ revision }) { const [value, setValue] = useState(saved); useEffect(() => { setValue(saved); }, [saved, revision]); const blocked = (ui.getSnapshot().activity === "busy") || (ui.getSnapshot().freshness === "stale"); - return h("section", { id: "alert-channel", className: "card bg-base-100 administration-card" }, - h("div", { className: "card-body" }, - h("h2", { className: "card-title" }, "Boot repair alerts"), + return h(Paper, { component: "section", withBorder: true, id: "alert-channel", className: "sf-card administration-card" }, + h("div", { className: "sf-card-body" }, + h("h2", { className: "sf-card-title" }, "Boot repair alerts"), h("p", { className: "muted" }, "The bot posts here once when boot repair can't restore the recorded bot or API release."), !saved && h("p", { id: "alert-channel-unset", className: "muted" }, "No alert channel is set. Mismatches are logged and shown on the component cards."), h("label", { className: "fieldset field" }, h("span", { className: "fieldset-legend" }, "Alert channel ID"), h(TextInput, noAutofill({ id: "alert-channel-id", size: "sm", inputMode: "numeric", value, disabled: blocked, onChange: event => setValue(event.target.value) }))), - h("div", { className: "card-actions" }, + h("div", { className: "sf-card-actions" }, h(Button, { id: "save-alert-channel", type: "button", size: "sm", variant: "default", disabled: blocked || value.trim() === saved, onClick: () => mutate({ component: "alerts" }, "Save alert channel", () => request("/api/updates/alert-channel", { channel_id: value.trim() })) }, "Save alert channel")))); @@ -375,9 +375,9 @@ function AdministrationView({ appearance }) { document.addEventListener("visibilitychange", visible); return () => { document.removeEventListener("visibilitychange", visible); clearTimeout(refreshTimer); }; }, []); - if (display.access === "denied" && display.signIn !== "required") return h(Paper, { component: "section", className: "card bg-base-100 card-border" }, - h("div", { className: "card-body" }, - h("h1", { className: "card-title" }, "Owner access required"), + if (display.access === "denied" && display.signIn !== "required") return h(Paper, { component: "section", withBorder: true, className: "sf-card" }, + h("div", { className: "sf-card-body" }, + h("h1", { className: "sf-card-title" }, "Owner access required"), h("p", null, "Administration is available only to the configured bot owner."), h("a", { href: workspaceHref }, "Back to workspace"), ), diff --git a/frontend/app.js b/frontend/app.js index 9131af89..85d8e9b4 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -61,8 +61,11 @@ function Field({ children, ...props }) { function Label(props) { return h("label", { htmlFor: useContext(FieldId), ...props }); } +function SentinelCard({ className = "", withBorder = true, ...props }) { + return h(Paper, { withBorder, ...props, className: className ? `sf-card ${className}` : "sf-card" }); +} function DraftCard({ group, children, ...props }) { - return h(DraftGroup.Provider, { value: group }, h(Paper, props, children)); + return h(DraftGroup.Provider, { value: group }, h(SentinelCard, props, children)); } function ActionButton({ onClick, savedFields, disabled, component = Button, ...props }) { const working = useContext(BusyContext); @@ -875,8 +878,8 @@ function TabSystemLogChannels() { h("p", null, "Old per-server mappings need approval before delivery resumes. Old global mappings cannot receive system logs."), result.loading && h("p", { role: "status" }, "Loading system log destinations…"), result.error && h("p", { role: "alert" }, result.error.message), - result.data && h(Paper, { className: "card bg-base-100 card-border", "data-no-draft": true }, - h("div", { className: "card-body" }, + result.data && h(SentinelCard, { "data-no-draft": true }, + h("div", { className: "sf-card-body" }, enrolled.length ? h("label", null, "Server", h(FieldSelect, { value: selected?.guild_id || "", onChange: (event) => setGuildId(event.target.value) }, @@ -970,8 +973,8 @@ function TabServerEnrollment() { }; return h( - Paper, { component: "section", className: "card bg-base-100 card-border" }, - h("div", { className: "card-body" }, + SentinelCard, { component: "section" }, + h("div", { className: "sf-card-body" }, h("h2", null, "Your servers"), state.me?.role_scope_missing && h("p", { role: "status" }, "Sign out and sign in again so jModGuard can check your server roles."), @@ -1404,11 +1407,11 @@ function UsageCard({ database: initial, stale, revision }) { } }; return h( - Paper, - { component: "section", className: "card bg-base-100 card-border du-card", "aria-labelledby": headingId, "data-usage-stale": oldSample ? "1" : undefined }, + SentinelCard, + { component: "section", className: "du-card", "aria-labelledby": headingId, "data-usage-stale": oldSample ? "1" : undefined }, h( "div", - { className: "card-body" }, + { className: "sf-card-body" }, h( "header", { className: "du-head" }, @@ -1745,7 +1748,7 @@ function PlatformServerTable({ rows, totals, rangeLabel }) { ), h( "div", - { className: "table-scroll rounded-box", tabIndex: 0, role: "region", "aria-label": "Servers" }, + { className: "table-scroll", tabIndex: 0, role: "region", "aria-label": "Servers" }, h( Table, { className: "pa-table" }, @@ -2230,11 +2233,11 @@ function ResourceCard({ id, title, process, generatedAtMs, nowMs, range, chartFr ], }), [points, title, chartFrom, chartTo, memoryLimit]); return h( - Paper, - { component: "section", className: "card bg-base-100 card-border du-card br-card", "aria-labelledby": headingId, "data-freshness": freshness }, + SentinelCard, + { component: "section", className: "du-card br-card", "aria-labelledby": headingId, "data-freshness": freshness }, h( "div", - { className: "card-body" }, + { className: "sf-card-body" }, h( "header", { className: "du-head" }, @@ -2369,7 +2372,7 @@ function BunnyCostHistory({ history, services, configured }) { h("h4", { id: "resources-bunny-history", className: "du-metric-label" }, "Past months (UTC)"), rows.length === 0 ? h("p", { className: "an-note muted" }, "No saved months yet.") - : h("div", { className: "table-scroll rounded-box", tabIndex: 0, role: "region", "aria-labelledby": "resources-bunny-history" }, + : h("div", { className: "table-scroll", tabIndex: 0, role: "region", "aria-labelledby": "resources-bunny-history" }, h(Table, null, h(Table.Thead, null, h(Table.Tr, null, ...["Month", "Subtotal of known estimates", ...services.map(([, label]) => label)].map((label) => @@ -2479,7 +2482,7 @@ function BunnyCostPanel({ provider }) { h("p", { className: "an-note muted" }, `${provider.month} (UTC). Bunny’s monthly figure is the authoritative Magic Containers projection. Partial estimates cover CPU, RAM, egress, and allocated volumes when available.`, ), - h("div", { className: "table-scroll rounded-box", tabIndex: 0, role: "region", "aria-label": "Current Bunny costs" }, + h("div", { className: "table-scroll", tabIndex: 0, role: "region", "aria-label": "Current Bunny costs" }, h(Table, null, h(Table.Thead, null, h(Table.Tr, null, ...["Service", "Projected month (USD)", "Month-to-date estimate (USD)", "Last updated"].map((label) => @@ -2667,7 +2670,7 @@ function BotResources() { panelBody(() => [ h( "div", - { key: "table", className: "table-scroll rounded-box", tabIndex: 0, role: "region", "aria-label": "Cost drivers per minute" }, + { key: "table", className: "table-scroll", tabIndex: 0, role: "region", "aria-label": "Cost drivers per minute" }, h( Table, { className: "br-costs" }, @@ -3077,7 +3080,7 @@ function Workspace({ appearance }) { { className: "workspace" }, h( "header", - { ref: navigationRefs.header, className: "navbar bg-base-100 workspace-header sf-hub-bar" }, + { ref: navigationRefs.header, className: "workspace-header sf-hub-bar" }, h( "div", { className: "sf-hub-left" }, @@ -3192,11 +3195,11 @@ function Workspace({ appearance }) { { id: display.view, className: "welcome-view" }, h(Appearance, appearance), h( - "div", - { className: "login-card card bg-base-100" }, + SentinelCard, + { className: "login-card" }, h( "div", - { className: "card-body" }, + { className: "sf-card-body" }, h("span", { className: "brand-mark", "aria-hidden": true }, "jG"), h( "p", @@ -4856,14 +4859,11 @@ async function reloadAfter(work, onSuccess, capturedGuild) { } function emptyPanel(title, body, action, attrs) { + const { className, ...rest } = attrs || {}; return h( - Paper, - { className: "hero bg-base-200 rounded-box", ...(attrs || {}) }, - h( - "div", - { className: "hero-content" }, - h("div", { className: "hero-copy" }, h("h2", {}, title), h("p", {}, body), action || null), - ), + SentinelCard, + { className: className ? `sf-empty-panel ${className}` : "sf-empty-panel", ...rest }, + h("div", { className: "sf-empty-panel-copy" }, h("h2", {}, title), h("p", {}, body), action || null), ); } @@ -4879,7 +4879,7 @@ function eventHeading(event) { return h( "div", { className: "event-heading" }, - h("h3", { className: "card-title" }, eventLabel(event)), + h("h3", { className: "sf-card-title" }, eventLabel(event)), h("code", { className: "muted" }, event), ); } @@ -5023,8 +5023,8 @@ function DashboardTelemetryBento({ guildId }) { const failed = Boolean(analytics.error) && !data; const points = React.useMemo(() => toTrendPoints(data?.series), [data?.series]); return h( - Paper, - { component: "section", withBorder: true, className: "card bg-base-100 sf-card sf-bento-card analytics-page", "aria-labelledby": "cc-telemetry-title" }, + SentinelCard, + { component: "section", className: "sf-bento-card analytics-page", "aria-labelledby": "cc-telemetry-title" }, h( "div", { className: "sf-bento-head" }, @@ -5053,8 +5053,8 @@ function ActiveShieldsCard({ rules }) { const liveCount = visible.filter((r) => quickRuleState(r) === "on").length; const editable = canEditSettings() && !isPreview(); return h( - Paper, - { component: "section", withBorder: true, className: "card bg-base-100 sf-card sf-bento-card", "aria-labelledby": "cc-shields-title" }, + SentinelCard, + { component: "section", className: "sf-bento-card", "aria-labelledby": "cc-shields-title" }, h( "div", { className: "sf-bento-head" }, @@ -5174,8 +5174,8 @@ function OwnerInfraStrip({ guildId }) { const shardMs = botCurrent?.gauges?.shard_latency_ms; const anyStale = !loading && (dbStale || botFreshness === "stale"); return h( - Paper, - { component: "section", withBorder: true, className: "card bg-base-100 sf-card sf-bento-card sf-infra", "aria-labelledby": "cc-infra-title" }, + SentinelCard, + { component: "section", className: "sf-bento-card sf-infra", "aria-labelledby": "cc-infra-title" }, h( "div", { className: "sf-bento-head" }, @@ -5263,12 +5263,12 @@ function tabDashboard() { ), setupLinks.length > 0 && !setupComplete(cfg) && h( - Paper, - { component: "section", className: "card bg-base-100 card-border getting-started" }, + SentinelCard, + { component: "section", className: "getting-started" }, h( "div", - { className: "card-body" }, - h("h3", { className: "card-title" }, "Getting started"), + { className: "sf-card-body" }, + h("h3", { className: "sf-card-title" }, "Getting started"), h( "div", { className: "setup-links" }, @@ -5296,13 +5296,13 @@ function tabDashboard() { h( "div", { className: "row dashboard-overview-head" }, - h("h3", { className: "card-title", id: "dashboard-overview" }, "Overview"), + h("h3", { className: "sf-card-title", id: "dashboard-overview" }, "Overview"), h(LastUpdated, { result }), h(ActionButton, { id: "refresh-dashboard", size: "sm", onClick: () => result.refresh() }, "Refresh"), ), h( Paper, - { className: "stats bg-base-100 w-full dashboard-stats" }, + { withBorder: true, className: "stats w-full dashboard-stats" }, // One row each for protection, moderation activity and server configuration. stat("Rules enabled", `${rulesOn} / ${rules.length}`, "rules-enabled"), stat("Rules in dry-run", rulesDry, "rules-dry-run"), @@ -5781,8 +5781,8 @@ function RuleWorkbenchInspector({ record }) { ["Exemptions", glob ? summarizeRuleExemptions(glob) : "—", summarizeRuleExemptions(eff), glob != null && !canonicalEqual(canonicalRuleExemptions(glob), canonicalRuleExemptions(eff))], ]; return h( - Paper, - { component: "section", withBorder: true, className: "card bg-base-100 sf-card sf-wb-inspector", "aria-labelledby": "sf-rule-inspector-title" }, + SentinelCard, + { component: "section", className: "sf-wb-inspector", "aria-labelledby": "sf-rule-inspector-title" }, h( "div", { className: "sf-bento-head" }, @@ -6088,7 +6088,7 @@ function ruleCard(r, options = {}) { { className: "rule-heading" }, h( "h3", - { className: "card-title" }, + { className: "sf-card-title" }, options.onSelect ? h( UnstyledButton, @@ -6122,7 +6122,7 @@ function ruleCard(r, options = {}) { ), h( "div", - { className: "card-actions" }, + { className: "sf-card-actions" }, canEditSettings() && h(IconButton, { action: "edit", label: "Edit", onClick: () => editRule(r) }), ), ), @@ -6378,7 +6378,7 @@ function RuleEditorHeader({ title, enabled, dryRun, dryRunDisabled, enabledDisab return h( "div", { className: "editor-heading rule-editor-header" }, - h("div", { className: "rule-editor-title" }, h("span", { className: "eyebrow" }, "AUTOMOD RULE"), h("h3", { className: "card-title" }, title)), + h("div", { className: "rule-editor-title" }, h("span", { className: "eyebrow" }, "AUTOMOD RULE"), h("h3", { className: "sf-card-title" }, title)), h( "div", { className: "rule-toggles" }, @@ -7612,11 +7612,11 @@ function RuleStatusCard({ record, trigger }) { } }, null); return h( - Paper, - { component: "section", className: "card bg-base-100 card-border list-card list-status", "aria-label": "Rule status", "data-no-draft": true }, + SentinelCard, + { component: "section", className: "list-card list-status", "aria-label": "Rule status", "data-no-draft": true }, h( "div", - { className: "card-body" }, + { className: "sf-card-body" }, canEditSettings() ? h(RuleEditorHeader, { key: attempt, @@ -7627,7 +7627,7 @@ function RuleStatusCard({ record, trigger }) { onEnabled: toggle("enabled"), onDryRun: toggle("dry_run"), }) - : h("h3", { className: "card-title" }, record.name), + : h("h3", { className: "sf-card-title" }, record.name), h(RuleSummary, { text: inactive ? `${record.name} is inactive. Open it to convert it.` @@ -7649,9 +7649,9 @@ function RuleStatusCard({ record, trigger }) { function ListCard({ title, children, className = "" }) { return h( - Paper, - { component: "section", className: `card bg-base-100 card-border list-card ${className}`.trim(), "aria-label": title }, - h("div", { className: "card-body" }, h("h3", { className: "card-title" }, title), children), + SentinelCard, + { component: "section", className: `list-card ${className}`.trim(), "aria-label": title }, + h("div", { className: "sf-card-body" }, h("h3", { className: "sf-card-title" }, title), children), ); } @@ -7780,11 +7780,11 @@ function tabBadwords() { h(RuleStatusCard, { record: badwordsRule(), trigger: RULE_TRIGGERS.badword.phrase() }), canEditSettings() && h( DraftCard, - { group: "badwords", className: "card bg-base-100 card-border list-card list-add" }, + { group: "badwords", className: "list-card list-add" }, h( "div", - { className: "card-body" }, - h("h3", { className: "card-title" }, "Add words"), + { className: "sf-card-body" }, + h("h3", { className: "sf-card-title" }, "Add words"), h( "div", { className: "list-form-row" }, @@ -7905,23 +7905,22 @@ function tabBadwords() { }), canEditSettings() && h( DraftCard, - { group: "badwords-test" }, - h( - "details", - { - className: "card bg-base-100 card-border list-card list-extra", - // Open stays open after the remount each save makes; it resets on leaving the page. - open: testerOpen, - onToggle: (event) => { - const open = event.currentTarget.open; - if (open !== Boolean(ui.getSnapshot().draftBaselines["badwords:tester-open"])) - ui.set({ draftBaselines: { ...ui.getSnapshot().draftBaselines, "badwords:tester-open": open } }); - }, + { + group: "badwords-test", + component: "details", + className: "list-card list-extra", + // Open stays open after the remount each save makes; it resets on leaving the page. + open: testerOpen, + onToggle: (event) => { + const open = event.currentTarget.open; + if (open !== Boolean(ui.getSnapshot().draftBaselines["badwords:tester-open"])) + ui.set({ draftBaselines: { ...ui.getSnapshot().draftBaselines, "badwords:tester-open": open } }); }, - h("summary", null, "Live tester"), - h( - "div", - { className: "card-body" }, + }, + h("summary", null, "Live tester"), + h( + "div", + { className: "sf-card-body" }, h("p", { className: "field-help" }, "Checks text against your list and the draft above. It doesn't take any action."), h( ListFormSubmit, @@ -7953,7 +7952,6 @@ function tabBadwords() { ), result ? h(BadwordTestResult, { result }) : null, ), - ), ), ); } @@ -8085,8 +8083,8 @@ function CommandWorkbenchInspector({ record, prefix, canManage }) { ? h(Badge, { component: "span", className: "badge badge-info" }, "inherited from global") : h(Badge, { component: "span", className: "badge" }, "server only"); return h( - Paper, - { component: "section", withBorder: true, className: "card bg-base-100 sf-card sf-wb-inspector", "aria-labelledby": "sf-cmd-inspector-title" }, + SentinelCard, + { component: "section", className: "sf-wb-inspector", "aria-labelledby": "sf-cmd-inspector-title" }, h( "div", { className: "sf-bento-head" }, @@ -8707,7 +8705,7 @@ function CommandEditor({ record: c }) { "div", { className: "rule-editor-title" }, h("span", { className: "eyebrow" }, builtin ? "BUILT-IN COMMAND" : isPlan ? "CUSTOM COMMAND" : "COMMAND"), - h("h3", { className: "card-title" }, isNew ? "New custom command" : `Edit command: ${c.name}`), + h("h3", { className: "sf-card-title" }, isNew ? "New custom command" : `Edit command: ${c.name}`), ), h( "div", @@ -9362,10 +9360,10 @@ function TemplateCard({ record: t }) { const scopeSel = scopeSelect(scopeSelRef, "This server", "Global", true, `template:${t.event}:scope`); return h( DraftCard, - { group: `template:${t.event}`, className: "card bg-base-100 card-border template-card" }, + { group: `template:${t.event}`, className: "template-card" }, h( "div", - { className: "card-body" }, + { className: "sf-card-body" }, eventHeading(t.event), h( "div", @@ -9488,8 +9486,8 @@ function tabLogChannels() { "div", { className: channels.length > 0 ? "sf-workbench sf-workbench-logs" : "" }, channels.length > 0 && h( - Paper, - { component: "nav", withBorder: true, className: "card bg-base-100 sf-card sf-log-nav", "aria-label": "Log event streams" }, + SentinelCard, + { component: "nav", className: "sf-log-nav", "aria-label": "Log event streams" }, h( ActionButton, { @@ -9558,8 +9556,8 @@ function LogChannelCard({ lc }) { }); const scopeSelRef = useRef(null); const scopeSel = scopeSelect(scopeSelRef, "This server", "Global", false); - if (!canEditSettings()) return h(Paper, { className: "card bg-base-100 card-border log-channel-card" }, - h("div", { className: "card-body" }, + if (!canEditSettings()) return h(SentinelCard, { className: "log-channel-card" }, + h("div", { className: "sf-card-body" }, eventHeading(lc.event), h("p", null, `Destination channel: ${input.props.defaultValue || "Not set"}`), h("p", null, `Ignored users or bots: ${(lc.ignore?.users || []).join(", ") || "None"}`), @@ -9568,10 +9566,10 @@ function LogChannelCard({ lc }) { ); return h( DraftCard, - { group: `log:${lc.event}`, className: "card bg-base-100 card-border log-channel-card" }, + { group: `log:${lc.event}`, className: "log-channel-card" }, h( "div", - { className: "card-body" }, + { className: "sf-card-body" }, h( "div", { className: "row title-row" }, @@ -10596,7 +10594,7 @@ function tabMembers() { parts.push( h( "h3", - { className: "card-title" }, + { className: "sf-card-title" }, displayName ? `History for ${displayName} (${userId})` : `History for ${userId}`, ), ); @@ -10771,11 +10769,11 @@ function tabMembers() { ), h(MemberImportStatus, { store: syncView }), h( - Paper, - { component: "section", className: "card bg-base-100 card-border" }, + SentinelCard, + { component: "section" }, h( "div", - { className: "card-body" }, + { className: "sf-card-body" }, h(ListControls, { controls }), h( "div", @@ -10805,9 +10803,9 @@ function tabMembers() { ), detailParts.length ? h( - Paper, - { component: "section", className: "card bg-base-100 card-border", "aria-label": "Member history" }, - h("div", { className: "card-body" }, ...detailParts), + SentinelCard, + { component: "section", "aria-label": "Member history" }, + h("div", { className: "sf-card-body" }, ...detailParts), ) : null, ); @@ -11710,9 +11708,9 @@ function tabCases() { ), progress !== null ? h(ListLoadProgress, { loaded: progress, onCancel: () => handlers.current.cancel?.() }) : null, rows === null ? h( - Paper, - { className: "card bg-base-100 card-border", role: "status", "aria-live": "polite" }, - h("div", { className: "card-body" }, "Loading cases…"), + SentinelCard, + { role: "status", "aria-live": "polite" }, + h("div", { className: "sf-card-body" }, "Loading cases…"), ) : h(PagedTable, { headings: CASE_LIST.columns.map((column) => removedView ? column.label : h(ListSortHeading, { key: column.key, column, controls })), @@ -11822,11 +11820,11 @@ function tabSettings() { else cards.push( h( DraftCard, - { group: "settings", className: "card bg-base-100 card-border" }, + { group: "settings" }, h( "div", - { className: "card-body" }, - h("h3", { className: "card-title" }, "This server"), + { className: "sf-card-body" }, + h("h3", { className: "sf-card-title" }, "This server"), cfg.nickname_reconcile?.state === "terminal" ? h( "p", @@ -11989,11 +11987,11 @@ function tabSettings() { if (canEditCaseRemoval) cards.push( h( DraftCard, - { group: "roles", className: "card bg-base-100 card-border" }, + { group: "roles" }, h( "div", - { className: "card-body" }, - h("h3", { className: "card-title" }, "Case removal"), + { className: "sf-card-body" }, + h("h3", { className: "sf-card-title" }, "Case removal"), h( "p", { className: "muted" }, @@ -12006,7 +12004,7 @@ function tabSettings() { ), h( "div", - { className: "card-actions" }, + { className: "sf-card-actions" }, h( ActionButton, { @@ -12042,11 +12040,11 @@ function tabSettings() { cards.push( h( DraftCard, - { group: "global", className: "card bg-base-100 card-border" }, + { group: "global" }, h( "div", - { className: "card-body" }, - h("h3", { className: "card-title" }, "Global defaults (applies to all servers)"), + { className: "sf-card-body" }, + h("h3", { className: "sf-card-title" }, "Global defaults (applies to all servers)"), h( "p", { className: "muted", style: { marginBottom: ".5rem" } }, @@ -12088,11 +12086,11 @@ function tabSettings() { if (canManageServer() && !isPreview()) cards.push( h( DraftCard, - { group: "copy", className: "card bg-base-100 card-border" }, + { group: "copy" }, h( "div", - { className: "card-body" }, - h("h3", { className: "card-title" }, "Copy configuration from another server"), + { className: "sf-card-body" }, + h("h3", { className: "sf-card-title" }, "Copy configuration from another server"), h( "p", { className: "muted", style: { marginBottom: ".5rem" } }, @@ -12188,11 +12186,11 @@ function AccessRolesCard({ settings, revisions }) { }; return h( DraftCard, - { group: "access-roles", className: "card bg-base-100 card-border" }, + { group: "access-roles" }, h( "div", - { className: "card-body" }, - h("h3", { className: "card-title" }, "Web UI access by role"), + { className: "sf-card-body" }, + h("h3", { className: "sf-card-title" }, "Web UI access by role"), h("p", { className: "muted" }, "Members with a listed role can sign in and open this server only."), h(GoodToKnow, { items: [ @@ -12250,7 +12248,7 @@ function AccessRolesCard({ settings, revisions }) { ), h( "div", - { className: "card-actions" }, + { className: "sf-card-actions" }, h( ActionButton, { @@ -12983,9 +12981,9 @@ function DataTable({ ...tableProps }) { return h( - "div", + Paper, { - className: "table-scroll rounded-box bg-base-100", + className: "table-scroll", tabIndex: 0, role: "region", "aria-label": "Scrollable data table", @@ -13306,9 +13304,9 @@ function tabKnownSpam() { ], }), h(RuleStatusCard, { record: rule, trigger: RULE_TRIGGERS.known_spam.phrase() }), - canEditSettings() && h(DraftCard, { group: "known-spam", className: "card bg-base-100 card-border list-card list-add" }, - h("div", { className: "card-body" }, - h("h3", { className: "card-title" }, "Add spam"), + canEditSettings() && h(DraftCard, { group: "known-spam", className: "list-card list-add" }, + h("div", { className: "sf-card-body" }, + h("h3", { className: "sf-card-title" }, "Add spam"), h("div", { className: "list-form-row" }, field("Entry type", h(FieldSelect, { "data-no-draft": true, value: kind, onChange: (event) => setKind(event.target.value) }, h("option", { value: "sample" }, "Full message sample"), @@ -13370,9 +13368,9 @@ function tabKnownSpam() { }) : h("span", { className: "muted" }, "Owner only"))), ), }), - h("details", { className: "card bg-base-100 card-border list-card list-extra" }, + h(SentinelCard, { component: "details", className: "list-card list-extra" }, h("summary", null, "Paste-as-sample examples (not active until saved)"), - h("div", { className: "card-body" }, + h("div", { className: "sf-card-body" }, h("p", null, "Copy the full owner sample you want to save into the sample field. These examples are not preloaded entries."), h("pre", { style: { whiteSpace: "pre-wrap" } }, STOCKS_SPAM_EXAMPLE), h("pre", { style: { whiteSpace: "pre-wrap" } }, AI_SPAM_EXAMPLE), @@ -13427,11 +13425,11 @@ function tabKnownBadImages() { h(RuleStatusCard, { record: rule, trigger: rule ? knownBadTrigger(rule.effective) : "" }), canEditSettings() && h( DraftCard, - { group: "known-bad-images", className: "card bg-base-100 card-border list-card list-add" }, + { group: "known-bad-images", className: "list-card list-add" }, h( "div", - { className: "card-body" }, - h("h3", { className: "card-title" }, "Add an image"), + { className: "sf-card-body" }, + h("h3", { className: "sf-card-title" }, "Add an image"), h("div", { className: "list-entry" }, field("SHA-256 digest", h(FieldInput, { className: "mono", draftKey: "known-bad:hash", "data-hash": true, maxLength: 64, @@ -14230,12 +14228,12 @@ function TabDeletions() { h("h2", null, "Deletions"), h(DeletionIntro, { retention: result.data?.retention }), !isPreview() && h( - Paper, - { className: "card bg-base-100 card-border" }, + SentinelCard, + {}, h( "div", - { className: "card-body" }, - h("h3", { className: "card-title" }, "Record a request"), + { className: "sf-card-body" }, + h("h3", { className: "sf-card-title" }, "Record a request"), h("div", { className: "row form-row", "data-no-draft": true }, field("Requester's Discord user ID", h(FieldInput, { type: "text", inputMode: "numeric", value: subject, @@ -14369,12 +14367,12 @@ function TabOwnerDeletions() { (result.data?.unavailable_guilds || []).length > 0 && h("p", { className: "err", role: "alert" }, `Some servers could not be read: ${result.data.unavailable_guilds.join(", ")}`), h( - Paper, - { className: "card bg-base-100 card-border" }, + SentinelCard, + {}, h( "div", - { className: "card-body" }, - h("h3", { className: "card-title" }, "Record a request for every server"), + { className: "sf-card-body" }, + h("h3", { className: "sf-card-title" }, "Record a request for every server"), h("div", { className: "row form-row", "data-no-draft": true }, field("Requester's Discord user ID", h(FieldInput, { type: "text", inputMode: "numeric", value: subject, diff --git a/frontend/controls.css b/frontend/controls.css index 3a229153..d2e9e51f 100644 --- a/frontend/controls.css +++ b/frontend/controls.css @@ -139,15 +139,8 @@ a:where(:not(.mantine-Button-root, .mantine-ActionIcon-root)) { color: inherit; .mantine-Switch-input:disabled + .mantine-Switch-track { opacity: .65; cursor: not-allowed; } :is(button, input, select, textarea):disabled { cursor: not-allowed; } -.card { min-width: 0; background: var(--panel); border-radius: var(--radius-box); } -.card-border { border: 1px solid var(--shell-border); } -.card-body { display: flex; flex-direction: column; gap: var(--ui-gap); padding: var(--card-p); min-width: 0; } -.card-title { font-size: 1rem; font-weight: 700; } -.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; } .fieldset { min-width: 0; } .fieldset-legend { display: block; font-size: var(--ui-font-size-sm); font-weight: 650; } -.hero { display: grid; place-items: center; padding: var(--card-p); } -.hero-content { min-width: 0; } .menu { display: flex; flex-direction: column; padding: .5rem; list-style: none; } .menu li { min-width: 0; } diff --git a/frontend/style.css b/frontend/style.css index c8b91718..5b810e53 100644 --- a/frontend/style.css +++ b/frontend/style.css @@ -40,14 +40,10 @@ body { background: var(--bg); } /* WCAG 2.2 target size: compact controls (xs/sm/square buttons, fields, tooltip triggers) never render below 24px. */ .mantine-ActionIcon-root, .tooltip-trigger { min-width: var(--target-min); } /* One visible focus ring for every control; --accent keeps 3:1 on all shell surfaces in both themes. */ -:is(.mantine-Button-root, .mantine-ActionIcon-root, .mantine-Input-input, .mantine-Checkbox-input, .server-picker-trigger, .menu button, .tooltip-trigger, .mantine-Notification-closeButton, a, summary, .sf-hub-pill, .sf-srv-btn, .sf-rail-toggle, .sf-ribbon-link, .sf-tri button, .sf-log-nav-btn, .sf-wb-select-btn):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } +:is(.mantine-Button-root, .mantine-ActionIcon-root, .mantine-Input-input, .mantine-Checkbox-input, .server-picker-trigger, .menu button, .tooltip-trigger, .mantine-Notification-closeButton, .table-scroll, a, summary, .sf-hub-pill, .sf-srv-btn, .sf-rail-toggle, .sf-ribbon-link, .sf-tri button, .sf-log-nav-btn, .sf-wb-select-btn):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } .mantine-Switch-input:focus-visible + .mantine-Switch-track { outline: 2px solid var(--accent); outline-offset: 2px; } .hidden, [hidden] { display: none !important; } .w-full { width: 100%; } -.bg-base-100 { background-color: var(--panel); } -.bg-base-200 { background-color: var(--hero); } -.text-warning { color: var(--warn); } -@layer utilities { .rounded-box { border-radius: var(--radius-box); } } .skip-link { position: fixed; top: -80px; left: 16px; z-index: 100; padding: 12px; background: var(--panel); } .skip-link:focus { top: 12px; } /* Visually hidden but still read by screen readers (e.g. chart summaries). */ @@ -75,12 +71,18 @@ body { background: var(--bg); } .workspace-header strong { display: block; font-size: var(--ui-font-size); overflow-wrap: anywhere; } #workspace-status { flex: 0 0 auto; color: var(--muted); font-size: .6875rem; text-align: right; } #content { width: 100%; max-width: 1440px; padding: 1rem 1.25rem 1.5rem; margin: 0 auto; flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--ui-gap); } -#content > div:not(.hero):not(.contents):not(.stats):not(.alert):not(.card):not(.modal) { display: flex; flex-direction: column; gap: var(--ui-gap); } +#content > div:not(.sf-empty-panel):not(.contents):not(.stats):not(.alert):not(.sf-card):not(.modal) { display: flex; flex-direction: column; gap: var(--ui-gap); } .workspace-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 1.25rem; padding: .625rem 0; border-top: 1px solid var(--shell-border); color: var(--muted); font-size: .6875rem; } -.hero-content { max-width: none; width: 100%; } -.hero-copy { max-width: 40rem; } -.hero-copy p { color: var(--hero-text); } +/* Shared Sentinel Paper card surface, body, title, actions and empty panel. */ +.sf-card { min-width: 0; box-shadow: 0 2px 10px #040b1814; } +[data-theme="dark"] .sf-card { box-shadow: 0 2px 12px #040b1852; } +.sf-card-body { display: flex; flex-direction: column; gap: var(--ui-gap); padding: var(--card-p); min-width: 0; } +.sf-card-title { font-size: 1rem; font-weight: 700; } +.sf-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; } +.sf-empty-panel { padding: var(--card-p); background: var(--hero); border-color: var(--hero-border); } +.sf-empty-panel-copy { max-width: 40rem; display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; } +.sf-empty-panel-copy p { color: var(--hero-text); } .contents { display: contents; } .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr)); gap: var(--ui-gap); } .row { display: flex; gap: .625rem; align-items: center; flex-wrap: wrap; } @@ -141,7 +143,7 @@ body { background: var(--bg); } /* The keyboard-active option keeps the shared focus ring while focus stays on the list. */ .server-picker-list [role=option].menu-focus { outline: 2px solid var(--accent); outline-offset: 0; } -.table-scroll { overflow-x: auto; } +.table-scroll { overflow-x: auto; border-radius: var(--radius-box); } .mono { font-family: var(--font-mono); --input-font-family: var(--font-mono); } .muted { color: var(--muted); } .ok { color: var(--good); } @@ -152,7 +154,8 @@ pre.code { background: var(--panel2); border: 1px solid var(--shell-border); bor .mantine-Notification-closeButton { color: var(--muted); } .welcome-view { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(ellipse at 80% 10%, var(--welcome-glow), transparent 60%), var(--bg); } -.login-card { width: min(100%, 38.75rem); color: var(--text); text-align: center; border: 1px solid var(--shell-border); box-shadow: 0 12px 32px #040b181f; } +.login-card { width: min(100%, 38.75rem); color: var(--text); text-align: center; box-shadow: 0 12px 32px #040b181f; } +[data-theme="dark"] .login-card { box-shadow: 0 12px 32px #040b1852; } .login-card .brand-mark { width: 3.25rem; height: 3.25rem; font-size: 1.5rem; margin: 0 auto .5rem; border-radius: .875rem; } .login-card .eyebrow { color: var(--muted); } .login-card h1 { font-size: clamp(1.75rem, 4.4vw, 2.75rem); line-height: 1.15; letter-spacing: -.04em; margin: .875rem 0 1rem; } @@ -204,8 +207,6 @@ pre.code { background: var(--panel2); border: 1px solid var(--shell-border); bor #content h2 { font-size: 1.125rem; line-height: 1.3; font-weight: 750; letter-spacing: -.01em; } #content h3 { font-size: .9375rem; line-height: 1.35; font-weight: 700; } #content p { line-height: 1.5; } -#content .card { border: 1px solid var(--shell-border); } -#content .card-body { gap: var(--ui-gap); } /* Compact stats. */ .stats .stat { padding: .5rem .75rem; row-gap: .125rem; } .stat-title { color: var(--muted); font-size: .75rem; } @@ -306,8 +307,8 @@ pre.code { background: var(--panel2); border: 1px solid var(--shell-border); bor editor's width: status, add form, list, then a collapsible tester or preview. Every control uses the shared height so inputs, selects and buttons line up. */ .list-page { max-width: 56rem; } -.list-card > .card-body, .list-card > details > .card-body { padding: .875rem 1.125rem; gap: .625rem; } -.list-card .card-title { margin: 0; } +.list-card > .sf-card-body, .list-card > details > .sf-card-body { padding: .875rem 1.125rem; gap: .625rem; } +.list-card .sf-card-title { margin: 0; } .list-card .field { margin-bottom: 0; padding-block: 0; } .list-card .mantine-InputWrapper-root { width: 100%; } .list-status .rule-editor-header, .list-status .rule-summary { margin: 0; } @@ -438,8 +439,7 @@ pre.code { background: var(--panel2); border: 1px solid var(--shell-border); bor .administration-overview h2 { margin: 0 0 .25rem; font-size: 1rem; } .administration-overview p, .administration-card-heading p { margin: 0; } .administration-page #update-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(21.875rem, 100%), 1fr)); gap: var(--ui-gap); align-items: start; } -.administration-card, .administration-card .card-body { min-width: 0; } -.administration-card .card-body { display: flex; flex-direction: column; padding: var(--card-p); gap: var(--ui-gap); } +.administration-card { min-width: 0; } .administration-card-heading { align-items: flex-start; } .administration-card-heading h2 { font-size: 1rem; margin: 0 0 .125rem; } .administration-card-heading p, .administration-help { font-size: .75rem; } @@ -627,7 +627,7 @@ svg.icon-neutral { color: var(--icon-neutral); } .du-tone-accent { --du-tone: var(--accent); } .du-tone-muted { --du-tone: var(--muted); } .du-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(26rem, 100%), 1fr)); gap: var(--ui-gap); align-items: start; } .du-card { min-width: 0; } -.du-card .card-body { gap: 8px; padding: 10px 12px; } +.du-card .sf-card-body { gap: 8px; padding: 10px 12px; } .du-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; } #content .du-title { margin: 0; min-width: 0; font-size: .875rem; font-weight: 600; overflow-wrap: anywhere; } .du-health { white-space: nowrap; } @@ -968,8 +968,6 @@ svg.icon-neutral { color: var(--icon-neutral); } .sf-sub-tabs svg.nav-icon { width: 1rem; height: 1rem; padding: 0; border-radius: 0; background: transparent; } /* Elevated Bento Cards & Command Center Layout */ -.sf-card { box-shadow: 0 2px 10px #040b1814; } -[data-theme="dark"] .sf-card { box-shadow: 0 2px 12px #040b1852; } .dashboard-section .stats.dashboard-stats { border-radius: var(--radius-box); box-shadow: 0 2px 10px #040b1814; diff --git a/scripts/administration-state-test.mjs b/scripts/administration-state-test.mjs index 2850a3d9..d0e3213e 100644 --- a/scripts/administration-state-test.mjs +++ b/scripts/administration-state-test.mjs @@ -1061,3 +1061,22 @@ test("Administration form controls render Mantine NativeSelect and TextInput wit assert.ok(alertInput?.classList.contains("mantine-TextInput-input")); assert.equal(alertInput.classList.contains("input"), false); }); + +test("Administration cards render bordered Sentinel Paper cards without daisy classes", async () => { + const view = await ready(async (url) => response(url === "/api/me" ? { is_bot_owner: true } : state([record("bot")]))); + const content = view.elements.get("content"); + const cards = [componentCard(view, "bot"), content.querySelector("#alert-channel")]; + for (const card of cards) { + assert.ok(card, "expected card element"); + assert.ok(card.classList.contains("mantine-Paper-root"), "card renders Mantine Paper"); + assert.ok(card.classList.contains("sf-card"), "card applies Sentinel surface class"); + assert.equal(card.getAttribute("data-with-border"), "true", "card renders with border"); + for (const retired of ["card", "card-border", "bg-base-100", "bg-base-200", "rounded-box"]) { + assert.equal(card.classList.contains(retired), false, `retired class ${retired}`); + } + assert.ok(card.querySelector(".sf-card-body"), "card uses .sf-card-body"); + assert.ok(card.querySelector(".sf-card-title"), "card uses .sf-card-title"); + assert.ok(card.querySelector(".sf-card-actions"), "card uses .sf-card-actions"); + assert.equal(card.querySelector(".card-body, .card-title, .card-actions"), null); + } +}); diff --git a/scripts/frontend-contrast-test.mjs b/scripts/frontend-contrast-test.mjs index 5dffe232..936c0aea 100644 --- a/scripts/frontend-contrast-test.mjs +++ b/scripts/frontend-contrast-test.mjs @@ -303,6 +303,40 @@ test("daisy-era .table and .table-zebra classes are removed from frontend source } }); +test("daisy-era card, hero, bg-base, rounded-box and text-warning classes are removed from frontend sources", () => { + const retiredTokens = /(?:^|[\s"`])(?:card|card-border|card-body|card-title|card-actions|bg-base-100|bg-base-200|rounded-box|hero|hero-content|hero-copy|text-warning)(?=$|[\s"`])/; + const retiredCss = /(?:^|[^a-zA-Z0-9_-])\.(?:card|card-border|card-body|card-title|card-actions|bg-base-100|bg-base-200|rounded-box|hero|hero-content|hero-copy|text-warning)(?=[^a-zA-Z0-9_-]|$)/; + for (const file of [ + "app.js", "administration.js", "appearance.js", "charts.js", "list-controls.js", + "controls.css", "style.css", "index.html", "administration/index.html", + ]) { + const source = readFileSync(new URL(`../frontend/${file}`, import.meta.url), "utf8"); + if (file.endsWith(".css")) { + assert.doesNotMatch(source, retiredCss, file); + } + if (file.endsWith(".js")) { + for (const [, literal] of source.matchAll(/className:\s*("[^"\n]*"|`[^`]*`)/g)) { + assert.doesNotMatch(literal, retiredTokens, `${file}: ${literal}`); + } + } + if (file.endsWith(".html")) { + for (const [, literal] of source.matchAll(/class="([^"]*)"/g)) { + assert.doesNotMatch(literal, /(?:^|\s)(?:card|card-border|card-body|card-title|card-actions|bg-base-100|bg-base-200|rounded-box|hero|hero-content|hero-copy|text-warning)(?=$|\s)/, `${file}: ${literal}`); + } + } + } + assert.equal(declaration(rule(".sf-card-body"), "padding"), "var(--card-p)"); + assert.equal(declaration(rule(".sf-card-body"), "gap"), "var(--ui-gap)"); + assert.equal(declaration(rule(".sf-empty-panel"), "background"), "var(--hero)"); + assert.equal(declaration(rule(".sf-empty-panel"), "border-color"), "var(--hero-border)"); + assert.equal(declaration(rule(".sf-empty-panel-copy p"), "color"), "var(--hero-text)"); + for (const [theme, selector] of [["light", ":root"], ["dark", ':root[data-theme="dark"]']]) { + const colors = tokens(selector); + assert.ok(contrast(colors["--text"], colors["--hero"]) >= 4.5, `${theme} empty panel heading on --hero`); + assert.ok(contrast(colors["--hero-text"], colors["--hero"]) >= 4.5, `${theme} empty panel copy on --hero`); + } +}); + test("Mantine Table maps stripe, hover, border and header tokens to Sentinel palette", () => { const appearance = readFileSync(new URL("../frontend/appearance.js", import.meta.url), "utf8"); assert.match(appearance, /"--table-border-color":\s*"var\(--shell-border\)"/); @@ -549,7 +583,7 @@ test("the page uses the scale tokens instead of the old touch-sized values", () test("compact controls keep a visible focus ring with 3:1 contrast on every surface", () => { const focus = css.match(/^:is\(([^)]*)\):focus-visible\s*\{([^}]*)\}/m); assert.ok(focus, "missing the shared :focus-visible rule"); - for (const control of [".mantine-Button-root", ".mantine-ActionIcon-root", ".mantine-Input-input", ".mantine-Checkbox-input", ".server-picker-trigger", ".menu button", ".tooltip-trigger", ".mantine-Notification-closeButton", "a", "summary"]) + for (const control of [".mantine-Button-root", ".mantine-ActionIcon-root", ".mantine-Input-input", ".mantine-Checkbox-input", ".server-picker-trigger", ".menu button", ".tooltip-trigger", ".mantine-Notification-closeButton", ".table-scroll", "a", "summary"]) assert.ok(focus[1].split(/,\s*/).includes(control), `focus ring must cover ${control}`); assert.match(focus[2], /outline:\s*2px solid var\(--accent\)/); assert.match(focus[2], /outline-offset:\s*2px/); diff --git a/scripts/frontend-state-test.mjs b/scripts/frontend-state-test.mjs index 288759ad..dda702f9 100644 --- a/scripts/frontend-state-test.mjs +++ b/scripts/frontend-state-test.mjs @@ -1130,7 +1130,7 @@ test('dashboard shows the configured and measured stats in one compact grid', as assert.equal(grids[0].children.length, expected.length, 'no stat dropped or duplicated'); for (const [label, shown] of expected) assert.equal(value(label), shown, label); // The hero, its eyebrow and the separate explainer band are gone. - assert.equal(dashboard.querySelector('.hero, .dashboard-hero, .eyebrow, .dashboard-note')?.className ?? null, null); + assert.equal(dashboard.querySelector('.sf-empty-panel, .hero, .dashboard-hero, .eyebrow, .dashboard-note')?.className ?? null, null); const header = dashboard.querySelector('.page-header'); assert.ok(Boolean(header), 'expected a page header'); assert.equal(header.querySelectorAll('h2').length, 1); @@ -1348,7 +1348,7 @@ test('analytics opens with a one-line header, range selector and info tip, then app.state.config = ANALYTICS_CONFIG; const panel = app.tabAnalytics(); await settle(); - assert.equal(panel.querySelector('.hero, .dashboard-hero, .eyebrow')?.className ?? null, null); + assert.equal(panel.querySelector('.sf-empty-panel, .hero, .dashboard-hero, .eyebrow')?.className ?? null, null); const header = panel.querySelector('.page-header'); assert.equal(header.querySelector('h2').textContent, 'Analytics'); assert.match(header.querySelector('.page-header-detail').textContent, /First · last 30 days \(UTC\)/); @@ -2844,7 +2844,7 @@ test('Members lays out a finished import as one summary line with its history be const panel = h.app.tabMembers(); await settle(); const card = memberImport(panel); - assert.ok(!card.closest('.card'), 'a finished one-time import does not lead the page as a card'); + assert.ok(!card.closest('.sf-card'), 'a finished one-time import does not lead the page as a card'); assert.equal(textOf(memberCoverage(panel)), 'Member list: up to date'); assert.ok(memberCoverage(panel).compareDocumentPosition(card) & h.window.Node.DOCUMENT_POSITION_FOLLOWING); // One line: counts, completion date and duration. @@ -2888,7 +2888,7 @@ test('Members lays out a finished import as one summary line with its history be fire(findNode(panel, n => n.localName === 'button' && n.getAttribute('aria-label') === 'View history'), 'click'); await settle(); const history = findNode(panel, n => n.getAttribute?.('aria-label') === 'Member history'); - assert.deepEqual([...history.children].map(n => n.className), ['card-body']); + assert.deepEqual([...history.children].map(n => n.className), ['sf-card-body']); }); test('Members keeps a running import compact but visible outside Details', async () => { @@ -2951,8 +2951,8 @@ test('Members describes a server that was never imported in one line with no emp const panel = memberView(h); await settle(); const card = memberImport(panel); - assert.ok(!card.closest('.card'), 'no import card'); - assert.ok(!card.querySelector('details, table, dl, progress, .card'), 'nothing to expand before a first run exists'); + assert.ok(!card.closest('.sf-card'), 'no import card'); + assert.ok(!card.querySelector('details, table, dl, progress, .sf-card'), 'nothing to expand before a first run exists'); assert.equal(textOf(memberImportStatus(panel)), 'The bot will create the first import job when it is online. Import controls become available after that job exists.'); assert.match(textOf(memberCoverage(panel)), /^Member list: partial/); @@ -11120,7 +11120,7 @@ test('known spam acknowledged Global add keeps Global selected when the refresh assert.match(content().textContent, /Configuration unavailable/); await fire([...content().querySelectorAll('button')].find(b => b.textContent === 'Retry'), 'click'); assert.equal(scopeSelect().value, 'global', 'the acknowledged scope stays selected after the refresh recovers'); - assert.equal(content().querySelector('.card [role="alert"]'), null, 'an acknowledged add is not reported as unconfirmed'); + assert.equal(content().querySelector('.sf-card [role="alert"]'), null, 'an acknowledged add is not reported as unconfirmed'); assert.deepEqual(Object.keys(h.app.currentDrafts()), []); assert.equal(h.app.isDirty(), false); }); @@ -11144,7 +11144,7 @@ test('known spam add failure stays with its draft without claiming an outcome th const sample = content().querySelector('textarea'); sample.value = 'Join our stocks community'; await fire(sample, 'input'); const add = label => fire([...content().querySelectorAll('button')].find(b => b.textContent === label), 'click'); - const alert = () => content().querySelector('.card [role="alert"]')?.textContent || ''; + const alert = () => content().querySelector('.sf-card [role="alert"]')?.textContent || ''; await add('Add sample'); assert.equal(alert(), 'Sample not confirmed as added: known spam entry already exists'); assert.equal(h.app.currentDrafts()['known-spam:sample'].value, 'Join our stocks community'); @@ -17934,3 +17934,50 @@ test('workspace form controls render Mantine TextInput, NativeSelect, Textarea, assert.ok(textarea?.classList.contains('mantine-Textarea-input'), 'multiline fields use Mantine Textarea'); assert.equal(textarea.classList.contains('textarea'), false); }); + +test('workspace cards and emptyPanel render Sentinel Paper cards without daisy classes', async () => { + const h = harness(); + const retired = ['card', 'card-border', 'card-body', 'card-title', 'card-actions', 'bg-base-100', 'bg-base-200', 'rounded-box', 'hero', 'hero-content', 'hero-copy']; + const assertNoRetired = (root, label) => { + for (const cls of retired) { + assert.equal(root.classList?.contains(cls) || false, false, `${label} must not have .${cls}`); + assert.equal(root.querySelector(`.${cls}`), null, `${label} subtree must not have .${cls}`); + } + }; + + h.app.state.config = { + enrollment_id: 'e1', + settings: { prefix: '!', bot_name: '' }, + global_settings: { prefix: '!' }, + rules: [{ rule_id: 'badword', name: 'Badwords', effective: { enabled: true, dry_run: false, actions: [{ at: 1, action: 'warn' }] } }], + commands: [], + log_channels: [], + badwords: [], + templates: [], + }; + h.app.navigate('badwords'); + await settle(); + const badwordsCards = [...h.document.querySelectorAll('#content .sf-card')]; + assert.equal(badwordsCards.length, 4, 'badwords renders status, add, table, and collapsible tester Sentinel cards'); + for (const card of badwordsCards) { + assert.ok(card.classList.contains('mantine-Paper-root'), 'card renders Mantine Paper'); + assert.equal(card.getAttribute('data-with-border'), 'true', 'card has Paper border'); + assert.ok(card.querySelector('.sf-card-body'), 'card uses .sf-card-body'); + } + const tester = h.document.querySelector('#content details.list-extra'); + assert.ok(tester?.classList.contains('mantine-Paper-root'), 'collapsible tester renders directly as Paper details'); + assert.ok(tester.classList.contains('sf-card')); + assertNoRetired(h.document.querySelector('#content'), 'badwords workspace'); + + h.app.state.config = null; + h.app.state.configRead = { activity: 'idle', error: 'Temporary outage' }; + h.app.renderTab(); + await settle(); + const empty = h.document.querySelector('#content .sf-empty-panel'); + assert.ok(empty, 'emptyPanel renders .sf-empty-panel'); + assert.ok(empty.classList.contains('mantine-Paper-root'), 'emptyPanel uses Mantine Paper'); + assert.ok(empty.classList.contains('sf-card'), 'emptyPanel uses .sf-card'); + assert.equal(empty.getAttribute('data-with-border'), 'true', 'emptyPanel uses Paper border'); + assert.ok(empty.querySelector('.sf-empty-panel-copy'), 'emptyPanel wraps copy cleanly'); + assertNoRetired(empty, 'emptyPanel'); +}); diff --git a/scripts/package-webui-test.mjs b/scripts/package-webui-test.mjs index 27f08df5..98b04331 100644 --- a/scripts/package-webui-test.mjs +++ b/scripts/package-webui-test.mjs @@ -105,26 +105,23 @@ test("WebUI ships Mantine components without the retired UI libraries", () => { test("WebUI CSS retains used widgets and excludes unused component families", () => { const css = fs.readFileSync(path.join(repo, "dist/frontend/style.css"), "utf8"); - for (const name of ["alert", "badge", "card", "hero", "menu", "modal-overlay", "stat"]) { + for (const name of ["alert", "badge", "menu", "modal-overlay", "sf-card", "sf-card-body", "sf-empty-panel", "stat"]) { assert.ok(new RegExp("\\." + name + "(?=[^a-zA-Z0-9_-])").test(css), "missing " + name); } - for (const name of ["btn", "checkbox", "input", "select", "table", "table-zebra", "textarea", "toggle"]) { + for (const name of ["btn", "card", "card-actions", "card-body", "card-border", "card-title", "checkbox", "hero", "hero-content", "hero-copy", "input", "select", "table", "table-zebra", "textarea", "toggle"]) { assert.ok(!new RegExp("\\." + name + "(?=[^a-zA-Z0-9_-])").test(css), `retired daisy .${name} must not be emitted`); } assert.ok(css.includes(".table-scroll{"), "horizontal table scroll wrapper must stay emitted"); for (const name of ["carousel", "chat", "countdown", "dock", "drawer", "rating", "timeline"]) { assert.ok(!new RegExp("\\." + name + "(?=[^a-zA-Z0-9_-])").test(css), "unused " + name); } - for (const name of ["bg-base-100", "bg-base-200", "text-warning", "rounded-box"]) { - assert.ok(css.includes("." + name + "{"), "missing theme utility " + name); - } // Selective imports keep unused Mantine component styles out of the release. const { css: metadata } = JSON.parse(fs.readFileSync(path.join(repo, "dist/webui-metafile.json"), "utf8")); assert.ok(!Object.keys(metadata.inputs).some((name) => /@mantine\/core\/styles(?:\.layer)?\.css$/.test(name))); - for (const name of ["ActionIcon", "Button", "Checkbox", "Combobox", "InlineInput", "Input", "Switch", "Table"]) { + for (const name of ["ActionIcon", "Button", "Checkbox", "Combobox", "InlineInput", "Input", "Paper", "Switch", "Table"]) { assert.ok(Object.keys(metadata.inputs).some((file) => file.endsWith(`/@mantine/core/styles/${name}.layer.css`)), "missing Mantine CSS " + name); } - for (const name of ["bg-base-300", "text-secondary", "rounded-t-box", "rounded-selector"]) { + for (const name of ["bg-base-100", "bg-base-200", "bg-base-300", "rounded-box", "rounded-t-box", "rounded-selector", "text-secondary", "text-warning"]) { assert.ok(!css.includes("." + name), "unused theme utility " + name); } });