Here's a thinking process that leads to the suggested HTML page:
-
Analyze the Request:
- Topic: Design-to-code handshake where Storybook stories auto-generate Cypress specs, visual snaps, and accessibility audits.
- Role: FUI (Fictional User Interface) designer from 2077, specializing in Cyberpunk/Hard Sci-Fi style.
- Key Elements: Intricate structure, dark mode, neon glow (cyan/magenta/amber), monospace fonts, HUD layout, decoding text effects, holographic visuals, micro-interactions, breathing elements, Tailwind CSS (simulated via styles), Canvas/Three.js (implied but static HTML preferred; I'll use Canvas for dynamic effects), Glitch shaders.
- Output: A single, self-contained HTML file (no external builds).
- Constraint: No external frameworks (React, Vue, etc.) but I can simulate the look of a modern dev tool using Vanilla JS + CSS. The user asked for a "Design-to-code handshake" system interface.
-
Conceptualization (Cyberpunk Dev Environment):
- Metaphor: A control center for a system that translates design components (Storybook) into testable, visual, and accessible code.
- Visual Style: Dark background (
#050505), heavy grid lines, neon cyan and magenta accents. HUD elements (corners, brackets, progress bars). Monospace text (Courier New or system-ui with adjustments).
- Functional Simulation: I need to show a dashboard where a user selects a component (Story), and the system "auto-generates" the Cyprus specs, Visual Snaps, and Accessibility audits.
- Interactivity:
- Sidebar: List of components (AF-21, BF-44, etc.).
- Main View: Split into three quadrants (Cypress, Visual, Accessibility).
- Action: clicking a component triggers a "decoding" animation, updates status bars, and logs "generation" steps.
- Canvas: A background particle network or data stream to make it feel "alive".
- Glitch effects: On hover or click.
-
Structure the HTML:
<!DOCTYPE html>
<html>
<head>: Styles (Tailwind-like utility classes + custom animations/fonts).
<body>:
- Background canvas (for network effect).
- Overlay container (HUD).
- Header: "SYNTHETIC DESIGN BRIDGE // V.2077"
- Panel 1: Component Selection (Left/Right).
- Panel 2: Live Preview (Center) - showing the Storybook component mockup.
- Panel 3: Metrics/Logs (Bottom).
- Panels for Output generation (Cypress, Visual, A11y).
-
Drafting the CSS (Cyberpunk/Aesthetic):
- Colors:
--neon-cyan: #00f3ff;, --neon-magenta: #ff00ff;, --neon-amber: #ffcc00;, --bg-color: #050505;.
- Fonts:
font-family: 'Courier New', Courier, monospace;.
- Borders: 1px solid with glow. Use
box-shadow for glow.
- Animations:
@keyframes scanline: A line moving down.
@keyframes decode: Letters scrambling (JS will handle actual random characters, but CSS can handle opacity/transforms).
@keyframes pulse: Opacity changes for breathing lights.
-
Implementing the JavaScript Logic:
- Data: An array of "Components" (Button, Modal, Input, Navbar). Each has properties:
id, name, cypressStatus (pending/success/fail), visualStatus, a11yScore.
- State:
selectedComponent.
- Functions:
renderComponentList(): Fill sidebar.
selectComponent(id): Update UI, trigger generation simulation.
simulateGeneration(): Show progress bars filling up, text decoding, status changes.
updateCanvas(): Draw a network of nodes connecting to the mouse (classic sci-fi background).
glitchText(element, finalText): Replace characters randomly then stabilize to final text.
-
Refining the Interaction (The "Handshake"):
- When a user clicks a component:
- Highlight the component in the list.
- Show "INITIATING HANDSHAKE" in the log.
- Process:
CONNECTING TO STORYBOOK..., FETCHING COMPONENT STATE..., GENERATING CYPRESS..., RENDERING VISUAL SNAPS..., RUNNING AXE CORE....
- As steps complete, update the respective panels (progress bars go to 100, icons turn from red to green).
- If A11y score < threshold, flash amber warning.
-
Visual Details (HUD Layout):
- Use absolute positioning for decorative corners.
- Add a "System Time" ticker in top corner.
- Use progress bars that look like "loading" mono-chrome fills.
- Icons: Use SVG shapes (circles, diamonds, chevrons) directly in HTML to avoid external dependencies.
-
Step-by-Step Implementation Plan:
- Step 1: Base CSS & Variables. Set up the dark theme and basic utilities. Implement the CRT/scanline overlay effect.
- Step 2: Shell Structure. Grid layout (CSS Grid) to hold the HUD columns.
- Step 3: Sidebar (Component List). Styling the list items, hover effects (glow).
- Step 4: Center Stage (Preview). A fake visual representation of the component (e.g., a button or a card) that briefly glitches before settling.
- Step 5: Bottom/Right Panels (Status). The three indicators: Cypress, Visual, A11y. Each with a title, a numeric score/progress, and a status text.
- Step 6: JavaScript Logic. Connect the DOM elements to the simulation functions.
- Step 7: The Background Canvas. Implement the "Constellation" effect (nodes connected by lines) to add depth.
- Step 8: Polish. Add sound effects (optional, but maybe overkill for a single file; stick to visual feedback). Ensure glitch effects are snappy. Check contrast.
-
Drafting the Code (Mental or Scratchpad):
- Glitch Function: Need a generic function
scrambleText(element) that runs an interval changing textContent to random chars, then clears interval and sets real text.
- Accessibility: The system itself should do decent contrast (Cyan on Black). Ensure descriptive labels for the simulated functions.
-
Final Code Assembly (incorporating strict constraints):
- Single HTML.
- No external libraries.
- Use semantic tags (
<main>, <aside>, <section>).
- Inline CSS/JS.
-
Self-Correction/Review during drafting:
- Critique: The page might look too messy if I add too many grid lines.
- Fix: Keep the grid lines subtle (low opacity). Use borders mainly on containers.
- Critique: The "decoding" effect might be too heavy if applied to everything.
- Fix: Apply it only to major status updates (e.g., when the percentage changes).
- Requirement Check: "Storybook stories auto-generate Cypress specs, visual snaps, and accessibility audits." -> The UI must reflect this trigger. I will add a "RUN AUTO-GEN" button that becomes active after selection, or just trigger on click. Auto-on-select feels more "systemic".
-
Final Polish: Add a "CRT overlay" div with pointer-events: none and a moving gradient to simulate screen refresh. Add a "boot sequence" on load where the text scrambles to the initial state.
(Self-Correction during coding the background): A simple mesh network drawing on a <canvas> works well. I'll make it react to the mouse position to satisfy "micro-interaction".
(Self-Correction during coding the visual): I need a way to show the "Storybook Story" inside the center panel. I'll create a div that gets populated with a specific HTML structure based on the selected component (e.g., a button, a form field). This visual representation will also have a "glitch" effect when it loads.
- Producing the Output: (Proceeding to generate the HTML string).
- Include
font-family: 'Courier New', monospace.
- Use
border: 1px solid var(--cyan).
- Use
box-shadow: 0 0 5px var(--cyan).
Let's build it.
Here is a complete, self-contained HTML file implementing a "Design-to-Code Handshake" interface in a Cyberpunk/Hard Sci-Fi FUI style.
The interface simulates a system that reads Storybook definitions, auto-generates Cypress tests, captures visual snapshots, and runs accessibility audits using the Axe engine.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SynthBridge // Design-to-Code Handshake</title>
<style>
:root {
--bg-color: #050505;
--primary-cyan: #00f3ff;
--primary-cyan-dim: rgba(0, 243, 255, 0.2);
--primary-magenta: #ff00ff;
--primary-magenta-dim: rgba(255, 0, 255, 0.2);
--primary-amber: #ffcc00;
--primary-amber-dim: rgba(255, 204, 0, 0.2);
--grid-line: rgba(0, 243, 255, 0.05);
--font-mono: 'Courier New', Courier, monospace;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: var(--bg-color);
color: var(--primary-cyan);
font-family: var(--font-mono);
overflow: hidden; /* HUD style, no scroll */
height: 100vh;
width: 100vw;
display: flex;
flex-direction: column;
}
/* CRT Scanline Overlay */
body::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
background-size: 100% 2px, 3px 100%;
pointer-events: none;
z-index: 999;
}
/* Background Canvas */
#bg-canvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
opacity: 0.3;
}
/* Layout Structure */
.hud-container {
position: relative;
z-index: 10;
display: grid;
grid-template-rows: auto 1fr;
height: 100%;
padding: 20px;
gap: 20px;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid var(--primary-cyan-dim);
padding-bottom: 10px;
text-transform: uppercase;
letter-spacing: 2px;
}
.brand {
font-size: 1.2rem;
font-weight: bold;
text-shadow: 0 0 8px var(--primary-cyan);
}
.status-badge {
font-size: 0.8rem;
padding: 4px 8px;
background: var(--primary-cyan-dim);
border: 1px solid var(--primary-cyan);
animation: pulse 2s infinite;
}
.main-grid {
display: grid;
grid-template-columns: 300px 1fr 300px;
gap: 20px;
height: 100%;
}
/* Universal Panel Styles */
.panel {
background: rgba(0, 10, 10, 0.8);
border: 1px solid var(--primary-cyan-dim);
position: relative;
display: flex;
flex-direction: column;
}
.panel::before {
/* Decorative Corner */
content: '';
position: absolute;
top: -1px;
left: -1px;
width: 15px;
height: 15px;
border-top: 2px solid var(--primary-cyan);
border-left: 2px solid var(--primary-cyan);
}
.panel::after {
content: '';
position: absolute;
bottom: -1px;
right: -1px;
width: 15px;
height: 15px;
border-bottom: 2px solid var(--primary-cyan);
border-right: 2px solid var(--primary-cyan);
}
.panel-header {
padding: 8px 12px;
background: var(--primary-cyan-dim);
font-size: 0.9rem;
font-weight: bold;
border-bottom: 1px solid var(--primary-cyan-dim);
display: flex;
justify-content: space-between;
align-items: center;
}
.panel-content {
padding: 15px;
flex: 1;
overflow-y: auto;
position: relative;
}
/* Scrollbar Styling */
.panel-content::-webkit-scrollbar {
width: 6px;
}
.panel-content::-webkit-scrollbar-track {
background: #000;
}
.panel-content::-webkit-scrollbar-thumb {
background: var(--primary-cyan-dim);
}
/* Sidebar (Component List) */
.component-list {
list-style: none;
}
.component-item {
padding: 10px;
border: 1px solid transparent;
margin-bottom: 5px;
cursor: pointer;
transition: all 0.2s;
display: flex;
justify-content: space-between;
align-items: center;
}
.component-item:hover {
background: var(--primary-cyan-dim);
border-color: var(--primary-cyan);
box-shadow: inset 0 0 10px var(--primary-cyan-dim);
}
.component-item.active {
background: var(--primary-cyan-dim);
border-color: var(--primary-cyan);
color: #fff;
text-shadow: 0 0 5px var(--primary-cyan);
}
.status-icon {
width: 10px;
height: 10px;
border-radius: 50%;
background: #333;
box-shadow: 0 0 2px #000;
}
.component-item.active .status-icon {
background: var(--primary-cyan);
box-shadow: 0 0 5px var(--primary-cyan);
}
/* Center Stage (Visualization) */
.preview-area {
display: flex;
flex-direction: column;
height: 100%;
}
.preview-window {
flex: 1;
border: 1px solid var(--primary-magenta-dim);
background: #000;
display: flex;
justify-content: center;
align-items: center;
position: relative;
overflow: hidden;
margin-bottom: 20px;
}
.preview-window::before {
content: "PREVIEW // BITMAP_DUMP";
position: absolute;
top: 5px;
right: 5px;
font-size: 0.7rem;
color: var(--primary-magenta);
opacity: 0.7;
}
/* Simulated Component Inside Preview */
.sim-component {
padding: 20px;
border: 1px solid var(--primary-cyan);
background: rgba(0, 243, 255, 0.05);
transition: transform 0.3s;
}
.sim-btn {
padding: 10px 30px;
background: var(--primary-cyan-dim);
border: 1px solid var(--primary-cyan);
color: #fff;
font-family: var(--font-mono);
cursor: default;
}
.sim-input {
padding: 8px;
background: #111;
border: 1px solid var(--primary-cyan);
color: var(--primary-cyan);
width: 200px;
font-family: var(--font-mono);
}
.log-terminal {
height: 150px;
background: #000;
border-top: 1px solid var(--primary-cyan-dim);
padding: 10px;
font-size: 0.8rem;
overflow-y: hidden; /* Auto scroll via JS */
}
.log-entry {
margin-bottom: 4px;
display: flex;
}
.log-time { color: var(--primary-amber); margin-right: 10px; }
.log-msg { color: var(--primary-cyan); }
.log-msg.error { color: #ff3333; }
.log-msg.success { color: var(--primary-magenta); }
/* Right Panel (Results) */
.metrics-grid {
display: grid;
gap: 15px;
}
.metric-card {
border: 1px solid var(--primary-cyan-dim);
padding: 10px;
background: rgba(0, 20, 20, 0.6);
}
.metric-title {
color: var(--primary-magenta);
font-size: 0.8rem;
margin-bottom: 5px;
text-transform: uppercase;
}
.progress-bar {
height: 20px;
background: #111;
border: 1px solid #333;
margin-bottom: 5px;
position: relative;
}
.progress-fill {
height: 100%;
background: var(--primary-cyan);
width: 0%;
transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
box-shadow: 0 0 8px var(--primary-cyan);
}
.progress-fill.amber { background: var(--primary-amber); box-shadow: 0 0 8px var(--primary-amber); }
.progress-fill.magenta { background: var(--primary-magenta); box-shadow: 0 0 8px var(--primary-magenta); }
.metric-score {
text-align: right;
font-size: 1.2rem;
font-weight: bold;
}
.code-block {
background: #000;
border: 1px solid #333;
padding: 10px;
font-size: 0.75rem;
color: #888;
overflow-x: auto;
white-space: pre-wrap;
margin-top: 10px;
max-height: 100px;
}
/* Animations */
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.glitch {
animation: glitch-anim 0.3s infinite;
color: var(--primary-magenta);
}
@keyframes glitch-anim {
0% { transform: translate(0); }
20% { transform: translate(-2px, 2px); }
40% { transform: translate(-2px, -2px); }
60% { transform: translate(2px, 2px); }
80% { transform: translate(2px, -2px); }
100% { transform: translate(0); }
}
/* Utility */
.text-amber { color: var(--primary-amber); }
.text-magenta { color: var(--primary-magenta); }
.hidden { display: none; }
/* Responsive */
@media (max-width: 1200px) {
.main-grid {
grid-template-columns: 250px 1fr;
}
.right-panel {
grid-column: 2;
grid-row: 2;
}
}
@media (max-width: 768px) {
.main-grid {
grid-template-columns: 1fr;
grid-template-rows: auto 1fr auto;
display: flex;
flex-direction: column;
}
.center-panel, .right-panel {
flex: 1;
min-height: 300px;
}
}
</style>
</head>
<body>
<canvas id="bg-canvas"></canvas>
<div class="hud-container">
<header>
<div class="brand">
<span style="color:var(--primary-magenta)">SYNTH</span>BRIDGE_INTERFACE
</div>
<div class="status-badge">SYSTEM ONLINE // LINKED</div>
<div class="brand" id="clock">00:00:00</div>
</header>
<div class="main-grid">
<!-- Left Panel: Component Selection -->
<aside class="panel left-panel">
<div class="panel-header">
<span>STORYBOOK_INDEX</span>
<span>V.3.4.0</span>
</div>
<div class="panel-content">
<ul class="component-list" id="component-list">
<!-- Populated by JS -->
</ul>
</div>
</aside>
<!-- Center Panel: Preview & Logs -->
<main class="panel center-panel preview-area">
<div class="panel-header">
<span>LIVE RENDER // PRE-VIZ</span>
<span id="active-component-name">NO_SELECTION</span>
</div>
<div class="panel-content" style="flex:1; padding:0; display:flex; flex-direction:column;">
<div class="preview-window" id="preview-container">
<div style="color: #666;">WAITING FOR INPUT STREAM...</div>
</div>
<div class="log-terminal" id="terminal">
<!-- Logs go here -->
</div>
</div>
</main>
<!-- Right Panel: Metrics -->
<aside class="panel right-panel">
<div class="panel-header">
<span>AUTO-GEN RESULTS</span>
<span>ID: <span class="text-amber">847-AX</span></span>
</div>
<div class="panel-content metrics-grid">
<!-- Cypress Spec Generator -->
<div class="metric-card">
<div class="metric-title">
CYPRESS_SPEC_GEN
<span id="cypress-status-icon" class="status-icon" style="float:right; background:#333; width:8px; height:8px;"></span>
</div>
<div class="progress-bar">
<div class="progress-fill" id="cypress-bar"></div>
</div>
<div class="metric-score text-magenta" id="cypress-score">0%</div>
<div class="code-block" id="cypress-code">// Specifications pending...</div>
</div>
<!-- Visual Snapshot -->
<div class="metric-card">
<div class="metric-title">
VISUAL_SNAP
<span id="vis-status-icon" class="status-icon" style="float:right; background:#222; width:8px; height:8px;"></span>
</div>
<div class="progress-bar">
<div class="progress-fill amber" id="vis-bar"></div>
</div>
<div class="metric-score text-amber" id="vis-score">0%</div>
<div class="code-block" id="vis-code">// Diffs: 0</div>
</div>
<!-- Accessibility Audit -->
<div class="metric-card">
<div class="metric-title">
AXE_A11Y_SCAN
<span id="a11y-status-icon" class="status-icon" style="float:right; background:#222; width:8px; height:8px;"></span>
</div>
<div class="progress-bar">
<div class="progress-fill" id="a11y-bar"></div>
</div>
<div class="metric-score" id="a11y-score">--</div>
<div class="code-block" id="a11y-code">// No violations detected</div>
</div>
</div>
</aside>
</div>
</div>
<script>
// --- Configuration & Data ---
const components = [
{ id: 'btn_primary', name: 'BUTTON_PRIMARY', type: 'button', html: '<button class="sim-btn">ACTIVATE</button>' },
{ id: 'btn_secondary', name: 'BUTTON_DISABLED', type: 'button_disabled', html: '<button class="sim-btn" style="opacity:0.5; cursor:not-allowed;">LOCKED</button>' },
{ id: 'input_text', name: 'INPUT_TEXT_FIELD', type: 'input', html: '<input type="text" class="sim-input" placeholder="ENTER_DATA...">' },
{ id: 'card_profile', name: 'PROFILE_CARD', type: 'card', html: `
<div style="border:1px solid #333; padding:15px; width:200px; background:#111;">
<div style="width:50px; height:50px; background:#333; margin:auto;"></div>
<div style="text-align:center; margin-top:10px; color:#aaa;">USER_X92</div>
</div>
` },
{ id: 'nav_header', name: 'NAV_BAR', type: 'nav', html: `
<div style="width:100%; display:flex; justify-content:space-between; border-bottom:1px solid var(--primary-cyan); padding-bottom:5px;">
<span>LOGO</span>
<span style="color:var(--primary-cyan)">HOME | ABOUT | DATA</span>
</div>
` }
];
// --- State ---
let selectedComponent = null;
let isProcessing = false;
// --- DOM Elements ---
const componentListEl = document.getElementById('component-list');
const previewContainer = document.getElementById('preview-container');
const activeComponentNameEl = document.getElementById('active-component-name');
const terminalEl = document.getElementById('terminal');
// Metrics Elements
const cypressBar = document.getElementById('cypress-bar');
const cypressScore = document.getElementById('cypress-score');
const cypressCode = document.getElementById('cypress-code');
const cyStatusIcon = document.getElementById('cypress-status-icon');
const visBar = document.getElementById('vis-bar');
const visScore = document.getElementById('vis-score');
const visCode = document.getElementById('vis-code');
const visStatusIcon = document.getElementById('vis-status-icon');
const a11yBar = document.getElementById('a11y-bar');
const a11yScore = document.getElementById('a11y-score');
const a11yCode = document.getElementById('a11y-code');
const a11yStatusIcon = document.getElementById('a11y-status-icon');
// --- Initialization ---
function init() {
renderList();
startClock();
initCanvas();
window.addEventListener('resize', resizeCanvas);
window.addEventListener('mousemove', handleMouseMove);
}
function renderList() {
componentListEl.innerHTML = '';
components.forEach(comp => {
const li = document.createElement('li');
li.className = 'component-item';
li.innerHTML = `
<span>${comp.name}</span>
<div class="status-icon"></div>
`;
li.onclick = () => selectComponent(comp.id);
li.dataset.id = comp.id;
componentListEl.appendChild(li);
});
}
function selectComponent(id) {
if (isProcessing) return;
// Update UI selection
document.querySelectorAll('.component-item').forEach(item => {
item.classList.remove('active');
if (item.dataset.id === id) item.classList.add('active');
});
selectedComponent = components.find(c => c.id === id);
activeComponentNameEl.textContent = `ID: ${selectedComponent.id.toUpperCase()}`;
// Clear previous metrics
resetMetrics();
// Log
log(`TARGET ACQUIRED: ${selectedComponent.name}`);
log(`CONNECTING TO STORYBOOK NODE...`);
// Start Simulation Sequence
runHandshakeSimulation();
}
function resetMetrics() {
setMetric(cypressBar, 0, '');
setMetric(cypressScore, '0%');
cypressCode.textContent = '// Fetching story definition...';
cyStatusIcon.style.backgroundColor = '#333';
setMetric(visBar, 0, '');
setMetric(visScore, '0%');
visCode.textContent = '// Rendering pixels...';
visStatusIcon.style.backgroundColor = '#222';
setMetric(a11yBar, 0, '');
setMetric(a11yScore, '--');
a11yCode.textContent = '// Scanning DOM...';
a11yStatusIcon.style.backgroundColor = '#222';
}
function setMetric(barEl, score, text) {
if (typeof score === 'number') {
barEl.style.width = score + '%';
} else {
barEl.className = 'progress-fill ' + score; // reset class
}
}
// --- The Core Simulation Logic ---
function runHandshakeSimulation() {
isProcessing = true;
// 1. Update Preview with Glitch
log('INITIALIZING PREVIEW CONTEXT...');
updatePreview(selectedComponent.html, true);
// 2. Sequence: Cypress Gen
simulateProcess(
'CYPRESS_SPEC_GEN',
2000,
(progress) => {
setMetric(cypressBar, progress, '');
cypressScore.textContent = Math.floor(progress) + '%';
if (progress === 100) {
cyStatusIcon.style.backgroundColor = 'var(--primary-cyan)';
cypressCode.textContent = `describe('${selectedComponent.name}', () => { it('renders correctly', () => { cy.get('[data-testid="${selectedComponent.id}"]').should('be.visible'); }); });`;
log('CYPRUS SPEC GENERATED [SUCCESS]', 'success');
}
}
);
// 3. Sequence: Visual Snap (runs in parallel slightly offset)
setTimeout(() => {
simulateProcess(
'VISUAL_SNAP',
2500,
(progress) => {
setMetric(visBar, progress, '');
visScore.textContent = Math.floor(progress) + '%';
if (progress === 100) {
visStatusIcon.style.backgroundColor = 'var(--primary-amber)';
const diff = Math.floor(Math.random() * 5); // random small diff
visCode.textContent = `// Compared: baseline_${selectedComponent.id}.png\n// Diff: ${diff} pixels`;
log('VISUAL SNAPSHOT LOCKED', 'success');
}
}
);
}, 500);
// 4. Sequence: Accessibility (runs last)
setTimeout(() => {
simulateProcess(
'AXE_A11Y_SCAN',
3000,
(progress) => {
setMetric(a11yBar, progress, '');
if (progress < 30) a11yScore.textContent = 'SCANNING...';
else if (progress < 70) a11yScore.textContent = 'ANALYZING DOM...';
else if (progress < 100) a11yScore.textContent = 'AGGREGATING...';
if (progress === 100) {
const score = Math.floor(Math.random() * (100 - 85) + 85); // Random good score 85-100
a11yScore.textContent = score;
a11yStatusIcon.style.backgroundColor = score >= 90 ? 'var(--primary-cyan)' : 'var(--primary-amber)';
a11yCode.textContent = `// Violations: 0\n// Score: ${score}/100`;
log(`ACCESSIBILITY AUDIT COMPLETE. SCORE: ${score}`, score >= 90 ? 'success' : 'text-amber');
}
}
);
}, 1000);
// Reset processing flag after max time
setTimeout(() => {
isProcessing = false;
}, 4000);
}
function simulateProcess(name, duration, callback) {
const start = Date.now();
const interval = setInterval(() => {
const elapsed = Date.now() - start;
const progress = Math.min((elapsed / duration) * 100, 100);
// Add randomness to progress feel like data crunch
const jitter = progress < 100 ? Math.random() * 2 : 0;
callback(progress + jitter);
if (progress >= 100) {
clearInterval(interval);
callback(100);
}
}, 50);
}
// --- Preview Glitch & Decode ---
function updatePreview(htmlString, doGlitch) {
if (doGlitch) {
const originalHtml = htmlString;
let iterations = 0;
const maxIter = 10;
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#@!';
const interval = setInterval(() => {
const scrambled = originalHtml
.split('')
.map((char, index) => {
if (index < iterations * originalHtml.length / maxIter && char !== ' ') {
return chars[Math.floor(Math.random() * chars.length)];
}
return char;
})
.join('');
previewContainer.innerHTML = scrambled;
iterations += 1;
if (iterations >= maxIter) {
clearInterval(interval);
previewContainer.innerHTML = originalHtml;
previewContainer.classList.remove('glitch');
}
}, 30);
previewContainer.classList.add('glitch');
} else {
previewContainer.innerHTML = htmlString;
}
}
// --- Terminal Log ---
function log(msg, type = '') {
const now = new Date();
const timeStr = now.toTimeString().split(' ')[0];
const div = document.createElement('div');
div.className = 'log-entry';
div.innerHTML = `
<span class="log-time">[${timeStr}]</span>
<span class="log-msg ${type}">${msg}</span>
`;
terminalEl.appendChild(div);
terminalEl.scrollTop = terminalEl.scrollHeight;
}
// --- Clock ---
function startClock() {
setInterval(() => {
const now = new Date();
document.getElementById('clock').textContent = now.toISOString().split('T')[1].split('.')[0] + ' UTC';
}, 1000);
}
// --- Canvas Background (Neural Network / Constellation) ---
const canvas = document.getElementById('bg-canvas');
const ctx = canvas.getContext('2d');
let width, height;
let nodes = [];
const nodeCount = 60;
const connectionDistance = 120;
const mouse = { x: null, y: null, radius: 150 };
function initCanvas() {
resizeCanvas();
createNodes();
animateCanvas();
}
function resizeCanvas() {
width = canvas.width = window.innerWidth;
height = canvas.height = window.innerHeight;
}
function createNodes() {
nodes = [];
for (let i = 0; i < nodeCount; i++) {
nodes.push({
x: Math.random() * width,
y: Math.random() * height,
vx: (Math.random() - 0.5) * 0.5,
vy: (Math.random() - 0.5) * 0.5,
size: Math.random() * 2 + 1
});
}
}
function handleMouseMove(e) {
mouse.x = e.clientX;
mouse.y = e.clientY;
}
function animateCanvas() {
ctx.clearRect(0, 0, width, height);
// Draw connections and nodes
ctx.strokeStyle = 'rgba(0, 243, 255, 0.15)';
ctx.lineWidth = 1;
ctx.fillStyle = 'rgba(0, 243, 255, 0.5)';
nodes.forEach((node, i) => {
// Move
node.x += node.vx;
node.y += node.vy;
// Bounce
if (node.x < 0 || node.x > width) node.vx *= -1;
if (node.y < 0 || node.y > height) node.vy *= -1;
// Mouse Interaction (Repel/Attract) - subtle
const dx = mouse.x - node.x;
const dy = mouse.y - node.y;
const dist = Math.sqrt(dx*dx + dy*dy);
if (dist < mouse.radius) {
const force = (mouse.radius - dist) / mouse.radius;
node.x -= dx * force * 0.02;
node.y -= dy * force * 0.02;
}
// Draw connections
for (let j = i + 1; j < nodes.length; j++) {
const node2 = nodes[j];
const dx2 = node.x - node2.x;
const dy2 = node.y - node2.y;
const dist2 = Math.sqrt(dx2*dx2 + dy2*dy2);
if (dist2 < connectionDistance) {
ctx.beginPath();
ctx.moveTo(node.x, node.y);
ctx.lineTo(node2.x, node2.y);
const alpha = 1 - (dist2 / connectionDistance);
ctx.strokeStyle = `rgba(0, 243, 255, ${alpha * 0.2})`;
ctx.stroke();
}
}
// Draw node
ctx.beginPath();
ctx.arc(node.x, node.y, node.size, 0, Math.PI * 2);
ctx.fill();
});
requestAnimationFrame(animateCanvas);
}
// Run
init();
</script>
</body>
</html>