From 6e3405ae0ccbaa07f39f57910607da6318aecdf7 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Thu, 22 Oct 2026 20:17:41 +0200 Subject: [PATCH] R Top bar like the parts bar, no left panel The parts panel on the left is gone: pinned parts sit at the start of the bottom bar, components open from the pencil in its Components list (or a double-click), examples load from there too. The side panel moved to the left. The top bar floats across the whole width: menu with the project, Main and the way into the open component instead of the circuit selector, Challenges in a drop-down, clock, search, undo, settings, share and account. / and the bar's search open quick add. Co-Authored-By: Claude Opus 5.5 --- README.md | 6 +- app/assets/css/main.css | 204 ++++++++++++--- app/components/editor/App.vue | 8 +- app/components/editor/BottomBar.vue | 41 ++- app/components/editor/Canvas.vue | 16 +- app/components/editor/ChallengesPanel.vue | 98 +++++++ app/components/editor/Help.vue | 16 +- app/components/editor/Inspector.vue | 6 +- app/components/editor/MenuCampaign.vue | 2 +- app/components/editor/Palette.vue | 298 ---------------------- app/components/editor/Rail.vue | 21 +- app/components/editor/Toolbar.vue | 197 ++++++++------ app/composables/useEditor.ts | 39 ++- app/composables/usePlace.ts | 2 +- 14 files changed, 481 insertions(+), 473 deletions(-) create mode 100644 app/components/editor/ChallengesPanel.vue delete mode 100644 app/components/editor/Palette.vue diff --git a/README.md b/README.md index 179aae3..34eb88f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Nuxt 4 (client-only editor, `ssr: false`), Tailwind CSS v4, Lucide icons via `@n ## What it does - Parts: NAND, input switch, output pin, lamp, push button, clock, constant 1, ground, hex display, pixel, cable bundle and split, input panel, note. -- Layout like Figma: a slim top bar (menu, project, circuit, clock, undo, share), a floating bar at the bottom of the canvas with one button per kind of part (Logic, Inputs, Outputs, Wiring, Notes, Connectors, Components) that opens its parts on pointing, and on the left your pinned parts (NAND, AND, OR, NOT, XOR, input, output, lamp, clock to start with; pin and unpin from the bottom bar, kept per browser, components by name) above the circuits list. +- Layout like Figma: two floating rounded bars and one side panel. The top bar, across the whole width: menu (pause menu) with the project name, "Main" and the way into the open component (each name leads back; every other circuit is a component and opens with a double-click, or the pencil in the Components list), Challenges (campaign, puzzle of the week, puzzles, challenges in a drop-down), the clock, search, undo, sound, settings, help, share and account. The bottom bar: your pinned parts first (NAND, AND, OR, NOT, XOR, input, output, lamp, clock to start with; pin from the lists, right-click to unpin, kept per browser, components by name), then one button per kind of part (Logic, Inputs, Outputs, Wiring, Notes, Connectors, Components) that opens its parts on pointing, and a search that opens quick add. The side panel sits on the left. - Lamps and output pins pass their signal on: the pin on their right carries the same value, so a lamp can sit in the middle of a wire. - Gates with more inputs: a placed AND, OR, XOR, NAND or NOR (built in, from the examples, or your own) has an "Inputs" setting from 2 to 16. The wide version is a component built as a balanced tree of the two-input gate (NAND and NOR as the plain gate plus a final inverted one), made once per gate and width in "Wide gates" and reused; transistors count honestly and changes to the two-input gate carry through. Which gates qualify is read off their truth table ([app/lib/logic/wide.ts](app/lib/logic/wide.ts)). - Campaign (Projects → New campaign): you start with NAND, inputs, outputs, lamps and notes, and no examples. Each challenge opens once the ones it builds on are solved (NOT → AND, OR, SR Latch → …), and your own solution becomes a part you can place. Other basic parts unlock on the way: constants with NOT, the input panel with AND, hex display and pixel with the decoder, cables with Adder 2, the button with the SR latch, the clock with the D latch. Rules in [app/lib/logic/progress.ts](app/lib/logic/progress.ts). Sandbox projects keep everything open. @@ -21,13 +21,13 @@ Nuxt 4 (client-only editor, `ssr: false`), Tailwind CSS v4, Lucide icons via `@n - Automatic names: copies continue a series (D0 copied gives D1, D2; A gives B), and so does placing a new input or output after a numbered one. A switch, button, lamp or output pin without a name of its own (or with an automatic one) takes the name of the component pin it gets wired to, made unique (Cin, Cin2); a name typed by hand is kept. On the canvas, a switch, button, clock, lamp or output pin without a name typed by hand shows the name of the component pin it is wired to, dimmed and in italics (or its automatic name, also dimmed); the name follows the wiring as it changes. - Every circuit is a component. Its input and output nodes become its pins, ordered top to bottom. Double-click a component to open it. - Lamps and hex displays inside a component show on its box, with their labels, lit by that instance's state. They are laid out in rows the way they sit inside. A checkbox in the inspector turns this off per component. -- The right panel has four tabs. **Selection**: settings of what you clicked (switches to it when you select something on an idle panel). **Circuit**: name, symbol, group, statistics, and where the transistors are (each kind of part with its count; click a line to select those parts). **Pins**: every input and output of the circuit in pin order, one line each, with its live value (click it to flip a switch, hold it for a button; panel rows are framed under their panel); rename in place (Enter goes to the next), "Number all" names a whole side from a pattern (D# → D0, D1, …), duplicate names are flagged, the target icon centres the canvas on a part. **Test**: the challenge or puzzle check and the truth table (opens by itself for a challenge). Display and sound preferences are in Settings (gear in the top bar). Both side panels fold away to a strip of icons (the panel icon in their tab row, or [ and ]). +- The side panel (left) has four tabs. **Selection**: settings of what you clicked (switches to it when you select something on an idle panel). **Circuit**: name, symbol, group, statistics, and where the transistors are (each kind of part with its count; click a line to select those parts). **Pins**: every input and output of the circuit in pin order, one line each, with its live value (click it to flip a switch, hold it for a button; panel rows are framed under their panel); rename in place (Enter goes to the next), "Number all" names a whole side from a pattern (D# → D0, D1, …), duplicate names are flagged, the target icon centres the canvas on a part. **Test**: the challenge or puzzle check and the truth table (opens by itself for a challenge). Display and sound preferences are in Settings (gear in the top bar). It folds away to a strip of icons (the panel icon in its tab row, or [). - Box selection: a box that touches no parts selects every wire and cable it crosses (drag across the wires between parts to bundle them). Dragged right to left (green box) it selects everything it touches, parts and wires. Left to right over parts it takes those parts and only the wires lying fully inside, so Delete never catches unrelated wires passing through. - Wiring many at once: select several parts and drag one wire from one of them to a pin of another part; the others follow onto that part's next pins, in position order (or use "Wire them all to" in the panel). - Zooming out goes at least far enough to see the whole circuit, further for bigger circuits. - Several selected parts are edited together: chips to narrow the selection by type, swap them all for another part, rename all top to bottom from a pattern, set every switch to 0 or 1 or flip each, one colour, one clock frequency or note size for all, line them up or spread them evenly, plus make component, connect one by one, unlink, duplicate, delete. - Transistors: every part shows its count (4 for a NAND, 0 for switches, lamps and cables, the whole inside for a component; the NAND in the palette shows 4T). The count is 4 per CMOS NAND gate the simulator builds, at every depth; a test checks this against the flattened circuit for every example and every wide gate. -- Clicking anything opens its settings on the right. Parts can be swapped in place (wires stay on the pins in the same position): NAND and components with each other, switch/button/clock/constants with each other, output/lamp/display with each other. Clocks have their own frequency or follow the top bar. Switches and buttons can get a keyboard key. Lamps and displays have colours, notes have sizes, components a name on the canvas. Components can be unpacked into their parts or given their own copy of the definition; any part can have all its wires unlinked. +- Clicking anything opens its settings in the side panel. Parts can be swapped in place (wires stay on the pins in the same position): NAND and components with each other, switch/button/clock/constants with each other, output/lamp/display with each other. Clocks have their own frequency or follow the top bar. Switches and buttons can get a keyboard key. Lamps and displays have colours, notes have sizes, components a name on the canvas. Components can be unpacked into their parts or given their own copy of the definition; any part can have all its wires unlinked. - Select parts and press "Make component" to turn them into a new component; wires crossing the selection become pins. - Gate symbols in IEC 60617 (DIN, default) or ANSI. A component with one output can be drawn as a gate symbol. - Wires of different signals never share a line: auto-routed wires pick a free column or a detour, and anything still clashing (hand-placed bends) is drawn on its own lane. Crossings are drawn as a bow, triangle, bridge, gap or plain crossing (Settings, the gear in the top bar). Clicking a junction dot selects its whole signal. diff --git a/app/assets/css/main.css b/app/assets/css/main.css index af1522a..18f711d 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -57,33 +57,27 @@ kbd { /* ── Layout ─────────────────────────────────────────────────────── */ .app { display: grid; - grid-template-rows: 44px 1fr; + grid-template-rows: auto 1fr; height: 100dvh; } .workspace { - --left: 232px; - --right: 272px; + --left: 272px; display: grid; - grid-template-columns: var(--left) 1fr var(--right); + grid-template-columns: var(--left) 1fr; min-height: 0; } -.workspace.no-left { +.workspace.no-panel { --left: 36px !important; } -.workspace.no-right { - --right: 36px !important; -} - .stage { position: relative; min-width: 0; overflow: hidden; } -.palette, .inspector { background: var(--panel); min-height: 0; @@ -91,12 +85,8 @@ kbd { flex-direction: column; } -.palette { - border-right: 1px solid var(--border); -} - .inspector { - border-left: 1px solid var(--border); + border-right: 1px solid var(--border); } .scroll { @@ -109,8 +99,7 @@ kbd { @media (max-width: 1100px) { .workspace { - --left: 210px; - --right: 260px; + --left: 252px; } } @@ -119,11 +108,10 @@ kbd { grid-template-columns: 1fr; grid-template-rows: 1fr 40%; } - .palette { - display: none; - } - .inspector { - border-left: 0; + .workspace > .inspector, + .workspace > .rail { + order: 2; + border-right: 0; border-top: 1px solid var(--border); } } @@ -328,7 +316,7 @@ kbd { color: var(--muted); } -.palette h3, +.challenges-panel h3, .inspector h3 { font-size: 11px; font-weight: 700; @@ -337,8 +325,8 @@ kbd { color: var(--muted); } -.palette h3 { - padding: 14px 12px 6px; +.challenges-panel h3 { + padding: 14px 6px 6px; } .items { @@ -380,7 +368,7 @@ kbd { color: var(--accent); } -/* Transistor count next to a component in the palette. */ +/* Transistor count next to a component in a parts list. */ .tcount { font-family: var(--font-mono); font-size: 10px; @@ -2198,7 +2186,7 @@ kbd { color: var(--on); } -/* ── Campaign and puzzles (palette) ─────────────────────────────── */ +/* ── Campaign and puzzles (challenges) ─────────────────────────────── */ .campaign, .weekly { margin: 12px 12px 4px; @@ -2657,14 +2645,10 @@ kbd { min-height: 0; } -.rail.left { +.rail { border-right: 1px solid var(--border); } -.rail.right { - border-left: 1px solid var(--border); -} - .rail-btn { display: grid; place-items: center; @@ -4224,16 +4208,26 @@ table.board { /* ── Bottom bar: parts by kind, like Figma's toolbar ────────────── */ .bottom-dock { position: absolute; - left: 50%; + left: 12px; + right: 12px; bottom: 14px; z-index: 20; - transform: translateX(-50%); + display: flex; + justify-content: center; + pointer-events: none; +} + +.bottom-dock > * { + pointer-events: auto; } .bottom-bar { display: flex; align-items: center; gap: 2px; + max-width: 100%; + overflow-x: auto; + scrollbar-width: none; padding: 5px; background: rgb(26 33 43 / 0.96); border: 1px solid var(--border); @@ -4246,6 +4240,7 @@ table.board { .bar-btn { display: flex; + flex-shrink: 0; align-items: center; gap: 6px; height: 34px; @@ -4472,6 +4467,143 @@ table.board { color: var(--text); } -.palette .tabs button { - white-space: nowrap; +/* ── Top bar: floating like the parts bar, across the whole width ─ */ +.top-dock { + position: relative; + z-index: 30; + padding: 8px 8px 6px; + background: var(--bg); + border-bottom: 1px solid var(--border); +} + +.top-bar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 10px; + min-width: 0; + padding: 4px; + background: rgb(26 33 43 / 0.96); + border: 1px solid var(--border); + border-radius: 12px; + box-shadow: + 0 6px 20px rgb(0 0 0 / 0.35), + 0 1px 0 rgb(255 255 255 / 0.03) inset; +} + +.tb-group { + display: flex; + align-items: center; + gap: 2px; +} + +.top-bar .bar-btn { + height: 32px; + padding: 0 9px; +} + +.top-bar .bar-btn:disabled { + opacity: 0.35; + cursor: not-allowed; + background: none; +} + +.top-bar .bar-btn.here:disabled { + opacity: 1; + color: var(--text); + cursor: default; +} + +.top-bar .tb-select { + height: 30px; + font-size: 12px; + border-radius: 8px; +} + +.brand-btn { + color: var(--on) !important; + max-width: 260px; +} + +.project-name { + color: var(--text); + font-size: 13px; + font-weight: 700; +} + +.crumbs { + display: flex; + align-items: center; + gap: 1px; + min-width: 0; + overflow: hidden; +} + +.crumb { + min-width: 0; + max-width: 180px; +} + +.crumb-sep { + flex-shrink: 0; + color: var(--muted); + opacity: 0.6; +} + +.bar-count { + font-family: var(--font-mono); + font-size: 11px; + color: var(--muted); +} + +.top-pop { + position: absolute; + top: calc(100% + 10px); + left: 50%; + width: 340px; + max-height: min(72vh, 640px); + overflow-y: auto; + padding: 10px; + transform: translateX(-50%); + background: rgb(26 33 43 / 0.98); + border: 1px solid var(--border); + border-radius: 12px; + box-shadow: 0 18px 50px rgb(0 0 0 / 0.5); + scrollbar-width: thin; + scrollbar-color: var(--border) transparent; +} + +.drop-enter-active, +.drop-leave-active { + transition: + opacity 0.12s, + translate 0.12s; +} + +.drop-enter-from, +.drop-leave-to { + opacity: 0; + translate: 0 -4px; +} + +@media (max-width: 1100px) { + .top-bar .status { + display: none; + } +} + +/* Pinned parts at the start of the parts bar. */ +.bar-btn.pinned-part { + padding: 0 8px; + color: var(--text); +} + +.bar-btn.blocked { + opacity: 0.4; +} + +@media (max-width: 1600px) { + .bottom-bar:has(.pinned-part) .bar-label { + display: none; + } } diff --git a/app/components/editor/App.vue b/app/components/editor/App.vue index c6361e5..dfad982 100644 --- a/app/components/editor/App.vue +++ b/app/components/editor/App.vue @@ -36,15 +36,13 @@ watch( diff --git a/app/components/editor/BottomBar.vue b/app/components/editor/BottomBar.vue index 210963f..1b90341 100644 --- a/app/components/editor/BottomBar.vue +++ b/app/components/editor/BottomBar.vue @@ -2,13 +2,13 @@ // The floating bar at the bottom of the canvas, like Figma's toolbar: one // button per kind of part. Pointing at one opens its parts above it; click // a part to place it (or drag it onto the canvas), pin it to keep it on the -// left. Components and your connector types have their own buttons. +// bar itself. Components and your connector types have their own buttons. import { shortCount } from '~/lib/logic/analyze' import { BASIC_GROUPS } from '~/composables/useParts' import type { ComponentDef, NodeKind } from '~/lib/logic/types' const ed = useEditor() -const { place, dragStart, dragEnd, isPinned, togglePin } = usePlace() +const { place, dragStart, dragEnd, isPinned, togglePin, pinned, unpin } = usePlace() const { componentGroups } = useParts() const ICONS: Record = { @@ -79,6 +79,9 @@ const activeCat = computed(() => { const group = computed(() => BASIC_GROUPS.find(g => g.name === open.value)) 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. +const shown = computed(() => pinned.value.filter(p => p.kind !== 'chip' || p.chip)) +const named = (p: { kind: NodeKind }) => p.kind === 'chip' || p.kind === 'nand' const placeable = (d: ComponentDef) => d.id !== ed.def.value.id && ed.canPlace(d.id) function onKey(e: KeyboardEvent) { @@ -114,7 +117,7 @@ onBeforeUnmount(() => window.removeEventListener('keydown', onKey, true)) {{ p.name }} {{ p.key }} - @@ -171,19 +174,45 @@ onBeforeUnmount(() => window.removeEventListener('keydown', onKey, true)) {{ d.name }} {{ shortCount(ed.transistors(d.id)) }}T - + - +
+ + +
diff --git a/app/components/editor/Canvas.vue b/app/components/editor/Canvas.vue index b4df8e4..6d1820e 100644 --- a/app/components/editor/Canvas.vue +++ b/app/components/editor/Canvas.vue @@ -953,12 +953,10 @@ function onKey(e: KeyboardEvent) { e.preventDefault() return openMenuForSelection() } - // Finding parts from the keyboard: / searches the parts list, Shift+A or Ctrl+K adds one at the mouse. + // Finding parts from the keyboard: /, Shift+A or Ctrl+K add one at the mouse. if (e.key === '/' && !mod) { e.preventDefault() - ed.toggleSidebar('left', true) - ed.partSearch.value++ - return + return openQuickAdd() } if ((e.shiftKey && key === 'a' && !mod) || (mod && key === 'k')) { e.preventDefault() @@ -1031,8 +1029,7 @@ function onKey(e: KeyboardEvent) { if (n?.kind === 'chip' && n.chip) ed.open(n.chip) } else if (!mod && !e.altKey && key === 'w' && ed.selection.value.length) ed.startLinking(ed.selection.value, e.shiftKey ? 'in' : undefined) else if (!mod && !e.altKey && key === 'f') fit() - else if (!mod && !e.altKey && e.key === '[') ed.toggleSidebar('left') - else if (!mod && !e.altKey && e.key === ']') ed.toggleSidebar('right') + else if (!mod && !e.altKey && (e.key === '[' || e.key === ']')) ed.toggleSidebar('right') else if (!mod && !e.altKey && e.key === '?') ed.showHelp.value = !ed.showHelp.value else if (!mod && !e.altKey && QUICK[key] && ed.canPlaceKind(QUICK[key]!)) ed.placing.value = { kind: QUICK[key]! } } @@ -1237,14 +1234,17 @@ watch( const quick = ref<{ x: number; y: number; at: Pt } | null>(null) let lastClient = { x: 0, y: 0 } -function openQuickAdd() { +function openQuickAdd(centre = false) { const r = root.value!.getBoundingClientRect() - const inside = lastClient.x >= r.left && lastClient.x <= r.right && lastClient.y >= r.top && lastClient.y <= r.bottom + const inside = !centre && lastClient.x >= r.left && lastClient.x <= r.right && lastClient.y >= r.top && lastClient.y <= r.bottom const x = inside ? lastClient.x : r.left + r.width / 2 const y = inside ? lastClient.y : r.top + r.height / 3 quick.value = { x, y, at: toWorld({ clientX: x, clientY: y }) } } +// The search button in the parts bar opens it in the middle of the canvas. +watch(ed.partSearch, () => openQuickAdd(true)) + function onQuickPick(p: { kind: CircuitNode['kind']; chip?: string }) { const q = quick.value quick.value = null diff --git a/app/components/editor/ChallengesPanel.vue b/app/components/editor/ChallengesPanel.vue new file mode 100644 index 0000000..7770f07 --- /dev/null +++ b/app/components/editor/ChallengesPanel.vue @@ -0,0 +1,98 @@ + + + diff --git a/app/components/editor/Help.vue b/app/components/editor/Help.vue index a7a0634..ad32369 100644 --- a/app/components/editor/Help.vue +++ b/app/components/editor/Help.vue @@ -4,9 +4,9 @@ const ed = useEditor() const SHORTCUTS: [string, string][] = [ ['Esc (nothing selected)', 'Pause menu: save, save as copy, load, settings, main menu'], ['Click switch', 'Flip an input between 0 and 1 (give it a keyboard key in its settings)'], - ['Click anything', 'Its settings appear on the right: swap the part, clock speed, colours, keys, position'], + ['Click anything', 'Its settings appear in the side panel on the left: swap the part, clock speed, colours, keys, position'], ['Select several', 'Change them all at once: swap, rename D0, D1, …, switch all to 0 or 1, line up'], - ['Pins tab (right)', 'Every input and output in one list: rename them one after another with Enter'], + ['Pins tab (side panel)', 'Every input and output in one list: rename them one after another with Enter'], ['Drag from a pin', 'Draw a wire to another pin; dropping it on a part uses that part’s next free pin'], ['Click a pin, then another', 'The same without holding the mouse button'], ['Select parts, then W', 'Connect one by one: click where each of their pins goes, in order (Shift+W: their inputs)'], @@ -23,7 +23,9 @@ const SHORTCUTS: [string, string][] = [ ['Right or middle drag, Space + drag', 'Move the view'], ['Mouse wheel', 'Zoom'], ['N, I, O, L, B, C, H, T, P, X', 'Place NAND, input, output, lamp, button, clock, hex display, note, input panel, pixel'], - ['Bar at the bottom', 'Point at a kind of part to see them all; click to place, drag onto the canvas, pin the ones you use most to the left'], + ['Bar at the bottom', 'Point at a kind of part to see them all; click to place, drag onto the canvas, pin the ones you use most to the bar itself (right-click a pinned part to unpin it)'], + ['Main (top bar)', 'Back to the main circuit; the names after it lead back to each component you entered'], + ['[', 'Hide or show the side panel'], ['Connectors (bottom bar)', 'Make a cable type of your own (HDMI, RJ45): its lines; place its Out and In ports; one cable joins them'], ['Select wires, Ctrl+G', 'Bundle them into one cable; an end whose wires all meet one part plugs straight into it'], ['Select a component, cable button beside its pins', 'A cable plugged onto S0–S3 (or any group); drop its free end on the next part\'s pins'], @@ -36,7 +38,7 @@ const SHORTCUTS: [string, string][] = [ ['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'], - ['/', 'Search the parts list; Enter starts placing the one chosen'], + ['/', 'The same: find a part by name and place it'], ['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'], @@ -46,7 +48,7 @@ const SHORTCUTS: [string, string][] = [ ['Ctrl+C, Ctrl+V, Ctrl+D', 'Copy, paste, duplicate; names continue their series (D0 → D1)'], ['Delete', 'Remove the selection'], ['Ctrl+Z, Ctrl+Shift+Z', 'Undo, redo'], - ['Logo (top left)', 'Back to the main menu: free play, campaign, challenges, leaderboard. Your work is saved'], + ['Logo (top left), Esc', 'Pause menu: save, load, settings, back to the main menu. Your work is saved'], ['F', 'Fit the circuit to the screen'], ['Enter', 'Open the selected component'], ] @@ -77,10 +79,10 @@ function close() { It runs while you draw. Green wires carry a 1, grey wires a 0. Flip switches, press buttons, or start the clock in the top bar.
  • - Try the challenges on the left, or open the examples (NOT up to a 4-bit counter) to see how each step is made of the previous one. + Try the challenges (top bar), or open the examples (NOT up to a 4-bit counter) to see how each step is made of the previous one.
  • - Select parts and press "Make component" on the right to turn a piece of your drawing into a reusable block. + Select parts and press "Make component" in the side panel to turn a piece of your drawing into a reusable block.
  • Controls

    diff --git a/app/components/editor/Inspector.vue b/app/components/editor/Inspector.vue index 921d556..519236d 100644 --- a/app/components/editor/Inspector.vue +++ b/app/components/editor/Inspector.vue @@ -1,5 +1,5 @@ diff --git a/app/components/editor/Palette.vue b/app/components/editor/Palette.vue deleted file mode 100644 index 3e85c8f..0000000 --- a/app/components/editor/Palette.vue +++ /dev/null @@ -1,298 +0,0 @@ - - - diff --git a/app/components/editor/Rail.vue b/app/components/editor/Rail.vue index de48c66..f362c35 100644 --- a/app/components/editor/Rail.vue +++ b/app/components/editor/Rail.vue @@ -1,6 +1,5 @@ diff --git a/app/components/editor/Toolbar.vue b/app/components/editor/Toolbar.vue index 3adf6fe..b22c476 100644 --- a/app/components/editor/Toolbar.vue +++ b/app/components/editor/Toolbar.vue @@ -1,4 +1,8 @@ diff --git a/app/composables/useEditor.ts b/app/composables/useEditor.ts index 68204b5..3e52f74 100644 --- a/app/composables/useEditor.ts +++ b/app/composables/useEditor.ts @@ -172,7 +172,7 @@ function create() { faceFor.value = defId dialog.value = 'face' } - /** Tab shown in the right panel. */ + /** Tab shown in the side panel. */ const rightTab = ref<'selection' | 'circuit' | 'pins' | 'test'>('circuit') /** Which side panels are open; remembered in this browser. */ const sidebars = reactive<{ left: boolean; right: boolean }>({ left: true, right: true }) @@ -456,8 +456,30 @@ function create() { if (id) open(id, false) } + /** The project's top circuit: "main", or else the first one no other circuit uses. */ + const mainId = computed(() => { + const list = project.value.components + if (list.some(d => d.id === 'main')) return 'main' + const used = new Set(list.flatMap(d => d.nodes.filter(n => n.kind === 'chip' && n.chip).map(n => n.chip!))) + return (list.find(d => !used.has(d.id) && !d.challenge) ?? list[0]!).id + }) + + /** Back to the top circuit; the way back is forgotten. */ + function goMain() { + nav.value = [] + open(mainId.value, false) + } + + /** Back to step `i` of the way here (0 is where it started). */ + function goTo(i: number) { + const id = nav.value[i] + if (!id) return + nav.value = nav.value.slice(0, i) + open(id, false) + } + // ── Editing ─────────────────────────────────────────────────────── - /** Asks the parts list to focus its search box ("/" on the canvas). */ + /** Asks the canvas to open quick add in its middle (search in the parts bar). */ const partSearch = ref(0) /** A part being dragged in from the parts list, so the canvas can show where it would connect. */ @@ -825,8 +847,8 @@ function create() { /** The title menu shows when the app opens at /; links open straight into the editor. */ const screen = ref<'menu' | 'editor'>(location.pathname === '/' ? 'menu' : 'editor') const menuPage = ref('main') - /** Tab of the parts panel on the left. */ - const paletteTab = ref<'parts' | 'challenges'>('parts') + /** The challenges list below its button in the top bar. */ + const challengesOpen = ref(false) function enterGame() { screen.value = 'editor' @@ -884,7 +906,7 @@ function create() { const m = newestOf('campaign') if (m) switchProject(m.id) else newProject(false, true) - paletteTab.value = 'challenges' + challengesOpen.value = true enterGame() } @@ -898,7 +920,7 @@ function create() { p.mode = 'challenges' activate(addProject(p), p) } - paletteTab.value = 'challenges' + challengesOpen.value = true } function playChallenge(c: Challenge) { @@ -2213,6 +2235,9 @@ function create() { rebuild, open, back, + mainId, + goMain, + goTo, addNode, canPlace, connect, @@ -2232,7 +2257,7 @@ function create() { setScreen, screen, menuPage, - paletteTab, + challengesOpen, enterGame, showMenu, projectMode, diff --git a/app/composables/usePlace.ts b/app/composables/usePlace.ts index dd4de96..e878c34 100644 --- a/app/composables/usePlace.ts +++ b/app/composables/usePlace.ts @@ -1,5 +1,5 @@ // Placing parts from anywhere (the bottom bar, pinned parts, the circuits -// list), and the parts pinned to the left panel. Pins are kept in this +// list), and the parts pinned to the bottom bar. Pins are kept in this // browser: built-in parts by kind, components by name, so a pinned "AND" // stays pinned in every project, whether it is the example or your own.