Engineer a dark mode verification harness sampling component snapshots, luminance…
- User
Engineer a dark mode verification harness sampling component snapshots, luminance ratios, and battery impact.
Assistant
Engineer a dark mode verification harness sampling component snapshots, luminance ratios, and battery impact.
The user wants a "dark mode verification harness" that samples:
This is a developer/design system tool - a dashboard or testing interface that helps verify dark mode implementations across components. Let me think about what this would need:
Design Direction:
Key Features:
Visual Aesthetic:
Let me create a comprehensive verification harness:
Components to show:
Features:
Color scheme:
Font choices:
Let me build this out as a comprehensive single-page application.
A professional developer tool for testing dark mode implementations with contrast analysis, component snapshots, and battery impact simulation.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dark Mode Verification Harness</title>
<script src="https://cdn.tailwindcss.com"></script>
<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">
<style>
:root {
--bg: #0a0c10;
--bg-elevated: #12151c;
--bg-card: #181c25;
--fg: #e8eaed;
--fg-muted: #6b7280;
--accent: #00d9ff;
--accent-dim: rgba(0, 217, 255, 0.15);
--success: #22c55e;
--warning: #f59e0b;
--error: #ef4444;
--border: #2a2f3a;
--grid-color: rgba(42, 47, 58, 0.5);
}
.light-mode {
--bg: #f8fafc;
--bg-elevated: #ffffff;
--bg-card: #ffffff;
--fg: #1e293b;
--fg-muted: #64748b;
--accent: #0891b2;
--accent-dim: rgba(8, 145, 178, 0.1);
--success: #16a34a;
--warning: #d97706;
--error: #dc2626;
--border: #e2e8f0;
--grid-color: rgba(226, 232, 240, 0.8);
}
* {
box-sizing: border-box;
}
body {
font-family: 'Space Grotesk', sans-serif;
background-color: var(--bg);
color: var(--fg);
min-height: 100vh;
}
.font-mono {
font-family: 'JetBrains Mono', monospace;
}
.grid-bg {
background-image:
linear-gradient(var(--grid-color) 1px, transparent 1px),
linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
background-size: 24px 24px;
}
.card {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 12px;
}
.glow-accent {
box-shadow: 0 0 20px rgba(0, 217, 255, 0.2);
}
.status-badge {
padding: 2px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.status-pass { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.status-warn { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.status-fail { background: rgba(239, 68, 68, 0.2); color: var(--error); }
.meter-bar {
height: 8px;
border-radius: 4px;
background: var(--border);
overflow: hidden;
}
.meter-fill {
height: 100%;
border-radius: 4px;
transition: width 0.5s ease-out;
}
.component-snapshot {
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.component-snapshot:hover {
transform: translateY(-4px);
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.sample-component {
transition: all 0.3s ease;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes slideIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.animate-in {
animation: slideIn 0.5s ease-out forwards;
}
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
@media (prefers-reduced-motion: reduce) {
.animate-in, .pulse, .component-snapshot {
animation: none;
transition: none;
}
}
.toggle-switch {
width: 44px;
height: 24px;
background: var(--border);
border-radius: 12px;
position: relative;
cursor: pointer;
transition: background 0.3s ease;
}
.toggle-switch.active {
background: var(--accent);
}
.toggle-switch::after {
content: '';
position: absolute;
width: 18px;
height: 18px;
background: var(--fg);
border-radius: 50%;
top: 3px;
left: 3px;
transition: transform 0.3s ease;
}
.toggle-switch.active::after {
transform: translateX(20px);
}
.btn {
padding: 10px 20px;
border-radius: 8px;
font-weight: 500;
transition: all 0.2s ease;
cursor: pointer;
border: none;
}
.btn-primary {
background: var(--accent);
color: var(--bg);
}
.btn-primary:hover {
filter: brightness(1.1);
transform: translateY(-1px);
}
.btn-outline {
background: transparent;
border: 1px solid var(--border);
color: var(--fg);
}
.btn-outline:hover {
border-color: var(--accent);
color: var(--accent);
}
.input-field {
background: var(--bg-elevated);
border: 1px solid var(--border);
border-radius: 8px;
padding: 10px 14px;
color: var(--fg);
transition: border-color 0.2s ease;
}
.input-field:focus {
outline: none;
border-color: var(--accent);
}
:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.scanline {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: repeating-linear-gradient(
0deg,
transparent,
transparent 2px,
rgba(0, 0, 0, 0.03) 2px,
rgba(0, 0, 0, 0.03) 4px
);
pointer-events: none;
}
.battery-animated {
background: linear-gradient(90deg, var(--success) 0%, var(--accent) 100%);
background-size: 200% 100%;
animation: batteryFlow 2s ease infinite;
}
@keyframes batteryFlow {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
</style>
</head>
<body class="grid-bg">
<div class="scanline"></div>
<!-- Header -->
<header class="border-b border-[var(--border)] bg-[var(--bg-elevated)] sticky top-0 z-50 backdrop-blur-sm bg-opacity-90">
<div class="max-w-7xl mx-auto px-4 py-4 flex items-center justify-between">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-[var(--accent-dim)] flex items-center justify-center">
<svg class="w-6 h-6 text-[var(--accent)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"/>
</svg>
</div>
<div>
<h1 class="text-lg font-semibold">Verification Harness</h1>
<p class="text-xs text-[var(--fg-muted)] font-mono">v2.4.1</p>
</div>
</div>
<div class="flex items-center gap-6">
<div class="flex items-center gap-2">
<span class="text-sm text-[var(--fg-muted)]">Preview Mode</span>
<div id="modeToggle" class="toggle-switch" role="switch" aria-checked="false" tabindex="0"></div>
</div>
<button id="runTestsBtn" class="btn btn-primary font-mono text-sm flex items-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
Run Suite
</button>
</div>
</div>
</header>
<main class="max-w-7xl mx-auto px-4 py-8">
<!-- Stats Overview -->
<section class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-8 opacity-0 animate-in">
<div class="card p-5">
<div class="flex items-center justify-between mb-3">
<span class="text-xs text-[var(--fg-muted)] uppercase tracking-wider">Components</span>
<span class="status-badge status-pass">Indexed</span>
</div>
<div class="text-3xl font-bold font-mono" id="componentCount">12</div>
<div class="text-sm text-[var(--fg-muted)] mt-1">Unique snapshots</div>
</div>
<div class="card p-5">
<div class="flex items-center justify-between mb-3">
<span class="text-xs text-[var(--fg-muted)] uppercase tracking-wider">Avg Contrast</span>
<span class="status-badge status-pass" id="contrastBadge">WCAG AA</span>
</div>
<div class="text-3xl font-bold font-mono" id="avgContrast">8.42:1</div>
<div class="text-sm text-[var(--fg-muted)] mt-1">Luminance ratio</div>
</div>
<div class="card p-5">
<div class="flex items-center justify-between mb-3">
<span class="text-xs text-[var(--fg-muted)] uppercase tracking-wider">Battery Save</span>
<span class="status-badge status-pass">Optimal</span>
</div>
<div class="text-3xl font-bold font-mono text-[var(--success)]" id="batterySave">34%</div>
<div class="text-sm text-[var(--fg-muted)] mt-1">Estimated OLED savings</div>
</div>
<div class="card p-5">
<div class="flex items-center justify-between mb-3">
<span class="text-xs text-[var(--fg-muted)] uppercase tracking-wider">Pass Rate</span>
<span class="status-badge" id="passRateBadge">Running</span>
</div>
<div class="text-3xl font-bold font-mono" id="passRate">--</div>
<div class="meter-bar mt-3">
<div class="meter-fill bg-[var(--accent)]" id="passMeter" style="width: 0%"></div>
</div>
</div>
</section>
<!-- Main Grid -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Component Snapshots Panel -->
<div class="lg:col-span-2 card p-6 opacity-0 animate-in stagger-1">
<div class="flex items-center justify-between mb-6">
<h2 class="text-lg font-semibold">Component Snapshots</h2>
<div class="flex gap-2">
<button class="btn-outline btn text-xs font-mono px-3 py-2" id="filterAll">All</button>
<button class="btn-outline btn text-xs font-mono px-3 py-2" id="filterPass">Pass</button>
<button class="btn-outline btn text-xs font-mono px-3 py-2" id="filterFail">Fail</button>
</div>
</div>
<div class="grid grid-cols-2 md:grid-cols-3 gap-4" id="snapshotGrid">
<!-- Snapshots rendered via JS -->
</div>
</div>
<!-- Luminance Analysis Panel -->
<div class="card p-6 opacity-0 animate-in stagger-2">
<h2 class="text-lg font-semibold mb-6">Luminance Ratios</h2>
<div class="space-y-4" id="luminanceList">
<!-- Rendered via JS -->
</div>
<div class="mt-6 pt-6 border-t border-[var(--border)]">
<h3 class="text-sm font-medium mb-3">WCAG Reference</h3>
<div class="space-y-2 text-sm">
<div class="flex justify-between">
<span class="text-[var(--fg-muted)]">AA Normal</span>
<span class="font-mono">4.5:1</span>
</div>
<div class="flex justify-between">
<span class="text-[var(--fg-muted)]">AA Large</span>
<span class="font-mono">3:1</span>
</div>
<div class="flex justify-between">
<span class="text-[var(--fg-muted)]">AAA Normal</span>
<span class="font-mono">7:1</span>
</div>
</div>
</div>
</div>
</div>
<!-- Battery Impact Section -->
<section class="mt-6 card p-6 opacity-0 animate-in stagger-3">
<div class="flex items-center justify-between mb-6">
<h2 class="text-lg font-semibold">Battery Impact Analysis</h2>
<span class="text-sm text-[var(--fg-muted)] font-mono">OLED Power Draw Simulation</span>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
<div>
<div class="flex items-end justify-between mb-4">
<div>
<div class="text-sm text-[var(--fg-muted)] mb-1">Dark Mode</div>
<div class="text-4xl font-bold font-mono text-[var(--success)]" id="darkPower">42<span class="text-lg">mW</span></div>
</div>
<div>
<div class="text-sm text-[var(--fg-muted)] mb-1">Light Mode</div>
<div class="text-4xl font-bold font-mono text-[var(--warning)]" id="lightPower">64<span class="text-lg">m