This is a developer tool/dashboard type of application. I need to create a visually striking, functional single-page app that shows:
Let me create a comprehensive, polished implementation.
A developer-focused dashboard for comparing static site builds across versions. I've designed this with a technical/terminal aesthetic, featuring interactive timeline navigation, diff highlighting, and bundle size analytics.
html Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SSG Diff Visualizer</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
mono: ['JetBrains Mono', 'monospace'],
display: ['Space Grotesk', 'sans-serif'],
}
}
}
}
</script>
<style>
:root {
--bg: #0a0e14;
--bg-elevated: #0f1419;
--bg-card: #151b23;
--fg: #e6e6e6;
--fg-muted: #6b7280;
--accent: #00d9ff;
--accent-dim: rgba(0, 217, 255, 0.15);
--success: #10b981;
--success-dim: rgba(16, 185, 129, 0.15);
--danger: #ef4444;
--danger-dim: rgba(239, 68, 68, 0.15);
--warning: #f59e0b;
--warning-dim: rgba(245, 158, 11, 0.15);
--border: rgba(255, 255, 255, 0.08);
}
* { box-sizing: border-box; }
body {
font-family: 'JetBrains Mono', monospace;
background: var(--bg);
color: var(--fg);
min-height: 100vh;
}
.font-display { font-family: 'Space Grotesk', sans-serif; }
/* Background pattern */
.bg-grid {
background-image:
linear-gradient(rgba(0, 217, 255, 0.03) 1px, transparent 1px),
linear-gradient(90deg, rgba(0, 217, 255, 0.03) 1px, transparent 1px);
background-size: 32px 32px;
}
/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-elevated); }
::-webkit-scrollbar-thumb { background: var(--fg-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
/* Animations */
@keyframes fadeInUp {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-glow {
0%, 100% { box-shadow: 0 0 0 0 var(--accent-dim); }
50% { box-shadow: 0 0 20px 4px var(--accent-dim); }
}
.animate-in {
animation: fadeInUp 0.5s ease-out forwards;
opacity: 0;
}
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
@media (prefers-reduced-motion: reduce) {
.animate-in { animation: none; opacity: 1; }
}
/* Timeline */
.timeline-node {
transition: all 0.2s ease;
}
.timeline-node:hover, .timeline-node.active {
transform: scale(1.3);
box-shadow: 0 0 16px var(--accent);
}
.timeline-node.active {
background: var(--accent);
}
/* Diff line styling */
.diff-add { background: var(--success-dim); border-left: 3px solid var(--success); }
.diff-remove { background: var(--danger-dim); border-left: 3px solid var(--danger); }
.diff-change { background: var(--warning-dim); border-left: 3px solid var(--warning); }
/* Chart bars */
.chart-bar {
transition: all 0.3s ease;
transform-origin: bottom;
}
.chart-bar:hover {
filter: brightness(1.2);
}
/* Route card */
.route-card {
transition: all 0.2s ease;
border: 1px solid var(--border);
}
.route-card:hover {
border-color: var(--accent);
background: var(--bg-elevated);
}
/* Tabs */
.tab-btn {
transition: all 0.2s ease;
border-bottom: 2px solid transparent;
}
.tab-btn.active {
color: var(--accent);
border-bottom-color: var(--accent);
}
/* Focus states */
button:focus-visible, [tabindex]:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
/* Stat card glow */
.stat-glow {
position: relative;
}
.stat-glow::before {
content: '';
position: absolute;
inset: -1px;
border-radius: inherit;
padding: 1px;
background: linear-gradient(135deg, var(--accent), transparent 50%);
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
-webkit-mask-composite: xor;
mask-composite: exclude;
}
</style>
</head>
<body class="bg-grid">
<div class="min-h-screen p-4 md:p-6 lg:p-8">
<!-- Header -->
<header class="animate-in mb-8">
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4">
<div>
<h1 class="font-display text-2xl md:text-3xl font-bold tracking-tight" style="color: var(--fg);">
SSG Diff Visualizer
</h1>
<p class="text-sm mt-1" style="color: var(--fg-muted);">
Compare builds across deployments
</p>
</div>
<div class="flex items-center gap-3">
<div class="px-3 py-1.5 rounded text-xs font-medium" style="background: var(--success-dim); color: var(--success);">
<span class="inline-block w-2 h-2 rounded-full mr-2" style="background: var(--success);"></span>
CI Connected
</div>
<button id="refreshBtn" class="px-4 py-2 rounded font-medium text-sm transition-all hover:scale-105"
style="background: var(--accent); color: var(--bg);" aria-label="Refresh data">
Refresh
</button>
</div>
</div>
</header>
<!-- Timeline -->
<section class="animate-in delay-1 mb-8 p-4 rounded-lg" style="background: var(--bg-card); border: 1px solid var(--border);">
<div class="flex items-center justify-between mb-4">
<h2 class="font-display font-semibold text-sm uppercase tracking-wider" style="color: var(--fg-muted);">Build Timeline</h2>
<span id="versionLabel" class="text-xs px-2 py-1 rounded" style="background: var(--accent-dim); color: var(--accent);">
v2.4.0 vs v2.3.9
</span>
</div>
<div id="timeline" class="relative h-16 flex items-center" role="slider" aria-label="Build version timeline" tabindex="0">
<!-- Timeline rendered by JS -->
</div>
</section>
<!-- Stats Overview -->
<section class="animate-in delay-2 grid grid-cols-2 md:grid-cols-4 gap-4 mb-8">
<div class="stat-glow p-4 rounded-lg" style="background: var(--bg-card);">
<p class="text-xs uppercase tracking-wider mb-2" style="color: var(--fg-muted);">Routes Changed</p>
<p class="font-display text-2xl font-bold" id="statRoutes" style="color: var(--fg);">24</p>
<p class="text-xs mt-1" style="color: var(--success);">+3 new</p>
</div>
<div class="stat-glow p-4 rounded-lg" style="background: var(--bg-card);">
<p class="text-xs uppercase tracking-wider mb-2" style="color: var(--fg-muted);">Bundle Delta</p>
<p class="font-display text-2xl font-bold" id="statBundle" style="color: var(--fg);">+12.4 KB</p>
<p class="text-xs mt-1" style="color: var(--danger);">+2.1% increase</p>
</div>
<div class="stat-glow p-4 rounded-lg" style="background: var(--bg-card);">
<p class="text-xs uppercase tracking-wider mb-2" style="color: var(--fg-muted);">A11y Issues</p>
<p class="font-display text-2xl font-bold" id="statA11y" style="color: var(--fg);">-8</p>
<p class="text-xs mt-1" style="color: var(--success);">57% resolved</p>
</div>
<div class="stat-glow p-4 rounded-lg" style="background: var(--bg-card);">
<p class="text-xs uppercase tracking-wider mb-2" style="color: var(--fg-muted);">Build Time</p>
<p class="font-display text-2xl font-bold" id="statBuild" style="color: var(--fg);">1m 24s</p>
<p class="text-xs mt-1" style="color: var(--success);">-12s faster</p>
</div>
</section>
<!-- Tabs -->
<nav class="animate-in delay-3 flex gap-6 mb-6 border-b" style="border-color: var(--border);" role="tablist">
<button class="tab-btn active py-3 px-1 text-sm font-medium" role="tab" aria-selected="true" data-tab="routes">
Route Snapshots
</button>
<button class="tab-btn py-3 px-1 text-sm font-medium" style="color: var(--fg-muted);" role="tab" aria-selected="false" data-tab="a11y">
Accessibility
</button>
<button class="tab-btn py-3 px-1 text-sm font-medium" style="color: var(--fg-muted);" role="tab" aria-selected="false" data-tab="bundles">
Bundle Sizes
</button>
</nav>
<!-- Tab Content -->
<main class="animate-in delay-4">
<!-- Routes Tab -->
<div id="routesTab" class="tab-content">
<div class="flex flex-col md:flex-row gap-4 mb-6">
<div class="flex-1 relative">
<input type="text" id="routeSearch" placeholder="Search routes..."
class="w-full px-4 py-2.5 rounded-lg text-sm"
style="background: var(--bg-card); border: 1px solid var(--border); color: var(--fg);"
aria-label="Search routes">
<svg class="absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4" style="color: var(--fg-muted);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
</div>
<select id="routeFilter" class="px-4 py-2.5 rounded-lg text-sm"
style="background: var(--bg-card); border: 1px solid var(--border); color: var(--fg);"
aria-label="Filter routes by change type">
<option value="all">All Changes</option>
<option value="added">Added</option>
<option value="removed">Removed</option>
<option value="modified">Modified</option>
</select>
</div>
<div id="routesList" class="space-y-3">
<!-- Routes rendered by JS -->
</div>
</div>
<!-- A11y Tab -->
<div id="a11yTab" class="tab-content hidden">
<div class="grid md:grid-cols-2 gap-6">
<div class="p-4 rounded-lg" style="background: var(--bg-card); border: 1px solid var(--border);">
<h3 class="font-display font-semibold mb-4 flex items-center gap-2">
<span class="w-3 h-3 rounded-full" style="background: var(--danger);"></span>
New Issues
</h3>
<div id="a11yNewIssues" class="space-y-3">
<!-- Issues rendered by JS -->
</div>
</div>
<div class="p-4 rounded-lg" style="background: var(--bg-card); border: 1px solid var(--border);">
<h3 class="font-display font-semibold mb-4 flex items-center gap-2">
<span class="w-3 h-3 rounded-full" style="background: var(--success);"></span>
Resolved Issues
</h3>
<div id="a11yResolved" class="space-y-3">
<!-- Issues rendered by JS -->
</div>
</div>
</div>
<!-- A11y Score Chart -->
<div class="mt-6 p-4 rounded-lg" style="background: var(--bg-card); border: 1px solid var(--border);">
<h3 class="font-display font-semibold mb-4">Accessibility Score Trend</h3>
<div id="a11yChart" class="h-48 flex items-end gap-2">
<!-- Chart rendered by JS -->
</div>
</div>
</div>
<!-- Bundles Tab -->
<div id="bundlesTab" class="tab-content hidden">
<div class="grid md:grid-cols-3 gap-4 mb-6">
<div class="p-4 rounded-lg" style="background: var(--bg-card); border: 1px solid var(--border);">
<p class="text-xs uppercase tracking-wider mb-2" style="color: var(--fg-muted);">Total Size</p>
<p class="font-display text-xl font-bold">847.2 KB</p>
<div class="mt-2 h-2 rounded-full overflow-hidden" style="background: var(--bg-elevated);">
<div class="h-full rounded-full" style="width: 68%; background: var(--accent);"></div>
</div>
<p class="text-xs mt-1" style="color: var(--fg-muted);">68% of budget</p>
</div>
<div class="p-4 rounded-lg" style="background: var(--bg-card); border: 1px solid var(--border);">
<p class="text-xs uppercase tracking-wider mb-2" style="color: var(--fg-muted);">Gzip Size</p>
<p class="font-display text-xl font-bold">268.4 KB</p>
<div class="mt-2 h-2 rounded-full overflow-hidden" style="background: var(--bg-elevated);">
<div class="h-full rounded-full" style="width: 42%; background: var(--success);"></div>
</div>
<p class="text-xs mt-1" style="color: var(--fg-muted);">42% of budget</p>
</div>
<div class="p-4 rounded-lg" style="background: var(--bg-card); border: 1px solid var(--border);">
<p class="text-xs uppercase tracking-wider mb-2" style="color: var(--fg-muted);">Chunk Count</p>
<p class="font-display text-xl font-bold">12</p>
<div class="mt-2 h-2 rounded-full overflow-hidden" style="background: var(--bg-elevated);">
<div class="h-full rounded-full" style="width: 80%; background: var(--warning);"></div>
</div>
<p class="text-xs mt-1" style="color: var(--fg-muted);">Optimal: 10</p>
</div>
</div>
<!-- Bundle Breakdown -->
<div class="p-4 rounded-lg" style="background: var(--bg-card); border: 1px solid var(--border);">
<h3 class="font-display font-semibold mb-4">Bundle Breakdown</h3>
<div id="bundleChart" class="space-y-3">
<!-- Chart rendered by JS -->
</div>
</div>
</div>
</main>
</div>
<script>
// === DATA ===
const builds = [
{ id: 'v2.4.0', date: '2024-01-15', routes: 156, bundle: 847.2, a11y: 6 },
{ id: 'v2.3.9', date: '2024-01-12', routes: 153, bundle: 834.8, a11y: 14 },
{ id: 'v2.3.8', date: '2024-01-08', routes: 151, bundle: 842.1, a11y: 18 },
{ id: 'v2.3.7', date: '2024-01-03', routes: 148, bundle: 839.5, a11y: 22 },
{ id: 'v2.3.6', date: '2023-12-28', routes: 145, bundle: 831.2, a11y: 25 },
{ id: 'v2.3.5', date: '2023-12-20', routes: 142, bundle: 828.0, a11y: 31 },
{ id: 'v2.3.4', date: '2023-12-15', routes: 140, bundle: 822.4, a11y: 35 },
];
const routes = [
{ path: '/', type: 'modified', changes: 12, htmlDiff: '+24 -8', status: '200 OK' },
{ path: '/products', type: 'modified', changes: 45, htmlDiff: '+156 -32', status: '200 OK' },
{ path: '/products/new-arrivals', type: 'added', changes: 0, htmlDiff: '+312', status: '201 New' },
{ path: '/about', type: 'modified', changes: 3, htmlDiff: '+8 -5', status: '200 OK' },
{ path: '/blog', type: 'modified', changes: 28, htmlDiff: '+89 -12', status: '200 OK' },
{ path: '/blog/deprecated-post', type: 'removed', changes: 0, htmlDiff: '-245', status: '410 Gone' },
{ path: '/contact', type: 'modified', changes: 7, htmlDiff: '+18 -4', status: '200 OK' },
{ path: '/api/docs', type: 'added', changes: 0, htmlDiff: '+567', status: '201 New' },
];
const a11yIssues = {
new: [
{ route: '/products', issue: 'Missing skip navigation link', severity: 'serious', wcag: '2.4.1' },
{ route: '/blog', issue: 'Image missing alt text', severity: 'critical', wcag: '1.1.1' },
{ route: '/contact', issue: 'Form field missing label', severity: 'serious', wcag: '3.3.2' },
],
resolved: [
{ route: '/', issue: 'Insufficient color contrast', severity: 'serious', wcag: '1.4.3' },
{ route: '/about', issue: 'Heading order skipped', severity: 'moderate', wcag: '1.3.1' },
{ route: '/products', issue: 'Keyboard trap in modal', severity: 'critical', wcag: '2.1.2' },
{ route: '/products', issue: 'Focus not visible', severity: 'serious', wcag: '2.4.7' },
{ route: '/blog', issue: 'Link purpose unclear', severity: 'moderate', wcag: '2.4.4' },
{ route: '/contact', issue: 'Missing ARIA labels', severity: 'serious', wcag: '4.1.2' },
{ route: '/contact', issue: 'No error suggestion', severity: 'moderate', wcag: '3.3.3' },
{ route: '/api/docs', issue: 'Missing language attr', severity: 'moderate', wcag: '3.1.1' },
]
};
const bundles = [
{ name: 'main.js', size: 245.6, delta: +4.2 },
{ name: 'vendor.js', size: 312.4, delta: +8.1 },
{ name: 'components.js', size: 89.3, delta: -2.4 },
{ name: 'utils.js', size: 34.2, delta: +0.8 },
{ name: 'styles.css', size: 98.4, delta: +1.7 },
{ name: 'polyfills.js', size: 67.3, delta: 0 },
];
// === STATE ===
let selectedBuild = 0;
let compareBuild = 1;
let currentTab = 'routes';
// === RENDER FUNCTIONS ===
function renderTimeline() {
const container = document.getElementById('timeline');
if (!container) return;
container.innerHTML = '';
const line = document.createElement('div');
line.className = 'absolute top-1/2 left-0 right-0 h-0.5 -translate-y-1/2';
line.style.background = 'var(--border)';
container.appendChild(line);
builds.forEach((build, i) => {
const node = document.createElement('button');
node.className = `timeline-node relative z-10 w-4 h-4 rounded-full cursor-pointer ${i === selectedBuild ? 'active' : ''}`;
node.style.background = i === selectedBuild ? 'var(--accent)' : i === compareBuild ? 'var(--warning)' : 'var(--fg-muted)';
node.style.marginLeft = i === 0 ? '0' : `${100 / (builds.length - 1)}%`;
node.setAttribute('aria-label', `Build ${build.id}`);
node.setAttribute('role', 'slider');
const tooltip = document.createElement('div');
tooltip.className = 'absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 rounded text-xs whitespace-nowrap opacity-0 transition-opacity pointer-events-none';
tooltip.style.background = 'var(--bg-elevated)';
tooltip.style.border = '1px solid var(--border)';
tooltip.innerHTML = `<strong>${build.id}</strong><br>${build.date}`;
node.appendChild(tooltip);
node.addEventListener('mouseenter', () => tooltip.style.opacity = '1');
node.addEventListener('mouseleave', () => tooltip.style.opacity = '0');
node.addEventListener('click', () => selectBuild(i));
container.appendChild(node);
});
}
function selectBuild(index) {
if (index === selectedBuild) return;
compareBuild = selectedBuild;
selectedBuild = index;
const label = document.getElementById('versionLabel');
if (label) {
label.textContent = `${builds[selectedBuild].id} vs ${builds[compareBuild].id}`;
}
renderTimeline();
updateStats();
}
function updateStats() {
const current = builds[selectedBuild];
const previous = builds[compareBuild];
const routeDiff = current.routes - previous.routes;
const bundleDiff = current.bundle - previous.bundle;
const a11yDiff = previous.a11y - current.a11y;
const routesEl = document.getElementById('statRoutes');
const bundleEl = document.getElementById('statBundle');
const a11yEl = document.getElementById('statA11y');
if (routesEl) routesEl.textContent = Math.abs(routeDiff);
if (bundleEl) bundleEl.textContent = `${bundleDiff >= 0 ? '+' : ''}${bundleDiff.toFixed(1)} KB`;
if (a11yEl) a11yEl.textContent = a11yDiff >= 0 ? `-${a11yDiff}` : `+${Math.abs(a11yDiff)}`;
}
function renderRoutes(filter = 'all', search = '') {
const container = document.getElementById('routesList');
if (!container) return;
container.innerHTML = '';
const filtered = routes.filter(r => {
const matchesFilter = filter === 'all' || r.type === filter;
const matchesSearch = r.path.toLowerCase().includes(search.toLowerCase());
return matchesFilter && matchesSearch;
});
filtered.forEach((route, i) => {
const card = document.createElement('div');
card.className = 'route-card rounded-lg overflow-hidden';
card.style.background = 'var(--bg-card)';
card.style.animationDelay = `${i * 0.05}s`;
const typeColor = {
added: 'var(--success)',
removed: 'var(--danger)',
modified: 'var(--warning)'
}[route.type];
card.innerHTML = `
<div class="p-4 cursor-pointer" tabindex="0" role="button" aria-expanded="false">
<div class="flex items-center justify-between">
<div class="flex items-center gap-3">
<span class="w-2 h-2 rounded-full" style="background: ${typeColor};"></span>
<code class="text-sm font-medium">${route.path}</code>
<span class="text-xs px-2 py-0.5 rounded" style="background: var(--bg-elevated); color: var(--fg-muted);">
${route.type}
</span>
</div>
<div class="flex items-center gap-4">
<span class="text-xs" style="color: var(--success);">${route.htmlDiff.split(' ')[0]}</span>
${route.htmlDiff.split(' ')[1] ? `<span class="text-xs" style="color: var(--danger);">${route.htmlDiff.split(' ')[1]}</span>` : ''}
<svg class="w-4 h-4 transition-transform expand-icon" style="color: var(--fg-muted);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
</svg>
</div>
</div>
</div>
<div class="route-details hidden px-4 pb-4">
<div class="pt-2 border-t" style="border-color: var(--border);">
<div class="grid grid-cols-3 gap-4 mt-3 text-xs">
<div>
<span style="color: var(--fg-muted);">Status</span>
<p class="mt-1 font-medium" style="color: ${route.status.startsWith('2') ? 'var(--success)' : 'var(--warning)'};">${route.status}</p>
</div>
<div>
<span style="color: var(--fg-muted);">Changes</span>
<p class="mt-1 font-medium">${route.changes || 'N/A'}</p>
</div>
<div>
<span style="color: var(--fg-muted);">HTML Diff</span>
<p class="mt-1 font-medium">${route.htmlDiff}</p>
</div>
</div>
<div class="mt-4 p-3 rounded font-mono text-xs" style="background: var(--bg-elevated);">
<div class="diff-add px-2 py-1 mb-1">+ <span style="color: var(--success);"><section class="new-feature"></span></div>
<div class="diff-add px-2 py-1 mb-1">+ <span style="color: var(--success);"><h2>What's New</h2></span></div>
<div class="diff-remove px-2 py-1 mb-1">- <span style="color: var(--danger);"><div class="deprecated-banner"></span></div>
<div class="diff-change px-2 py-1">~ <span style="color: var(--warning);"><p>Updated content...</p></span></div>
</div>
</div>
</div>
`;
const header = card.querySelector('[role="button"]');
const details = card.querySelector('.route-details');
const icon = card.querySelector('.expand-icon');
header.addEventListener('click', () => {
const isExpanded = !details.classList.contains('hidden');
details.classList.toggle('hidden');
icon.style.transform = isExpanded ? '' : 'rotate(180deg)';
header.setAttribute('aria-expanded', !isExpanded);
});
header.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
header.click();
}
});
container.appendChild(card);
});
if (filtered.length === 0) {
container.innerHTML = `
<div class="text-center py-12" style="color: var(--fg-muted);">
<p>No routes found matching your criteria</p>
</div>
`;
}
}
function renderA11y() {
const newContainer = document.getElementById('a11yNewIssues');
const resolvedContainer = document.getElementById('a11yResolved');
if (newContainer) {
newContainer.innerHTML = a11yIssues.new.map(issue => `
<div class="p-3 rounded" style="background: var(--danger-dim); border: 1px solid var(--danger);">
<div class="flex items-start justify-between gap-2">
<div>
<code class="text-xs">${issue.route}</code>
<p class="text-sm mt-1">${issue.issue}</p>
</div>
<span class="text-xs px-2 py-0.5 rounded whitespace-nowrap" style="background: var(--bg-elevated);">
WCAG ${issue.wcag}
</span>
</div>
<div class="mt-2">
<span class="text-xs px-2 py-0.5 rounded" style="background: ${issue.severity === 'critical' ? 'var(--danger)' : issue.severity === 'serious' ? 'var(--warning)' : 'var(--fg-muted)'}; color: var(--bg);">
${issue.severity}
</span>
</div>
</div>
`).join('') || '<p class="text-sm" style="color: var(--fg-muted);">No new issues</p>';
}
if (resolvedContainer) {
resolvedContainer.innerHTML = a11yIssues.resolved.map(issue => `
<div class="p-3 rounded" style="background: var(--success-dim); border: 1px solid var(--success);">
<div class="flex items-start justify-between gap-2">
<div>
<code class="text-xs">${issue.route}</code>
<p class="text-sm mt-1 line-through" style="color: var(--fg-muted);">${issue.issue}</p>
</div>
<svg class="w-5 h-5 flex-shrink-0" style="color: var(--success);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
</svg>
</div>
</div>
`).join('') || '<p class="text-sm" style="color: var(--fg-muted);">No resolved issues</p>';
}
// A11y trend chart
const chart = document.getElementById('a11yChart');
if (chart) {
const maxIssues = Math.max(...builds.map(b => b.a11y));
chart.innerHTML = [...builds].reverse().map((build, i) => {
const height = Math.max(5, (build.a11y / maxIssues) * 100);
const isCurrentOrCompare = i === builds.length - 1 - selectedBuild || i === builds.length - 1 - compareBuild;
return `
<div class="flex-1 flex flex-col items-center gap-2">
<div class="w-full flex-1 flex items-end">
<div class="chart-bar w-full rounded-t" style="height: ${height}%; background: ${isCurrentOrCompare ? 'var(--accent)' : 'var(--fg-muted)'};"></div>
</div>
<span class="text-xs" style="color: var(--fg-muted);">${build.id.split('.')[1]}</span>
</div>
`;
}).join('');
}
}
function renderBundles() {
const chart = document.getElementById('bundleChart');
if (!chart) return;
const maxSize = Math.max(...bundles.map(b => b.size));
chart.innerHTML = bundles.map(bundle => `
<div class="flex items-center gap-4">
<code class="w-32 text-sm truncate">${bundle.name}</code>
<div class="flex-1 h-6 rounded overflow-hidden" style="background: var(--bg-elevated);">
<div class="chart-bar h-full rounded flex items-center justify-end pr-2"
style="width: ${(bundle.size / maxSize) * 100}%; background: ${bundle.delta > 5 ? 'var(--danger)' : bundle.delta > 0 ? 'var(--warning)' : bundle.delta < 0 ? 'var(--success)' : 'var(--accent)'};">
<span class="text-xs font-medium" style="color: var(--bg);">${bundle.size} KB</span>
</div>
</div>
<span class="w-16 text-right text-sm font-medium" style="color: ${bundle.delta > 0 ? 'var(--danger)' : bundle.delta < 0 ? 'var(--success)' : 'var(--fg-muted)'};">
${bundle.delta >= 0 ? '+' : ''}${bundle.delta} KB
</span>
</div>
`).join('');
}
// === EVENT HANDLERS ===
function initTabs() {
const tabs = document.querySelectorAll('.tab-btn');
const tabContents = document.querySelectorAll('.tab-content');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
const targetTab = tab.dataset.tab;
tabs.forEach(t => {
t.classList.remove('active');
t.style.color = 'var(--fg-muted)';
t.setAttribute('aria-selected', 'false');
});
tab.classList.add('active');
tab.style.color = '';
tab.setAttribute('aria-selected', 'true');
tabContents.forEach(content => {
content.classList.add('hidden');
});
const targetContent = document.getElementById(`${targetTab}Tab`);
if (targetContent) {
targetContent.classList.remove('hidden');
}
currentTab = targetTab;
// Render content for the active tab
if (targetTab === 'routes') renderRoutes();
if (targetTab === 'a11y') renderA11y();
if (targetTab === 'bundles') renderBundles();
});
});
}
function initSearch() {
const searchInput = document.getElementById('routeSearch');
const filterSelect = document.getElementById('routeFilter');
if (searchInput) {
searchInput.addEventListener('input', (e) => {
const filter = filterSelect ? filterSelect.value : 'all';
renderRoutes(filter, e.target.value);
});
}
if (filterSelect) {
filterSelect.addEventListener('change', (e) => {
const search = searchInput ? searchInput.value : '';
renderRoutes(e.target.value, search);
});
}
}
function initRefresh() {
const btn = document.getElementById('refreshBtn');
if (btn) {
btn.addEventListener('click', () => {
btn.disabled = true;
btn.textContent = 'Refreshing...';
setTimeout(() => {
btn.disabled = false;
btn.textContent = 'Refresh';
renderRoutes();
renderA11y();
renderBundles();
}, 1000);
});
}
}
// === INITIALIZATION ===
document.addEventListener('DOMContentLoaded', () => {
renderTimeline();
renderRoutes();
initTabs();
initSearch();
initRefresh();
// Keyboard navigation for timeline
const timeline = document.getElementById('timeline');
if (timeline) {
timeline.addEventListener('keydown', (e) => {
if (e.key === 'ArrowLeft' && selectedBuild < builds.length - 1) {
selectBuild(selectedBuild + 1);
} else if (e.key === 'ArrowRight' && selectedBuild > 0) {
selectBuild(selectedBuild - 1);
}
});
}
});
</script>
</body>
</html>