feat(ui): shared v2 header on all pages (logo, project cell, gradient button)

This commit is contained in:
chahinebrini 2026-07-22 17:30:09 +02:00
parent 964ddff2f2
commit 6e81500b74
5 changed files with 115 additions and 129 deletions

View File

@ -1,30 +1,13 @@
import { escapeHtml } from '../ui-shared.js'; import { appHeader } from '../ui-shared.js';
const LOGO = '<img src="/logo.svg" alt="" width="24" height="24" class="b2-logo-img">';
/** /**
* Fixed app header for board v2. The project cell is visual only the real * Fixed app header for board v2 the shared v2 header (ui-shared.appHeader)
* project switcher dropdown arrives with the multi-project v3 spec. * with the board marked active. The project cell is visual only (dropdown = v3);
* The SSE status span keeps the v1 ids (`sseStatus`, `sseLabel`) so the ported * SSE ids (`sseStatus`, `sseLabel`) match the ported connection-status JS.
* connection-status JS keeps working unchanged. * Styling comes from ui-shared's appHeaderOnlyCss(), which boardV2Css() includes.
*/ */
export function headerHtml(projectName: string): string { export function headerHtml(projectName: string): string {
const name = escapeHtml(projectName); return appHeader(projectName, 'board');
return `
<header class="b2-hdr">
<span class="b2-brand">${LOGO}<b>agenthub</b></span>
<span class="b2-proj" title="Projektwechsel kommt mit v3">/ <span id="projectName">${name}</span>&nbsp;<span class="b2-chev"></span></span>
<nav class="b2-nav" aria-label="Primary">
<b aria-current="page">Board</b><a href="/team">Team</a><a href="/activity">Activity</a><a href="/decisions">Decisions</a>
</nav>
<span class="b2-hdr-right">
<button type="button" class="b2-btn" id="newTaskBtn" aria-haspopup="dialog" aria-expanded="false">+ New task</button>
<span class="sse-status stale" id="sseStatus">
<span class="b2-live-dot" aria-hidden="true"></span>
<span id="sseLabel">connecting</span>
</span>
</span>
</header>`;
} }
/** Fullscreen splash overlay, shown until first data render (hard cap 1.5s). */ /** Fullscreen splash overlay, shown until first data render (hard cap 1.5s). */

View File

