diff --git a/README.md b/README.md index 34eb88f..f5f4f59 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: 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. +- Layout like Figma: two floating rounded bars over the canvas, a panel on the left for the circuit you are in and one on the right for what is selected. 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. - 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 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 [). +- The panel on the left is about the circuit you are in and has two tabs. **This**: the challenge or puzzle being built with its Check (at the top when there is one), problems, name, statistics, the truth table, how it looks as a component, where the transistors are (each kind of part with its count; click a line to select those parts) and tools. **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. 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 [). The panel on the right is there only while something is selected: its settings and what to do with it (swap, wire them all, make a component out of it); x or Esc closes it. - 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 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. +- Clicking anything opens its settings in the panel 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. - 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 e9fec3e..b6dea74 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -63,6 +63,7 @@ kbd { .workspace { --left: 272px; + --right: 280px; display: grid; grid-template-columns: var(--left) 1fr; min-height: 0; @@ -72,9 +73,14 @@ kbd { --left: 36px !important; } +.workspace.has-selection { + grid-template-columns: var(--left) 1fr var(--right); +} + .stage { position: relative; min-width: 0; + container-type: inline-size; overflow: hidden; } @@ -104,10 +110,21 @@ kbd { } @media (max-width: 820px) { - .workspace { + .workspace, + .workspace.has-selection { grid-template-columns: 1fr; grid-template-rows: 1fr 40%; } + /* On a phone the selection takes the place of the panel below the canvas. */ + .workspace.has-selection > .inspector:not(.selection-panel), + .workspace.has-selection > .rail { + display: none; + } + .workspace > .selection-panel { + order: 2; + border-left: 0; + border-top: 1px solid var(--border); + } .workspace > .inspector, .workspace > .rail { order: 2; @@ -2632,7 +2649,7 @@ kbd { } .itabs { - grid-template-columns: 30px repeat(4, 1fr); + grid-template-columns: 30px repeat(2, 1fr); } .rail { @@ -4273,7 +4290,7 @@ table.board { background: var(--border); } -@media (max-width: 1250px) { +@container (max-width: 1100px) { .bar-label { display: none; } @@ -4591,12 +4608,27 @@ table.board { translate: 0 -4px; } -@media (max-width: 1100px) { - .top-bar .status { +/* The bars follow the width of the canvas, which shrinks while the selection panel is open. */ +@container (max-width: 1000px) { + .top-bar .status, + .top-bar .cycles, + .top-bar .bar-count, + .top-bar .bar-text { display: none; } } +@container (max-width: 760px) { + .top-bar .project-name, + .top-bar .crumbs .bar-btn > span:not(.truncate), + .top-bar .tb-select { + display: none; + } + .top-bar .bar-btn { + padding: 0 7px; + } +} + /* Pinned parts at the start of the parts bar. */ .bar-btn.pinned-part { padding: 0 8px; @@ -4607,8 +4639,30 @@ table.board { opacity: 0.4; } -@media (max-width: 1600px) { +@container (max-width: 1400px) { .bottom-bar:has(.pinned-part) .bar-label { display: none; } } + +/* The selection's own panel on the right, there only while something is selected. */ +.selection-panel { + border-right: 0; + border-left: 1px solid var(--border); +} + +.sel-panel-head { + display: flex; + align-items: center; + gap: 8px; + height: 45px; + padding: 0 8px 0 12px; + flex-shrink: 0; + border-bottom: 1px solid var(--border); + font-size: 12px; + font-weight: 700; +} + +.table-pane .truth { + margin-top: 4px; +} diff --git a/app/components/editor/App.vue b/app/components/editor/App.vue index c3a8c72..4ae84b6 100644 --- a/app/components/editor/App.vue +++ b/app/components/editor/App.vue @@ -7,6 +7,8 @@ function reload() { location.reload() } +const hasSelection = computed(() => ed.selection.value.length + ed.wireSel.value.length > 0) + const link = computed(() => { const l = ed.linking.value const end = l?.queue[l.at] @@ -35,14 +37,15 @@ watch(