refactor: modularize into ES6 modules

Split monolithic index.html into:
- js/constants.js - gate config, colors, dimensions
- js/state.js     - shared application state
- js/gates.js     - evaluation logic, port geometry
- js/renderer.js  - canvas drawing
- js/waveform.js  - GTKWave-style signal viewer
- js/simulation.js - clock tick engine
- js/events.js    - mouse, keyboard, UI handlers
- js/app.js       - entry point
- css/style.css   - all styles
This commit is contained in:
Jose Luis Montañes
2026-03-19 22:00:02 +01:00
parent aa97b37f0a
commit 7409a96cf1
11 changed files with 1028 additions and 967 deletions

208
css/style.css Normal file
View File

@@ -0,0 +1,208 @@
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Segoe UI', system-ui, sans-serif;
background: #0a0a0f;
color: #e0e0e0;
overflow: hidden;
height: 100vh;
}
/* ==================== Toolbar ==================== */
#toolbar {
position: fixed;
top: 0; left: 0; right: 0;
height: 48px;
background: #12121a;
border-bottom: 1px solid #2a2a3a;
display: flex;
align-items: center;
padding: 0 12px;
gap: 6px;
z-index: 100;
}
#toolbar .logo {
font-weight: 700;
font-size: 15px;
color: #00e599;
margin-right: 12px;
}
.gate-btn {
padding: 5px 12px;
background: #1a1a2e;
border: 1px solid #2a2a3a;
border-radius: 6px;
color: #ccc;
cursor: pointer;
font-size: 12px;
font-weight: 600;
transition: all 0.15s;
user-select: none;
}
.gate-btn:hover { background: #252540; border-color: #00e599; color: #fff; }
.gate-btn.input-btn { border-color: #3388ff; }
.gate-btn.input-btn:hover { border-color: #55aaff; }
.gate-btn.clock-btn { border-color: #ff44aa; }
.gate-btn.clock-btn:hover { border-color: #ff66cc; }
.gate-btn.output-btn { border-color: #ff8833; }
.gate-btn.output-btn:hover { border-color: #ffaa55; }
.separator { width: 1px; height: 24px; background: #2a2a3a; margin: 0 6px; }
.toolbar-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.action-btn {
padding: 5px 10px;
background: transparent;
border: 1px solid #333;
border-radius: 6px;
color: #888;
cursor: pointer;
font-size: 11px;
transition: all 0.15s;
}
.action-btn:hover { border-color: #ff4444; color: #ff4444; }
.action-btn.help-btn:hover { border-color: #00e599; color: #00e599; }
.action-btn.sim-btn { border-color: #ff44aa; color: #ff44aa; }
.action-btn.sim-btn:hover { background: #ff44aa22; }
.action-btn.sim-btn.active { background: #ff44aa33; border-color: #ff66cc; color: #ff66cc; }
/* ==================== Canvas ==================== */
#canvas {
position: fixed;
top: 48px; left: 0; right: 0; bottom: 0;
cursor: default;
}
/* ==================== Waveform Panel ==================== */
#waveform-panel {
display: none;
position: fixed;
left: 0; right: 0; bottom: 0;
height: 220px;
background: #0c0c14;
border-top: 2px solid #00e599;
z-index: 90;
flex-direction: column;
}
#waveform-panel.visible { display: flex; }
#wave-toolbar {
display: flex;
align-items: center;
padding: 4px 12px;
gap: 8px;
background: #10101a;
border-bottom: 1px solid #1a1a2a;
height: 32px;
flex-shrink: 0;
}
#wave-toolbar span.wave-title {
font-size: 12px;
font-weight: 700;
color: #00e599;
margin-right: 8px;
}
.wave-btn {
padding: 3px 10px;
background: #1a1a2e;
border: 1px solid #2a2a3a;
border-radius: 4px;
color: #aaa;
cursor: pointer;
font-size: 11px;
font-weight: 600;
transition: all 0.15s;
}
.wave-btn:hover { border-color: #00e599; color: #fff; }
.wave-btn.active { background: #00e59933; border-color: #00e599; color: #00e599; }
.wave-btn.record { border-color: #ff4444; }
.wave-btn.record.active { background: #ff444433; border-color: #ff4444; color: #ff4444; }
.wave-info { margin-left: auto; font-size: 11px; color: #555; }
#wave-container { display: flex; flex: 1; overflow: hidden; }
#wave-labels {
width: 100px;
flex-shrink: 0;
overflow-y: auto;
background: #0e0e18;
border-right: 1px solid #1a1a2a;
}
.wave-label {
height: 30px;
display: flex;
align-items: center;
padding: 0 8px;
font-size: 11px;
font-weight: 600;
border-bottom: 1px solid #111;
color: #888;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.wave-label.input-label { color: #3388ff; }
.wave-label.output-label { color: #ff8833; }
.wave-label.gate-label { color: #00e599; }
#wave-canvas { flex: 1; cursor: crosshair; }
/* ==================== Help Modal ==================== */
#help-modal {
display: none;
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background: rgba(0,0,0,0.7);
z-index: 200;
justify-content: center;
align-items: center;
}
#help-modal.visible { display: flex; }
#help-content {
background: #12121a;
border: 1px solid #2a2a3a;
border-radius: 12px;
padding: 24px;
max-width: 520px;
width: 90%;
max-height: 80vh;
overflow-y: auto;
}
#help-content h2 { color: #00e599; margin-bottom: 12px; font-size: 18px; }
#help-content h3 { color: #ff44aa; margin: 12px 0 8px; font-size: 14px; }
#help-content p, #help-content li { color: #aaa; font-size: 13px; line-height: 1.5; margin-bottom: 6px; }
#help-content ul { padding-left: 20px; }
#help-content kbd {
background: #1a1a2e;
border: 1px solid #333;
border-radius: 4px;
padding: 1px 5px;
font-size: 11px;
color: #ddd;
}
#help-close {
margin-top: 12px;
padding: 6px 18px;
background: #00e599;
border: none;
border-radius: 6px;
color: #000;
font-weight: 600;
cursor: pointer;
}
/* ==================== Resize Handle ==================== */
#wave-resize {
position: absolute;
top: -4px; left: 0; right: 0;
height: 8px;
cursor: ns-resize;
z-index: 91;
}