R bottom bar as wide as the top bar; Logic shows every gate; Space opens a search for parts and actions

The parts bar sits under the top bar at the same width, pinned parts on
the left (the wheel scrolls them when they do not fit), search on the
right. Logic lists NAND and every component drawn as a gate, pinned or
not. A tap on Space opens the search box at the mouse with the recent
parts and common actions (new component, find, truth table, fit, print,
…); Space held while dragging still moves the view.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Fabian @ Blax Software 2026-10-23 12:43:08 +02:00
parent 821f468748
commit 8300712a21
6 changed files with 223 additions and 46 deletions

View File

@ -3372,7 +3372,7 @@ kbd {
.quick-add {
position: fixed;
z-index: 60;
width: 300px;
width: 340px;
padding-bottom: 6px;
border: 1px solid #2d3745;
border-radius: 10px;
@ -3385,6 +3385,25 @@ kbd {
cursor: pointer;
}
.quick-list {
max-height: min(420px, 60vh);
overflow-y: auto;
scrollbar-width: thin;
}
.quick-head {
padding: 8px 12px 2px;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.07em;
text-transform: uppercase;
color: var(--muted);
}
.quick-add kbd {
flex-shrink: 0;
}
/* ── Title screen ───────────────────────────────────────────────── */
.brand {
padding: 4px 8px 4px 4px;
@ -4228,14 +4247,14 @@ table.board {
}
/* ── Bottom bar: parts by kind, like Figma's toolbar ────────────── */
/* Same width and place as the top bar, whatever panels are open. */
.bottom-dock {
position: absolute;
left: 12px;
right: 12px;
left: var(--bar-inset);
right: var(--bar-inset);
bottom: 14px;
z-index: 20;
display: flex;
justify-content: center;
container-type: inline-size;
pointer-events: none;
}
@ -4245,11 +4264,10 @@ table.board {
.bottom-bar {
display: flex;
justify-content: space-between;
align-items: center;
gap: 2px;
max-width: 100%;
overflow-x: auto;
scrollbar-width: none;
gap: 6px;
width: 100%;
padding: 5px;
background: rgb(26 33 43 / 0.96);
border: 1px solid var(--border);
@ -5123,3 +5141,31 @@ button.tile:hover {
transition: none;
}
}
/* Pinned parts on the left, kinds of parts in the middle, search on the right. */
.bb-group {
display: flex;
align-items: center;
gap: 2px;
min-width: 0;
}
.bb-group.pinned {
flex: 0 1 auto;
overflow-x: auto;
scrollbar-width: none;
}
.bb-group:not(.pinned) {
flex-shrink: 0;
}
.bb-group.end {
justify-content: flex-end;
}
@media (max-width: 820px) {
.bottom-dock {
bottom: calc(40% + 14px);
}
}

View File

@ -42,10 +42,10 @@ watch(
<EditorRail v-else />
<main class="stage">
<EditorCanvas />
<EditorBottomBar />
</main>
<EditorSelectionPanel v-if="hasSelection" />
<EditorToolbar />
<EditorBottomBar />
</div>
</template>
<Transition name="fade">

View File

@ -60,6 +60,13 @@ function onWheel(e: WheelEvent) {
e.preventDefault()
el.scrollLeft += e.deltaY
}
/** Pinned parts that do not fit: the wheel scrolls them sideways too. */
function sideways(e: WheelEvent) {
const el = e.currentTarget as HTMLElement
if (el.scrollWidth <= el.clientWidth || Math.abs(e.deltaX) > Math.abs(e.deltaY)) return
e.preventDefault()
el.scrollLeft += e.deltaY
}
function page(dir: number) {
strip.value?.scrollBy({ left: dir * strip.value.clientWidth * 0.8, behavior: 'smooth' })
}
@ -117,7 +124,6 @@ function endDrag() {
open.value = null
}
watch([open, compTab, () => compGroup.value?.defs.length], () => nextTick(measure))
/** Which button the part being placed belongs to, to show it as active. */
const activeCat = computed(() => {
@ -129,6 +135,11 @@ const activeCat = computed(() => {
})
const group = computed(() => BASIC_GROUPS.find(g => g.name === open.value))
/** Components that belong with a kind of part: gates (drawn as one, or in the Gates group) under Logic. */
const groupComps = computed(() =>
open.value === 'Logic' ? ed.project.value.components.filter(d => d.group?.trim() === 'Gates' || (d.symbol && d.symbol !== 'box')) : [],
)
watch([open, compTab, () => compGroup.value?.defs.length, () => groupComps.value.length], () => nextTick(measure))
const connectors = computed(() => ed.project.value.connectors ?? [])
const portsOk = computed(() => ed.canPlaceKind('portin'))
// Pinned parts sit on the bar; a pinned component this project lacks is left out.
@ -174,6 +185,25 @@ onBeforeUnmount(() => window.removeEventListener('keydown', onKey, true))
<Icon :name="isPinned(p.kind) ? 'lucide:pin-off' : 'lucide:pin'" class="size-3.5" />
</button>
</div>
<div v-for="d in groupComps" :key="d.id" class="part-slot">
<button
class="part-tile"
:class="{ blocked: !placeable(d), active: ed.placing.value?.chip === d.id }"
:title="d.id === ed.def.value.id ? 'You are editing this one' : d.description || ''"
:draggable="placeable(d)"
@click="pick('chip', d.id)"
@dragstart="dragStart($event, 'chip', d.id)"
@dragend="endDrag"
>
<span class="part-art"><EditorPartThumb kind="chip" :chip="d.id" /></span>
<span class="part-name">{{ d.name }}</span>
<span v-if="d.id === ed.def.value.id" class="part-meta">editing</span>
<span v-else-if="ed.transistors(d.id)" class="part-meta">{{ shortCount(ed.transistors(d.id)) }} transistors</span>
</button>
<button class="pin-btn" :class="{ on: isPinned('chip', d) }" :title="isPinned('chip', d) ? 'Unpin from the bar' : 'Pin to the bar'" @click="togglePin('chip', d)">
<Icon :name="isPinned('chip', d) ? 'lucide:pin-off' : 'lucide:pin'" class="size-3.5" />
</button>
</div>
</div>
<button v-if="edges.right" class="strip-arrow right" title="Scroll right" @click="page(1)"><Icon name="lucide:chevron-right" class="size-4" /></button>
</div>
@ -261,7 +291,7 @@ onBeforeUnmount(() => window.removeEventListener('keydown', onKey, true))
</Transition>
<nav class="bottom-bar" aria-label="Parts" @pointerleave="leave">
<template v-if="shown.length">
<div class="bb-group pinned" @wheel="sideways">
<button
v-for="p in shown"
:key="p.pin"
@ -279,9 +309,9 @@ onBeforeUnmount(() => window.removeEventListener('keydown', onKey, true))
<Icon v-if="!named(p)" :name="p.icon" class="size-[18px]" />
<span v-else>{{ p.name }}</span>
</button>
<span class="bar-sep" />
</template>
<button
</div>
<div class="bb-group">
<button
v-for="c in cats"
:key="c.id"
class="bar-btn"
@ -292,11 +322,14 @@ onBeforeUnmount(() => window.removeEventListener('keydown', onKey, true))
>
<Icon :name="c.icon" class="size-[18px]" />
<span class="bar-label">{{ c.label }}</span>
</button>
<span class="bar-sep" />
<button class="bar-btn" title="Find a part (/)" @click="ed.partSearch.value++">
<Icon name="lucide:search" class="size-[18px]" />
</button>
</button>
</div>
<div class="bb-group end">
<button class="bar-btn" title="Find a part or an action (Space or /)" @click="ed.partSearch.value++">
<Icon name="lucide:search" class="size-[18px]" />
<kbd class="bar-label">Space</kbd>
</button>
</div>
</nav>
</div>
</template>

View File

@ -423,6 +423,8 @@ type Drag =
const drag = ref<Drag | null>(null)
const spaceDown = ref(false)
/** Space pressed and let go quickly, without moving the view: opens the search box at the mouse. */
let spaceTap: { at: number } | null = null
let lastClick = { id: '', t: 0 }
function isDoubleClick(id: string) {
@ -446,6 +448,7 @@ function onPointerDown(e: PointerEvent) {
const w = toWorld(e)
const v = view.value
if (e.button === 1 || e.button === 2 || (e.button === 0 && spaceDown.value)) {
spaceTap = null
menu.value = null
drag.value = { kind: 'pan', sx: e.clientX, sy: e.clientY, vx: v.x, vy: v.y, menu: e.button === 2 ? { target: e.target as Element, at: w } : undefined }
root.value!.setPointerCapture(e.pointerId)
@ -1023,6 +1026,7 @@ function onKey(e: KeyboardEvent) {
nudge(dx * step, dy * step)
} else if (e.key === ' ') {
e.preventDefault()
if (!e.repeat) spaceTap = { at: performance.now() }
spaceDown.value = true
} else if (e.key === 'Enter' && ed.selection.value.length === 1) {
const n = nodeMap.value.get(ed.selection.value[0]!)
@ -1035,7 +1039,12 @@ function onKey(e: KeyboardEvent) {
}
function onKeyUp(e: KeyboardEvent) {
if (e.key === ' ') spaceDown.value = false
if (e.key === ' ') {
spaceDown.value = false
// A tap, not a hold for moving the view: the search box with recent parts and actions.
if (spaceTap && performance.now() - spaceTap.at < 350 && !quick.value) openQuickAdd()
spaceTap = null
}
const key = e.key.toLowerCase()
for (const n of def.value.nodes) if (n.kind === 'button' && n.key === key) ed.press(n, false)
for (const [n, r] of boundRows(key)) if (r.type === 'button') ed.pressRow(n, r, false)
@ -1581,7 +1590,7 @@ defineExpose({ fit, zoomAt })
<rect v-if="boxRect" v-bind="boxRect" />
</g>
</svg>
<EditorQuickAdd v-if="quick" :x="quick.x" :y="quick.y" @pick="onQuickPick" @close="quick = null" />
<EditorQuickAdd v-if="quick" :x="quick.x" :y="quick.y" @pick="onQuickPick" @fit="fit" @close="quick = null" />
<EditorContextMenu v-if="menu" :x="menu.x" :y="menu.y" :entries="menu.entries" :keyboard="menu.keyboard" @close="menu = null" />
<div v-if="!def.nodes.length" class="empty-hint">

View File

@ -37,8 +37,8 @@ const SHORTCUTS: [string, string][] = [
['Alt + click an input pin', 'Inverts it (a bubble); counted honestly as one NAND'],
['Send signal / Use signal', 'Name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire'],
['Ctrl+F', 'Find a part, signal or component in every circuit, and where a component is used'],
['Shift+A or Ctrl+K', 'Add a part at the mouse: type a few letters, arrows to choose, Enter to place'],
['/', 'The same: find a part by name and place it'],
['Space (tap)', 'Search at the mouse: recent parts and actions like a new component; type a few letters, arrows to choose, Enter to take it'],
['/, Shift+A or Ctrl+K', 'The same search box'],
['Ctrl+P', 'Print the circuit as a sheet with a title block, or save it as PDF'],
['Select switches or buttons, Combine', 'One input panel (all rows can become buttons); lamps or output pins combine into an output panel'],
['Select panels, Merge', 'One panel with all their rows; inside a component input panel rows are inputs, output panel rows outputs'],

View File

@ -1,24 +1,107 @@
<script setup lang="ts">
// Adding a part from the keyboard (Shift+A or Ctrl+K): a search box at the
// mouse; type a few letters, arrows to choose, Enter puts it right there.
// The search box at the mouse (Space, /, Shift+A or Ctrl+K): parts to place
// right there, and things to do. Empty, it shows the parts used lately and
// the common actions; typing narrows both. Arrows choose, Enter takes it.
import { matchScore } from '~/lib/match'
import type { NodeKind } from '~/lib/logic/types'
const props = defineProps<{ x: number; y: number }>()
const emit = defineEmits<{ pick: [p: { kind: NodeKind; chip?: string }]; close: [] }>()
const emit = defineEmits<{ pick: [p: { kind: NodeKind; chip?: string }]; fit: []; close: [] }>()
const { search } = useParts()
const ed = useEditor()
const { search, recentParts } = useParts()
const query = ref('')
const at = ref(0)
const input = ref<HTMLInputElement>()
const el = ref<HTMLElement>()
const hits = computed(() => search(query.value, 10))
interface Action {
id: string
label: string
icon: string
keys?: string
/** Other words it is found by. */
aka?: string
/** Only offered when this holds. */
when?: () => boolean
run: () => void
}
const ACTIONS: Action[] = [
{ id: 'new-comp', label: 'Create a new component', icon: 'lucide:square-plus', aka: 'new part chip block', run: () => ed.createComponent() },
{
id: 'package',
label: 'Make a component from the selection',
icon: 'lucide:package',
aka: 'group package extract',
when: () => ed.selection.value.length > 1,
run: () => ed.packageSelected('Part'),
},
{ id: 'find', label: 'Find anything in the project', icon: 'lucide:search', keys: 'Ctrl+F', aka: 'search where used', run: () => (ed.dialog.value = 'search') },
{ id: 'table', label: 'Truth table', icon: 'lucide:table', aka: 'test outputs', run: () => (ed.dialog.value = 'table') },
{ id: 'fit', label: 'Fit the circuit to the screen', icon: 'lucide:scan', keys: 'F', aka: 'zoom view', run: () => emit('fit') },
{ id: 'examples', label: 'Add example parts', icon: 'lucide:book-open', aka: 'library not and or adder counter', run: () => ed.loadExamples() },
{ id: 'connector', label: 'New connector type', icon: 'lucide:plug', aka: 'cable hdmi rj45 bus port', when: () => ed.canPlaceKind('portin'), run: () => ed.addConnector() },
{ id: 'undo', label: 'Undo', icon: 'lucide:undo-2', keys: 'Ctrl+Z', when: () => ed.canUndo.value, run: () => ed.undo() },
{ id: 'print', label: 'Print or save as PDF', icon: 'lucide:printer', keys: 'Ctrl+P', aka: 'sheet export', run: () => ed.exportSheet('print') },
{ id: 'settings', label: 'Settings', icon: 'lucide:settings', aka: 'symbols sound wires options', run: () => (ed.dialog.value = 'settings') },
{ id: 'help', label: 'How to play', icon: 'lucide:circle-help', keys: '?', aka: 'help shortcuts keys', run: () => (ed.showHelp.value = true) },
{ id: 'menu', label: 'Menu: save, load, main menu', icon: 'lucide:menu', keys: 'Esc', aka: 'pause quit', run: () => ed.pause() },
]
type Item = { type: 'part'; id: string; kind: NodeKind; chip?: string; label: string; icon: string; note?: string } | { type: 'action'; id: string; act: Action; label: string; icon: string; note?: string }
const partItem = (p: { kind: NodeKind; chip?: string; name: string; icon: string }, note?: string): Item => ({
type: 'part',
id: `p:${p.chip ?? p.kind}`,
kind: p.kind,
chip: p.chip,
label: p.name,
icon: p.icon,
note,
})
const actItem = (a: Action): Item => ({ type: 'action', id: `a:${a.id}`, act: a, label: a.label, icon: a.icon, note: a.keys })
const offered = () => ACTIONS.filter(a => !a.when || a.when())
/** Sections to show: parts first, then actions. */
const sections = computed(() => {
const q = query.value.trim()
if (!q) {
const recent = recentParts.value.map(r => partItem(r, 'recent'))
const parts = recent.length ? recent : search('', 6).map(h => partItem(h, h.group))
return [
{ title: recent.length ? 'Recent parts' : 'Parts', items: parts },
{ title: 'Actions', items: offered().slice(0, 7).map(actItem) },
]
}
const parts = search(q, 8).map(h => partItem(h, h.group))
const acts = offered()
.map(a => ({ a, s: Math.max(matchScore(a.label, q.toLowerCase()), matchScore(a.aka ?? '', q.toLowerCase()) * 0.8) }))
.filter(x => x.s > 0)
.sort((x, y) => y.s - x.s)
.slice(0, 5)
.map(x => actItem(x.a))
return [
{ title: 'Parts', items: parts },
{ title: 'Actions', items: acts },
].filter(s => s.items.length)
})
const flat = computed(() => sections.value.flatMap(s => s.items))
const indexOf = (it: Item) => flat.value.indexOf(it)
watch(query, () => (at.value = 0))
function take(it: Item | undefined) {
if (!it) return
if (it.type === 'part') return emit('pick', { kind: it.kind, chip: it.chip })
emit('close')
it.act.run()
}
const pos = ref({ left: props.x, top: props.y })
onMounted(() => {
input.value?.focus()
const r = el.value!.getBoundingClientRect()
pos.value = { left: Math.max(8, Math.min(props.x, window.innerWidth - r.width - 8)), top: Math.max(8, Math.min(props.y, window.innerHeight - 380)) }
pos.value = { left: Math.max(8, Math.min(props.x, window.innerWidth - r.width - 8)), top: Math.max(8, Math.min(props.y, window.innerHeight - 440)) }
window.addEventListener('pointerdown', outside, true)
})
onBeforeUnmount(() => window.removeEventListener('pointerdown', outside, true))
@ -29,14 +112,14 @@ function outside(e: Event) {
function onKey(e: KeyboardEvent) {
e.stopPropagation()
const n = hits.value.length
const n = flat.value.length
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
e.preventDefault()
if (n) at.value = (at.value + (e.key === 'ArrowDown' ? 1 : -1) + n) % n
nextTick(() => el.value?.querySelector('.item.active')?.scrollIntoView({ block: 'nearest' }))
} else if (e.key === 'Enter') {
e.preventDefault()
const h = hits.value[at.value]
if (h) emit('pick', { kind: h.kind, chip: h.chip })
take(flat.value[at.value])
} else if (e.key === 'Escape') {
e.preventDefault()
emit('close')
@ -48,20 +131,26 @@ function onKey(e: KeyboardEvent) {
<Teleport to="body">
<div ref="el" class="quick-add" :style="{ left: `${pos.left}px`, top: `${pos.top}px` }" @keydown="onKey">
<div class="search part-search">
<Icon name="lucide:plus" class="size-3.5 text-(--muted)" />
<input ref="input" v-model="query" placeholder="Add a part here…" />
<Icon name="lucide:search" class="size-3.5 text-(--muted)" />
<input ref="input" v-model="query" placeholder="Find a part or an action…" />
</div>
<div class="quick-list">
<template v-for="s in sections" :key="s.title">
<p class="quick-head">{{ s.title }}</p>
<ul class="items">
<li v-for="it in s.items" :key="it.id">
<button class="item" :class="{ active: indexOf(it) === at }" @pointerenter="at = indexOf(it)" @click="take(it)">
<span v-if="it.type === 'part' && it.kind === 'nand'" class="nand-badge">&amp;</span>
<Icon v-else :name="it.icon" class="size-4 shrink-0" :class="it.type === 'action' ? 'text-(--accent)' : 'text-(--muted)'" />
<span class="grow truncate">{{ it.label }}</span>
<kbd v-if="it.type === 'action' && it.note">{{ it.note }}</kbd>
<span v-else-if="it.note" class="group-tag">{{ it.note }}</span>
</button>
</li>
</ul>
</template>
<p v-if="!flat.length" class="hint px-3 pb-2">Nothing called "{{ query.trim() }}" here.</p>
</div>
<ul class="items">
<li v-for="(h, i) in hits" :key="h.chip ?? h.kind">
<button class="item" :class="{ active: i === at }" @pointerenter="at = i" @click="emit('pick', { kind: h.kind, chip: h.chip })">
<span v-if="h.kind === 'nand'" class="nand-badge">&amp;</span>
<Icon v-else :name="h.icon" class="size-4 shrink-0 text-(--muted)" />
<span class="grow truncate">{{ h.name }}</span>
<span class="group-tag">{{ h.group }}</span>
</button>
</li>
</ul>
<p v-if="!hits.length" class="hint px-3 pb-2">Nothing called "{{ query.trim() }}" fits here.</p>
</div>
</Teleport>
</template>