improve UI
This commit is contained in:
4 files changed
+34
-8
No files matched your search
@@ -83,7 +83,8 @@ function render() {
|
|||||||
|
|
||||||
const seconds = controller.time();
|
const seconds = controller.time();
|
||||||
byId('clock').textContent = `${String(Math.floor(seconds / 60)).padStart(2, '0')}:${String(seconds % 60).padStart(2, '0')}`;
|
byId('clock').textContent = `${String(Math.floor(seconds / 60)).padStart(2, '0')}:${String(seconds % 60).padStart(2, '0')}`;
|
||||||
byId('controller-screen').textContent = controller.render();
|
const screenView = document.querySelector('input[name="screen-view"]:checked').value;
|
||||||
|
byId('controller-screen').textContent = screenView === 'configured' ? controller.render_timing() : controller.render();
|
||||||
byId('signal-summary').textContent = green.length ? `Green: ${green.join(' / ')}`
|
byId('signal-summary').textContent = green.length ? `Green: ${green.join(' / ')}`
|
||||||
: yellow.length ? `Yellow: ${yellow.join(' / ')}`
|
: yellow.length ? `Yellow: ${yellow.join(' / ')}`
|
||||||
: clearing ? 'Red clearance · all red' : 'Startup · all red';
|
: clearing ? 'Red clearance · all red' : 'Startup · all red';
|
||||||
@@ -172,6 +173,7 @@ try {
|
|||||||
byId('lcd-toggle').addEventListener('change', () => {
|
byId('lcd-toggle').addEventListener('change', () => {
|
||||||
byId('controller-screen').classList.toggle('lcd-mode', byId('lcd-toggle').checked);
|
byId('controller-screen').classList.toggle('lcd-mode', byId('lcd-toggle').checked);
|
||||||
});
|
});
|
||||||
|
for (const el of document.querySelectorAll('input[name="screen-view"]')) el.addEventListener('change', render);
|
||||||
for (const phase of phases) {
|
for (const phase of phases) {
|
||||||
document.querySelector(`[data-call="${phase.id}"]`).addEventListener('click', () => {
|
document.querySelector(`[data-call="${phase.id}"]`).addEventListener('click', () => {
|
||||||
controller.call(phase.id);
|
controller.call(phase.id);
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" style="display:none">
|
||||||
|
<symbol id="chip" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<rect x="6" y="6" width="12" height="12" rx="1"/>
|
||||||
|
<path d="M9 1v3M12 1v3M15 1v3M9 20v3M12 20v3M15 20v3M1 9h3M1 12h3M1 15h3M20 9h3M20 12h3M20 15h3"/>
|
||||||
|
</symbol>
|
||||||
|
<symbol id="gitea" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<circle cx="6" cy="6" r="2.5"/>
|
||||||
|
<circle cx="6" cy="18" r="2.5"/>
|
||||||
|
<circle cx="18" cy="12" r="2.5"/>
|
||||||
|
<path d="M6 8.5v7M8.3 7.3 15.7 10.7M8.3 16.7 15.7 13.3"/>
|
||||||
|
</symbol>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 702 B |
+15
-7
@@ -101,7 +101,13 @@
|
|||||||
|
|
||||||
<details class="panel mb-3" open>
|
<details class="panel mb-3" open>
|
||||||
<summary class="h6 mb-0">Controller display</summary>
|
<summary class="h6 mb-0">Controller display</summary>
|
||||||
<div class="d-flex justify-content-end mt-2">
|
<div class="d-flex align-items-center justify-content-between flex-wrap gap-2 mt-2">
|
||||||
|
<div class="btn-group btn-group-sm" role="group" aria-label="Controller display view">
|
||||||
|
<input type="radio" class="btn-check" name="screen-view" id="view-live" value="live" autocomplete="off" checked>
|
||||||
|
<label class="btn btn-outline-secondary" for="view-live">Live</label>
|
||||||
|
<input type="radio" class="btn-check" name="screen-view" id="view-configured" value="configured" autocomplete="off">
|
||||||
|
<label class="btn btn-outline-secondary" for="view-configured">Configured</label>
|
||||||
|
</div>
|
||||||
<div class="form-check form-switch mb-0">
|
<div class="form-check form-switch mb-0">
|
||||||
<input class="form-check-input" type="checkbox" role="switch" id="lcd-toggle">
|
<input class="form-check-input" type="checkbox" role="switch" id="lcd-toggle">
|
||||||
<label class="form-check-label small" for="lcd-toggle">LCD display</label>
|
<label class="form-check-label small" for="lcd-toggle">LCD display</label>
|
||||||
@@ -129,15 +135,17 @@
|
|||||||
</form>
|
</form>
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<footer class="d-flex justify-content-between gap-3 small text-secondary pb-2">
|
<footer class="d-flex align-items-center justify-content-between gap-3 small text-secondary pb-2">
|
||||||
<span>Fixed pairs: 1/5 → 2/6 → 3/7 → 4/8</span>
|
<span>Fixed pairs: 1/5 → 2/6 → 3/7 → 4/8</span>
|
||||||
<svg class="icon" aria-hidden="true"><use href="/icons.svg#chip" /></svg>
|
<div class="d-flex align-items-center gap-2">
|
||||||
|
<svg class="icon" aria-hidden="true"><use href="./icons.svg#chip" /></svg>
|
||||||
<span>Rust/WebAssembly demo</span>
|
<span>Rust/WebAssembly demo</span>
|
||||||
<span class="dot">·</span>
|
<span class="dot" aria-hidden="true">·</span>
|
||||||
<a href="https://git.sowinski.dev/SowinskiBraeden/traffic-lights" target="_blank" rel="noreferrer">
|
<a class="d-inline-flex align-items-center gap-1" href="https://git.sowinski.dev/SowinskiBraeden/traffic-lights" target="_blank" rel="noreferrer">
|
||||||
<svg class="icon" aria-hidden="true"><use href="/icons.svg#gitea" /></svg>
|
<svg class="icon" aria-hidden="true"><use href="./icons.svg#gitea" /></svg>
|
||||||
Source
|
Source
|
||||||
</a>
|
</a>
|
||||||
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
</main>
|
</main>
|
||||||
<script type="module" src="./app.js"></script>
|
<script type="module" src="./app.js"></script>
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ body { background: #f5f5f5; color: #212529; }
|
|||||||
.timing-table input { width: 84px; }
|
.timing-table input { width: 84px; }
|
||||||
.clearance-input { width: 110px; }
|
.clearance-input { width: 110px; }
|
||||||
summary { cursor: pointer; }
|
summary { cursor: pointer; }
|
||||||
|
.icon { width: 14px; height: 14px; flex: none; }
|
||||||
|
.dot { opacity: .5; }
|
||||||
|
footer a { color: inherit; text-decoration: none; }
|
||||||
|
footer a:hover { color: #212529; text-decoration: underline; }
|
||||||
#controller-screen { background: #f3f4f5; border: 1px solid #ced4da; padding: 1rem; font-size: .8rem; line-height: 1.6; white-space: pre; overflow-x: auto; }
|
#controller-screen { background: #f3f4f5; border: 1px solid #ced4da; padding: 1rem; font-size: .8rem; line-height: 1.6; white-space: pre; overflow-x: auto; }
|
||||||
|
|
||||||
#controller-screen.lcd-mode {
|
#controller-screen.lcd-mode {
|
||||||
|
|||||||