R This tab: title, health, four tiles, tidy folds

The circuit name is the panel's title, edited in place, with where it is
used below. One line says whether all is good or how many problems
there are; inputs, outputs, transistors and delay sit in tiles. The rest
folds away with plain titles: truth table, as a component (fields one
under another), transistors (name, count × each, total), unused
components (only when there are any) and tools. The tabs are a
segmented control with the hide button beside it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Fabian @ Blax Software 2026-10-22 20:53:43 +02:00
parent c1b70a937f
commit 6398381550
3 changed files with 381 additions and 110 deletions

View File

@ -4059,11 +4059,9 @@ table.board {
gap: 6px;
width: 100%;
padding: 9px 14px;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--muted);
font-size: 12.5px;
font-weight: 600;
color: rgb(230 237 243 / 0.82);
text-align: left;
}
@ -4081,7 +4079,10 @@ table.board {
}
.fold-note {
max-width: 55%;
flex-shrink: 0;
max-width: 45%;
color: var(--muted);
font-size: 11px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@ -4666,3 +4667,260 @@ table.board {
.table-pane .truth {
margin-top: 4px;
}
/* ── Panel heads: segmented tabs on the left, a title on the right ── */
.panel-head,
.sel-panel-head {
display: flex;
align-items: center;
gap: 6px;
height: 48px;
flex-shrink: 0;
padding: 0 8px 0 10px;
border-bottom: 1px solid var(--border);
}
.seg-tabs {
display: flex;
flex: 1;
gap: 2px;
padding: 3px;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 9px;
}
.seg-tabs button {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
height: 28px;
border-radius: 6px;
font-size: 12px;
font-weight: 600;
color: var(--muted);
}
.seg-tabs button:hover {
color: var(--text);
}
.seg-tabs button.active {
background: var(--panel-2);
color: var(--text);
box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
}
.seg-tabs button.task:not(.active) {
color: var(--lamp);
}
.seg-tabs .badge {
min-width: 18px;
padding: 0 5px;
border-radius: 999px;
background: rgb(76 194 255 / 0.16);
color: var(--accent);
font-family: var(--font-mono);
font-size: 10px;
line-height: 16px;
}
.seg-tabs .badge.warn {
background: rgb(232 162 58 / 0.18);
color: #e8a23a;
}
/* ── This: the circuit you are in ───────────────────────────────── */
.inspector section.this-head {
padding: 14px 14px 16px;
}
.title-input {
width: calc(100% + 12px);
margin: -4px -6px 0;
padding: 3px 6px;
border: 1px solid transparent;
border-radius: 6px;
background: transparent;
color: var(--text);
font-size: 17px;
font-weight: 700;
letter-spacing: -0.01em;
outline: none;
}
.title-input:hover {
border-color: var(--border);
}
.title-input:focus {
border-color: var(--accent);
background: var(--panel-2);
}
.this-sub {
margin: 2px 0 12px;
font-size: 12px;
color: var(--muted);
}
.this-sub a {
color: var(--accent);
}
.health {
display: flex;
align-items: center;
gap: 8px;
padding: 7px 10px;
border-radius: 8px;
font-size: 12.5px;
font-weight: 600;
color: var(--on);
background: rgb(61 220 132 / 0.08);
}
.health.warn {
color: #e8a23a;
background: rgb(232 162 58 / 0.1);
}
.health.error {
color: #ff7a7a;
background: rgb(255 122 122 / 0.1);
}
.health-notes {
display: flex;
align-items: center;
gap: 5px;
font-size: 11.5px;
font-weight: 500;
color: var(--muted);
cursor: pointer;
}
.this-head .issue-list {
margin-top: 6px;
}
.tiles {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 6px;
margin-top: 12px;
}
.tile {
display: flex;
flex-direction: column;
align-items: flex-start;
min-width: 0;
padding: 8px 10px;
border: 1px solid var(--border);
border-radius: 8px;
background: var(--panel-2);
text-align: left;
}
button.tile:hover {
border-color: rgb(76 194 255 / 0.5);
}
.tile-label {
font-size: 11px;
color: var(--muted);
}
.tile-value {
font-size: 17px;
font-weight: 700;
font-variant-numeric: tabular-nums;
line-height: 1.3;
}
.tile-note {
font-size: 10.5px;
color: var(--muted);
}
.inspector section.folds {
padding: 0 14px;
border-bottom: 0;
}
.folds .fold:first-child {
border-top: 0;
}
.folds .fold:last-of-type {
margin-bottom: 0;
border-bottom: 1px solid var(--border);
}
.fold-head > .grow {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.cost-list li {
display: flex;
align-items: center;
gap: 10px;
margin: 0 -8px;
padding: 5px 8px;
border-radius: 6px;
cursor: pointer;
}
.cost-list li:hover {
background: var(--panel-2);
}
.cost-name {
display: flex;
flex: 1;
flex-direction: column;
min-width: 0;
font-size: 12.5px;
}
.cost-each {
font-size: 11px;
color: var(--muted);
font-variant-numeric: tabular-nums;
}
.cost-total {
font-size: 12.5px;
font-weight: 700;
font-variant-numeric: tabular-nums;
}
.cost-list li.cost-sum {
margin-top: 4px;
padding-top: 8px;
border-top: 1px solid var(--border);
border-radius: 0;
cursor: default;
}
.cost-list li.cost-sum:hover {
background: none;
}
.unused-list li {
display: flex;
align-items: center;
gap: 6px;
padding: 3px 0;
font-size: 12.5px;
}
.unused-list a {
color: var(--accent);
}

View File

@ -1,5 +1,7 @@
<script setup lang="ts">
import { TRANSISTORS_PER_NAND } from '~/lib/logic/analyze'
// "This": the circuit you are in. Its name and health on top, four numbers,
// then everything else folded away.
import { shortCount, TRANSISTORS_PER_NAND } from '~/lib/logic/analyze'
import { transistorBreakdown } from '~/lib/logic/bulk'
import { chipPins } from '~/lib/logic/geometry'
import { unusedComponents } from '~/lib/logic/check'
@ -47,10 +49,11 @@ function toggleFace(e: Event) {
// ── Problems ────────────────────────────────────────────────────────
const LEVEL_ICON = { error: 'lucide:circle-x', warn: 'lucide:triangle-alert', info: 'lucide:info' } as const
const showInfo = ref(false)
const problems = computed(() => ed.issues.value.filter(i => i.level !== 'info'))
const worst = computed<'error' | 'warn' | 'ok'>(() => (problems.value.some(i => i.level === 'error') ? 'error' : problems.value.length ? 'warn' : 'ok'))
const shownIssues = computed(() => ed.issues.value.filter(i => showInfo.value || i.level !== 'info'))
const infoCount = computed(() => ed.issues.value.filter(i => i.level === 'info').length)
const unused = computed(() => unusedComponents(ed.project.value).filter(d => d.id !== def.value.id))
const showUnused = ref(false)
const confirmRemove = ref<string | null>(null)
const confirmDelete = ref(false)
@ -58,11 +61,32 @@ watch(() => def.value.id, () => (confirmDelete.value = false))
</script>
<template>
<section class="problems">
<div class="problems-head">
<h3>Check</h3>
<span v-if="!shownIssues.length" class="ok"><Icon name="lucide:circle-check" class="size-4" /> {{ infoCount ? 'No problems' : 'All good' }}</span>
<label v-if="infoCount" class="check ml-auto"><input v-model="showInfo" type="checkbox" /> Notes ({{ infoCount }})</label>
<section class="this-head">
<input
ref="nameInput"
v-model="def.name"
class="title-input"
title="Rename this circuit"
spellcheck="false"
@change="ed.commit(false)"
@keydown.enter="($event.target as HTMLInputElement).blur()"
/>
<p class="this-sub">
<template v-if="users.length">
Used in
<template v-for="(u, i) in users" :key="u.id">
<a href="#" @click.prevent="ed.open(u.id)">{{ u.name }}</a><template v-if="i < users.length - 1">, </template>
</template>
</template>
<template v-else>{{ def.id === ed.mainId.value ? 'The main circuit' : 'Not used in another circuit' }}</template>
</p>
<div class="health" :class="worst">
<Icon :name="worst === 'ok' ? 'lucide:circle-check' : LEVEL_ICON[worst]" class="size-4 shrink-0" />
<span class="grow">{{ worst === 'ok' ? 'All good' : `${problems.length} ${problems.length === 1 ? 'problem' : 'problems'}` }}</span>
<label v-if="infoCount" class="health-notes" title="Show notes too: things that work but may not be meant">
<input v-model="showInfo" type="checkbox" /> {{ infoCount }} {{ infoCount === 1 ? 'note' : 'notes' }}
</label>
</div>
<ul v-if="shownIssues.length" class="issue-list">
<li v-for="(i, k) in shownIssues.slice(0, 40)" :key="k">
@ -73,54 +97,33 @@ watch(() => def.value.id, () => (confirmDelete.value = false))
</li>
</ul>
<p v-if="shownIssues.length > 40" class="hint">and {{ shownIssues.length - 40 }} more</p>
<template v-if="unused.length">
<button class="section-toggle mt-2" @click="showUnused = !showUnused">
<Icon :name="showUnused ? 'lucide:chevron-down' : 'lucide:chevron-right'" class="size-4" />
Not used in another circuit ({{ unused.length }})
</button>
<template v-if="showUnused">
<p class="hint">Circuits you work in directly show up here too. Delete only what you don't need.</p>
<ul class="issue-list">
<li v-for="d in unused" :key="d.id" class="unused-row">
<a href="#" class="grow truncate" @click.prevent="ed.open(d.id)">{{ d.name }}</a>
<template v-if="confirmRemove === d.id">
<button class="btn-sm danger" @click="ed.removeComponent(d.id), (confirmRemove = null)">Delete</button>
<button class="btn-sm" @click="confirmRemove = null">Keep</button>
</template>
<button v-else class="icon-btn" title="Delete this component" @click="confirmRemove = d.id"><Icon name="lucide:trash-2" class="size-3.5" /></button>
</li>
</ul>
</template>
</template>
</section>
<section>
<label class="field">
<span>Circuit name</span>
<input ref="nameInput" v-model="def.name" @change="ed.commit(false)" @keydown.enter="($event.target as HTMLInputElement).blur()" />
</label>
<dl class="stats">
<dt>Pins</dt>
<dd>
<a href="#" title="List and rename them" @click.prevent="ed.panelTab.value = 'pins'">{{ pins.inputs.length }} in, {{ pins.outputs.length }} out</a>
</dd>
<dt>NAND gates</dt>
<dd>{{ ed.circuitStats.value.nands.toLocaleString() }}</dd>
<dt title="CMOS: 4 per NAND gate, at every depth">Transistors</dt>
<dd>{{ total.toLocaleString() }}</dd>
<dt>{{ ed.circuitStats.value.sequential ? 'Memory' : 'Delay' }}</dt>
<dd>{{ ed.circuitStats.value.sequential ? 'yes (feedback loops)' : `${ed.circuitStats.value.delay} gates` }}</dd>
</dl>
<p v-for="err in ed.errors.value" :key="err" class="result fail">
<Icon name="lucide:triangle-alert" class="size-4 shrink-0" /> {{ err }}
</p>
<p v-if="users.length" class="hint">
Used in
<template v-for="(u, i) in users" :key="u.id">
<a href="#" @click.prevent="ed.open(u.id)">{{ u.name }}</a><template v-if="i < users.length - 1">, </template>
</template>
</p>
<div class="tiles">
<button class="tile" title="List and rename them" @click="ed.panelTab.value = 'pins'">
<span class="tile-label">Inputs</span>
<span class="tile-value">{{ pins.inputs.length }}</span>
</button>
<button class="tile" title="List and rename them" @click="ed.panelTab.value = 'pins'">
<span class="tile-label">Outputs</span>
<span class="tile-value">{{ pins.outputs.length }}</span>
</button>
<div class="tile" title="CMOS: 4 per NAND gate, at every depth">
<span class="tile-label">Transistors</span>
<span class="tile-value">{{ total.toLocaleString() }}</span>
<span class="tile-note">{{ ed.circuitStats.value.nands.toLocaleString() }} NAND</span>
</div>
<div class="tile" :title="ed.circuitStats.value.sequential ? 'It has feedback loops, so it can hold state' : 'Longest path from an input to an output'">
<span class="tile-label">{{ ed.circuitStats.value.sequential ? 'Memory' : 'Delay' }}</span>
<span class="tile-value">{{ ed.circuitStats.value.sequential ? 'Yes' : ed.circuitStats.value.delay }}</span>
<span class="tile-note">{{ ed.circuitStats.value.sequential ? 'feedback loops' : 'gates deep' }}</span>
</div>
</div>
</section>
<section class="folds">
<EditorFold id="circuit-table" title="Truth table">
<EditorTestPane part="table" />
</EditorFold>
@ -130,22 +133,20 @@ watch(() => def.value.id, () => (confirmDelete.value = false))
<span>Description</span>
<textarea v-model="def.description" rows="2" placeholder="What does it do?" @change="ed.commit(false)" />
</label>
<div class="sel-row">
<label class="field grow">
<label class="field">
<span>Drawn as</span>
<select v-model="def.symbol" @change="ed.commit(false)">
<option v-for="s in SYMBOLS" :key="s.value" :value="s.value">{{ s.label }}</option>
</select>
</label>
<label class="field grow">
<span>Group</span>
<label class="field">
<span>Group in the parts list</span>
<input v-model="def.group" list="groups" placeholder="My components" @change="ed.commit(false)" />
<datalist id="groups">
<option v-for="g in groupNames" :key="g" :value="g" />
</datalist>
</label>
</div>
<label v-if="hasFace" class="check">
<label v-if="hasFace" class="check mb-3">
<input type="checkbox" :checked="def.face !== false" @change="toggleFace" />
Show its lamps and displays on the box
</label>
@ -154,28 +155,38 @@ watch(() => def.value.id, () => (confirmDelete.value = false))
</button>
</EditorFold>
<EditorFold id="circuit-transistors" title="Where the transistors are" :note="total ? total.toLocaleString() : ''">
<EditorFold id="circuit-transistors" title="Transistors" :note="total ? shortCount(total) : ''">
<p v-if="!breakdown.length" class="hint">No gates here yet. Switches, lamps, displays and cables need no transistors.</p>
<table
v-else
class="cost"
title="Everything is built from NAND gates; a CMOS NAND has 4 transistors (2 in parallel to the supply, 2 in series to ground), so it is 4 per NAND inside, at every depth"
>
<tbody>
<tr v-for="l in breakdown" :key="l.key" title="Select these parts" @click="ed.selectOnly(l.ids)">
<td class="what">{{ l.count }} × {{ l.name }}</td>
<td class="num">{{ l.each.toLocaleString() }} each</td>
<td class="num strong">{{ l.total.toLocaleString() }}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Total</td>
<td class="num">{{ (total / TRANSISTORS_PER_NAND).toLocaleString() }} NAND</td>
<td class="num strong">{{ total.toLocaleString() }}</td>
</tr>
</tfoot>
</table>
<ul v-else class="cost-list">
<li v-for="l in breakdown" :key="l.key" title="Select these parts" @click="ed.selectOnly(l.ids)">
<span class="cost-name">
<span class="truncate">{{ l.name }}</span>
<span class="cost-each">{{ l.count }} × {{ l.each.toLocaleString() }}</span>
</span>
<span class="cost-total">{{ l.total.toLocaleString() }}</span>
</li>
<li class="cost-sum">
<span class="cost-name">
<span>Total</span>
<span class="cost-each">{{ (total / TRANSISTORS_PER_NAND).toLocaleString() }} NAND × 4</span>
</span>
<span class="cost-total">{{ total.toLocaleString() }}</span>
</li>
</ul>
</EditorFold>
<EditorFold v-if="unused.length" id="circuit-unused" title="Unused components" :note="String(unused.length)">
<p class="hint">Not placed in any other circuit. Circuits you work in directly show up here too, so delete only what you don't need.</p>
<ul class="unused-list">
<li v-for="d in unused" :key="d.id">
<a href="#" class="grow truncate" @click.prevent="ed.open(d.id)">{{ d.name }}</a>
<template v-if="confirmRemove === d.id">
<button class="btn-sm danger" @click="ed.removeComponent(d.id), (confirmRemove = null)">Delete</button>
<button class="btn-sm" @click="confirmRemove = null">Keep</button>
</template>
<button v-else class="icon-btn" title="Delete this component" @click="confirmRemove = d.id"><Icon name="lucide:trash-2" class="size-3.5" /></button>
</li>
</ul>
</EditorFold>
<EditorFold id="circuit-tools" title="Tools">

View File

@ -36,10 +36,8 @@ watch(
<template>
<aside class="inspector">
<nav class="itabs" role="tablist">
<button class="collapse-btn" title="Hide this panel ([)" @click="ed.togglePanel(false)">
<Icon name="lucide:panel-left-close" class="size-4" />
</button>
<div class="panel-head">
<nav class="seg-tabs" role="tablist">
<button
v-for="t in tabs"
:key="t.id"
@ -54,6 +52,10 @@ watch(
<span v-if="t.badge" class="badge" :class="{ warn: t.warn }">{{ t.badge }}</span>
</button>
</nav>
<button class="icon-btn" title="Hide this panel ([)" @click="ed.togglePanel(false)">
<Icon name="lucide:panel-left-close" class="size-4" />
</button>
</div>
<div class="scroll">
<template v-if="ed.panelTab.value === 'circuit'">
<EditorTestPane part="task" />