@ -1,15 +1,19 @@
/** /**
* Board v2 design system: glass dashboard on a deep gradient. * Board v2 design system: glass dashboard on a deep gradient.
* Everything is emitted by boardV2Css() and inlined into the page <style>. * Everything is emitted by boardV2Css() and inlined into the page <style>.
* The header CSS is shared with all pages and comes from ui-shared
* (appHeaderOnlyCss) this file only adds the board-specific components.
* *
* Naming: `b2-` prefix for new v2 components (header, kpis, sidebar tabs, * Naming: `b2-` prefix for new v2 components (kpis, sidebar tabs,
* feed, splash, progress ring). Interaction-critical components ported from * feed, splash, progress ring). Interaction-critical components ported from
* v1 (cards, columns, console, modals, toasts, budget internals) keep their * v1 (cards, columns, console, modals, toasts, budget internals) keep their
* v1 class names so the ported client JS keeps working unchanged they read * v1 class names so the ported client JS keeps working unchanged they read
* the same CSS variables, which are redefined here with the v2 glass values. * the same CSS variables, which are redefined here with the v2 glass values.
*/ */
import { appHeaderOnlyCss } from '../ui-shared.js';
export function boardV2Css(): string { export function boardV2Css(): string {
return ` return appHeaderOnlyCss() + `
:root { :root {
/* v2 tokens */ /* v2 tokens */
--b2-bg: #090c18; --b2-bg: #090c18;
@ -65,60 +69,9 @@ export function boardV2Css(): string {
/* ── Keyframes (v2) ───────────────────────────────────────────────── */ /* ── Keyframes (v2) ───────────────────────────────────────────────── */
@keyframes b2-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } } @keyframes b2-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes b2-fill { from { width: 0; } } @keyframes b2-fill { from { width: 0; } }
@keyframes b2-ping { 0% { box-shadow: 0 0 0 0 rgba(52,211,179,.55); } 70% { box-shadow: 0 0 0 7px rgba(52,211,179,0); } 100% { box-shadow: 0 0 0 0 rgba(52,211,179,0); } }
@keyframes b2-blink { 50% { opacity: .3; } } @keyframes b2-blink { 50% { opacity: .3; } }
@keyframes b2-draw { to { stroke-dashoffset: 0; } } @keyframes b2-draw { to { stroke-dashoffset: 0; } }
/* ── Header ───────────────────────────────────────────────────────── */
.b2-hdr {
position: fixed; top: 0; left: 0; right: 0; z-index: 40;
display: flex; align-items: center; gap: 14px;
min-height: 66px; padding: 10px 22px;
border-bottom: 1px solid rgba(255,255,255,.06);
background: rgba(9, 12, 24, .82);
backdrop-filter: blur(12px);
}
.b2-brand { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.b2-brand b { font-weight: 700; letter-spacing: .01em; }
.b2-logo-img { display: block; }
.b2-proj {
display: flex; align-items: center; gap: 5px;
color: var(--b2-muted); font-size: 13px; font-family: var(--mono);
padding: 4px 10px; border-radius: 8px; border: 1px solid transparent;
max-width: 34vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.b2-proj:hover { background: rgba(255,255,255,.05); border-color: var(--b2-border); color: #c6d0e8; }
.b2-chev { font-size: 9px; opacity: .7; }
.b2-nav { display: flex; align-items: center; gap: 2px; margin-left: 8px;
border: 1px solid var(--b2-border); background: var(--b2-surface);
padding: 3px; border-radius: 9px; }
.b2-nav b, .b2-nav a {
min-height: 32px; display: inline-flex; align-items: center;
padding: 0 13px; border-radius: 7px; font-size: 13px; font-weight: 500;
color: var(--b2-muted); transition: color 160ms ease, background 160ms ease;
}
.b2-nav b { color: var(--b2-text); background: rgba(255,255,255,.08); font-weight: 600; }
.b2-nav a:hover { color: var(--b2-text); background: rgba(255,255,255,.05); }
.b2-hdr-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.b2-btn {
display: inline-flex; align-items: center; gap: 7px;
min-height: 36px; padding: 0 16px; border: 0; border-radius: 9px;
background: linear-gradient(135deg, #6366f1, #8b5cf6);
color: #fff; font: 600 13px/1 var(--sans);
box-shadow: 0 4px 18px rgba(99,102,241,.28);
transition: transform 120ms ease, box-shadow 160ms ease, filter 160ms ease;
}
.b2-btn:hover { filter: brightness(1.1); box-shadow: 0 6px 22px rgba(99,102,241,.38); }
.b2-btn:active { transform: translateY(1px); }
.b2-live-dot {
width: 9px; height: 9px; border-radius: 50%;
background: var(--b2-green); animation: b2-ping 2s infinite;
}
/* v1 JS toggles stale/down states on the wrapper — keep hooks compatible */
.sse-status { display: inline-flex; align-items: center; gap: 7px; color: var(--b2-muted); font: 12px/1 var(--mono); }
.sse-status.stale .b2-live-dot { background: var(--b2-amber); animation: none; }
.sse-status.down .b2-live-dot { background: var(--danger); animation: none; }
/* ── Layout ───────────────────────────────────────────────────────── */ /* ── Layout ───────────────────────────────────────────────────────── */
.b2-body { .b2-body {
display: grid; grid-template-columns: minmax(0, 1fr) minmax(290px, 330px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(290px, 330px);
@ -458,17 +411,14 @@ export function boardV2Css(): string {
} }
@media (max-width: 860px) { @media (max-width: 860px) {
body { padding-left: 14px; padding-right: 14px; } body { padding-left: 14px; padding-right: 14px; }
.b2-hdr { padding-left: 14px; padding-right: 14px; } .app-header { padding-left: 14px; padding-right: 14px; }
.b2-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .b2-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.board { grid-template-columns: repeat(2, 1fr); } .board { grid-template-columns: repeat(2, 1fr); }
.b2-proj { max-width: 46vw; } .app-header .b2-proj { max-width: 46vw; }
} }
@media (max-width: 560px) { @media (max-width: 560px) {
.b2-hdr { align-items: flex-start; flex-wrap: wrap; }
.b2-kpis { grid-template-columns: 1fr; } .b2-kpis { grid-template-columns: 1fr; }
.board { grid-template-columns: 1fr; } .board { grid-template-columns: 1fr; }
.b2-nav { flex: 1; }
.b2-nav b, .b2-nav a { flex: 1; justify-content: center; }
.detail-activity-row { grid-template-columns: 1fr; gap: 3px; } .detail-activity-row { grid-template-columns: 1fr; gap: 3px; }
.agent-bar-row { grid-template-columns: 1fr; gap: 6px; } .agent-bar-row { grid-template-columns: 1fr; gap: 6px; }
} }

View File

@ -293,41 +293,72 @@ export function pageHeader(projectName: string, current: 'board' | 'team' | 'act
export type HeaderPage = 'board' | 'team' | 'activity' | 'messages' | 'decisions' | 'archive' | 'task'; export type HeaderPage = 'board' | 'team' | 'activity' | 'messages' | 'decisions' | 'archive' | 'task';
/** CSS for the shared header + new-task modal + toasts. Include once per page. */ /** CSS for ONLY the shared header (board v2 reuses this inside boardV2Css). */
export function appHeaderCss(): string { export function appHeaderOnlyCss(): string {
return ` return `
/* v2 header tokens (self-contained — host pages define different palettes) */
:root {
--b2-border: rgba(255,255,255,.09);
--b2-surface: rgba(255,255,255,.045);
--b2-text: #eef1f8;
--b2-muted: #8fa0c6;
--b2-green: #34d399;
--b2-amber: #fbbf24;
}
@keyframes b2-ping { 0% { box-shadow: 0 0 0 0 rgba(52,211,179,.55); } 70% { box-shadow: 0 0 0 7px rgba(52,211,179,0); } 100% { box-shadow: 0 0 0 0 rgba(52,211,179,0); } }
.app-header { .app-header {
position: fixed; top: 0; left: 0; right: 0; z-index: 40; position: fixed; top: 0; left: 0; right: 0; z-index: 40;
display: flex; align-items: center; gap: 16px; min-height: 64px; display: flex; align-items: center; gap: 14px; min-height: 66px;
margin: 0; padding: 10px 20px; margin: 0; padding: 10px 22px;
border-bottom: 1px solid var(--border); border-bottom: 1px solid rgba(255,255,255,.06);
background: rgba(15, 23, 42, .96); backdrop-filter: blur(10px); background: rgba(9, 12, 24, .82); backdrop-filter: blur(12px);
} }
.app-header .brand { display: flex; align-items: center; gap: 10px; min-width: 0; } .app-header .b2-brand { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.app-header .mark { width: 34px; height: 34px; flex: 0 0 auto; border: 1px solid rgba(88,166,255,.38); border-radius: 8px; display: grid; place-items: center; background: var(--raised); } .app-header .b2-brand b { font-weight: 700; letter-spacing: .01em; }
.app-header .mark svg { width: 22px; height: 22px; } .b2-logo-img { display: block; }
.brand-copy { min-width: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; } .app-header .b2-proj {
.brand-title { font-weight: 700; font-size: 17px; } display: flex; align-items: center; gap: 5px;
.project-name { color: var(--muted); font-size: 12px; font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; } color: var(--b2-muted); font-size: 13px; font-family: var(--font-mono, ui-monospace, monospace);
.header-spacer { flex: 1; } padding: 4px 10px; border-radius: 8px; border: 1px solid transparent;
.app-header .nav { display: flex; align-items: center; gap: 4px; border: 1px solid var(--border); background: var(--surface); padding: 3px; border-radius: 8px; } max-width: 34vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
.app-header .nav-link { min-height: 34px; display: inline-flex; align-items: center; padding: 0 12px; border-radius: 6px; color: var(--muted); font-size: 13px; text-decoration: none; transition: color 180ms ease, background 180ms ease; } }
.app-header .nav-link:hover, .app-header .nav-link.active { color: var(--text); background: var(--raised); } .app-header .b2-proj:hover { background: rgba(255,255,255,.05); border-color: var(--b2-border); color: #c6d0e8; }
.new-task-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid rgba(88,166,255,.45); background: linear-gradient(180deg, rgba(88,166,255,.20), rgba(88,166,255,.10)); color: var(--text); font: 600 13px/1 var(--font-sans); cursor: pointer; transition: background 160ms ease, transform 120ms ease, box-shadow 160ms ease; } .b2-chev { font-size: 9px; opacity: .7; }
.new-task-btn:hover { background: rgba(88,166,255,.28); box-shadow: 0 4px 16px rgba(88,166,255,.18); } .app-header .b2-nav { display: flex; align-items: center; gap: 2px; margin-left: 8px;
.new-task-btn:active { transform: translateY(1px); } border: 1px solid var(--b2-border); background: var(--b2-surface); padding: 3px; border-radius: 9px; }
.new-task-btn .plus { font-size: 16px; line-height: 1; margin-top: -1px; } .app-header .b2-nav a {
.sse-status { display: inline-flex; align-items: center; gap: 7px; min-width: 116px; min-height: 34px; color: var(--muted); font: 12px/1 var(--font-mono); white-space: nowrap; } min-height: 32px; display: inline-flex; align-items: center;
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,.16); } padding: 0 13px; border-radius: 7px; font-size: 13px; font-weight: 500;
.sse-status.stale .conn-dot { background: var(--status-review); box-shadow: 0 0 0 3px rgba(210,153,34,.14); } color: var(--b2-muted); text-decoration: none; transition: color 160ms ease, background 160ms ease;
.sse-status.down .conn-dot { background: #F85149; box-shadow: 0 0 0 3px rgba(248,81,73,.14); } }
.app-header .b2-nav a:hover { color: var(--b2-text); background: rgba(255,255,255,.05); }
.app-header .b2-nav a.active { color: var(--b2-text); background: rgba(255,255,255,.08); font-weight: 600; }
.b2-hdr-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.b2-btn {
display: inline-flex; align-items: center; gap: 7px;
min-height: 36px; padding: 0 16px; border: 0; border-radius: 9px;
background: linear-gradient(135deg, #6366f1, #8b5cf6);
color: #fff; font: 600 13px/1 var(--font-sans, system-ui, sans-serif); cursor: pointer;
box-shadow: 0 4px 18px rgba(99,102,241,.28);
transition: transform 120ms ease, box-shadow 160ms ease, filter 160ms ease;
}
.b2-btn:hover { filter: brightness(1.1); box-shadow: 0 6px 22px rgba(99,102,241,.38); }
.b2-btn:active { transform: translateY(1px); }
.sse-status { display: inline-flex; align-items: center; gap: 7px; min-width: 116px; min-height: 34px; color: var(--b2-muted); font: 12px/1 var(--font-mono, ui-monospace, monospace); white-space: nowrap; }
.b2-live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--b2-green); animation: b2-ping 2s infinite; }
.sse-status.stale .b2-live-dot { background: var(--b2-amber); animation: none; }
.sse-status.down .b2-live-dot { background: #F85149; animation: none; }
@media (max-width: 680px) { @media (max-width: 680px) {
.app-header { flex-wrap: wrap; gap: 10px 12px; } .app-header { flex-wrap: wrap; gap: 10px 12px; }
.header-spacer { display: none; } .b2-hdr-right { margin-left: auto; }
.app-header .nav { order: 3; width: 100%; } .app-header .b2-nav { order: 3; width: 100%; }
.app-header .nav-link { flex: 1; justify-content: center; } .app-header .b2-nav a { flex: 1; justify-content: center; }
} }`;
}
/** CSS for the shared header + new-task modal + toasts. Include once per page. */
export function appHeaderCss(): string {
return appHeaderOnlyCss() + `
/* ── New-task modal ─────────────────────────────────────────────────── */ /* ── New-task modal ─────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; background: rgba(2,6,18,.62); backdrop-filter: blur(3px); animation: modalFade 140ms ease; } .modal-backdrop { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; background: rgba(2,6,18,.62); backdrop-filter: blur(3px); animation: modalFade 140ms ease; }
.modal-backdrop[hidden] { display: none; } .modal-backdrop[hidden] { display: none; }
@ -366,35 +397,28 @@ export function appHeaderCss(): string {
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }`; @keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }`;
} }
/** The shared header markup: brand, nav, New-task button, live status. */ /** The shared header markup (v2): logo, project cell, nav, New-task, live status. */
export function appHeader(projectName: string, current: HeaderPage): string { export function appHeader(projectName: string, current: HeaderPage): string {
const mark = `<span class="mark" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none"><path d="M5 7.5h8.5a5.5 5.5 0 0 1 0 11H5v-11Z" stroke="#58A6FF" stroke-width="1.8"/><path d="M8.5 5.5h7a4 4 0 0 1 0 8h-7v-8Z" stroke="#22C55E" stroke-width="1.8"/></svg></span>`;
const link = (label: string, path: string, key: HeaderPage) => const link = (label: string, path: string, key: HeaderPage) =>
`<a class="nav-link${current === key ? ' active' : ''}" href="${path}">${label}</a>`; `<a class="${current === key ? 'active' : ''}" href="${path}"${current === key ? ' aria-current="page"' : ''}>${label}</a>`;
return ` return `
<header class="app-header"> <header class="app-header">
<div class="brand"> <span class="b2-brand"><img src="/logo.svg" alt="" width="24" height="24" class="b2-logo-img"><b>agenthub</b></span>
${mark} <span class="b2-proj" title="Projektwechsel kommt mit v3">/ <span id="projectName">${escapeHtml(projectName)}</span>&nbsp;<span class="b2-chev"></span></span>
<div class="brand-copy"> <nav class="b2-nav" aria-label="Primary">
<span class="brand-title">AgentHub</span>
<span class="project-name" id="projectName">${escapeHtml(projectName)}</span>
</div>
</div>
<span class="header-spacer"></span>
<nav class="nav" aria-label="Primary">
${link('Board', '/board', 'board')} ${link('Board', '/board', 'board')}
${link('Team', '/team', 'team')} ${link('Team', '/team', 'team')}
${link('Activity', '/activity', 'activity')} ${link('Activity', '/activity', 'activity')}
${link('Messages', '/messages', 'messages')} ${link('Messages', '/messages', 'messages')}
${link('Decisions', '/decisions', 'decisions')} ${link('Decisions', '/decisions', 'decisions')}
</nav> </nav>
<button class="new-task-btn" id="newTaskBtn" type="button" aria-haspopup="dialog" aria-expanded="false"> <span class="b2-hdr-right">
<span class="plus" aria-hidden="true">+</span> New task <button class="b2-btn" id="newTaskBtn" type="button" aria-haspopup="dialog" aria-expanded="false">+ New task</button>
</button>
<span class="sse-status stale" id="sseStatus"> <span class="sse-status stale" id="sseStatus">
<span class="conn-dot" aria-hidden="true"></span> <span class="b2-live-dot" aria-hidden="true"></span>
<span id="sseLabel">connecting</span> <span id="sseLabel">connecting</span>
</span> </span>
</span>
</header>`; </header>`;
} }

View File

@ -10,7 +10,7 @@ describe('renderBoardHtml (v2)', () => {
expect(html).toContain('id="b2-splash"'); expect(html).toContain('id="b2-splash"');
}); });
it('contains header, kpis, columns and sidebar mount points', () => { it('contains header, kpis, columns and sidebar mount points', () => {
for (const s of ['b2-hdr', 'demo-project', 'id="kpiOpen"', 'id="b2Budget"', 'id="b2Feed"']) { for (const s of ['app-header', 'demo-project', 'id="kpiOpen"', 'id="b2Budget"', 'id="b2Feed"']) {
expect(html).toContain(s); expect(html).toContain(s);
} }
}); });

View File

@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'; import { describe, it, expect } from 'vitest';
import { agentAvatar, designTokensCss, escapeHtml, liveTimerJs, statusPill } from '../src/server/ui-shared.js'; import { agentAvatar, designTokensCss, escapeHtml, liveTimerJs, statusPill, appHeader, appHeaderCss, appHeaderOnlyCss } from '../src/server/ui-shared.js';
describe('ui-shared helpers', () => { describe('ui-shared helpers', () => {
it('designTokensCss returns the dark palette variables', () => { it('designTokensCss returns the dark palette variables', () => {
@ -48,3 +48,32 @@ describe('ui-shared helpers', () => {
expect(js).toContain('claimed'); expect(js).toContain('claimed');
}); });
}); });
describe('appHeader (v2 shared header)', () => {
it('renders logo, project cell, nav links and status mounts', () => {
const h = appHeader('demo', 'team');
expect(h).toContain('/logo.svg');
expect(h).toContain('id="projectName"');
expect(h).toContain('b2-proj');
expect(h).toContain('id="newTaskBtn"');
expect(h).toContain('id="sseStatus"');
for (const path of ['/board', '/team', '/activity', '/messages', '/decisions']) {
expect(h).toContain(`href="${path}"`);
}
});
it('marks the current page active with aria-current', () => {
const team = appHeader('demo', 'team');
expect(team).toContain('active" href="/team" aria-current="page"');
const board = appHeader('demo', 'board');
expect(board).toContain('active" href="/board" aria-current="page"');
expect(board).not.toContain('active" href="/team"');
});
it('escapes the project name', () => {
expect(appHeader('<b>x</b>', 'board')).not.toContain('<b>x</b>');
});
it('appHeaderOnlyCss is a prefix of appHeaderCss', () => {
expect(appHeaderCss().startsWith(appHeaderOnlyCss())).toBe(true);
expect(appHeaderOnlyCss()).toContain('.app-header');
expect(appHeaderCss()).toContain('.modal-backdrop');
});
});