R a Figma-like workspace: a floating bottom bar of part kinds with flyouts, pinned parts on the left
- Bottom bar over the canvas: Logic, Inputs, Outputs, Wiring, Notes,
Connectors, Components (and search). Pointing at one opens its parts
above it: click to place, drag onto the canvas, pin to the left.
Connectors offer Out/In, edit and new type; components come grouped
with their transistor counts.
- Left panel: pinned parts first (NAND, AND, OR, NOT, XOR, input,
output, lamp, clock to start with; kept per browser, components by
name so they follow you into every project), then the circuits list.
The long list of built-in parts and the connector list moved to the
bar.
- Slimmer top bar and side panels; notices sit above the bar.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:04:43 +00:00
// Placing parts from anywhere (the bottom bar, pinned parts, the circuits
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 <noreply@anthropic.com>
2026-10-22 18:17:41 +00:00
// list), and the parts pinned to the bottom bar. Pins are kept in this
R a Figma-like workspace: a floating bottom bar of part kinds with flyouts, pinned parts on the left
- Bottom bar over the canvas: Logic, Inputs, Outputs, Wiring, Notes,
Connectors, Components (and search). Pointing at one opens its parts
above it: click to place, drag onto the canvas, pin to the left.
Connectors offer Out/In, edit and new type; components come grouped
with their transistor counts.
- Left panel: pinned parts first (NAND, AND, OR, NOT, XOR, input,
output, lamp, clock to start with; kept per browser, components by
name so they follow you into every project), then the circuits list.
The long list of built-in parts and the connector list moved to the
bar.
- Slimmer top bar and side panels; notices sit above the bar.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:04:43 +00:00
// 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.
import { BASIC_PARTS } from '~/composables/useParts'
import { challengeName , defUsable , KIND_UNLOCK } from '~/lib/logic/progress'
import type { ComponentDef , NodeKind } from '~/lib/logic/types'
const PIN_KEY = 'logigate:pinned'
const DEFAULT_PINS = [ 'nand' , 'name:AND' , 'name:OR' , 'name:NOT' , 'name:XOR' , 'input' , 'output' , 'lamp' , 'clock' ]
function loadPins ( ) : string [ ] {
try {
const raw = JSON . parse ( localStorage . getItem ( PIN_KEY ) ? ? 'null' )
if ( Array . isArray ( raw ) ) return raw . filter ( ( k ) : k is string = > typeof k === 'string' ) . slice ( 0 , 40 )
} catch { }
return [ . . . DEFAULT_PINS ]
}
const pins = ref < string [ ] > ( import . meta . client ? loadPins ( ) : [ . . . DEFAULT_PINS ] )
export interface PinnedPart {
pin : string
kind : NodeKind
chip? : string
name : string
icon : string
key? : string
/** Pinned, but not here: the component is not in this project, or not usable yet. */
missing? : boolean
}
export function usePlace() {
const ed = useEditor ( )
function lockedHint ( kind : NodeKind ) {
const by = KIND_UNLOCK [ kind ]
return by ? ` Solve the ${ challengeName ( by ) } challenge to unlock this part ` : ''
}
/** Start placing a part: click on the canvas puts it there. */
function place ( kind : NodeKind , chip? : string , conn? : string ) {
if ( chip && ! ed . canPlace ( chip ) ) {
ed . play ( 'error' )
A public library of components: publish yours, add everybody's
"Publish to the library…" in the menu on a circuit's name (or Space)
sends the component with every component it uses and their connector
types, under your leaderboard name. The server checks it like any
project, refuses what is missing, inside itself, nested too deep or too
big to run, and counts its transistors and pins itself. Publishing again
from the same browser makes the next version of the same entry; only that
browser holds the entry's key, so only it can update or remove it.
Challenge circuits and puzzle solutions stay private.
The Library (Components in the bottom bar, Space, the main menu) lists
every entry, newest first, searchable by name, description and author,
with a picture of its box, its transistors, pins and what comes along.
Add brings an entry into the open project and starts placing it: what the
project has in exactly that form already is used as it is, the rest comes
with new ids, a taken name gets a number, connector types join one with
the same lines. The This panel says where a component came from and
offers a newer version, which replaces it in place. A campaign only adds
what is built from parts it has earned, and its challenges take nothing
from the library.
Components keep an optional "from" mark; projects without it load and
compute as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:14:46 +00:00
return ed . notify ( 'That component cannot go in here (it is this circuit, contains it, is not solved yet, or is from the library and this is a campaign challenge)' , 'error' )
R a Figma-like workspace: a floating bottom bar of part kinds with flyouts, pinned parts on the left
- Bottom bar over the canvas: Logic, Inputs, Outputs, Wiring, Notes,
Connectors, Components (and search). Pointing at one opens its parts
above it: click to place, drag onto the canvas, pin to the left.
Connectors offer Out/In, edit and new type; components come grouped
with their transistor counts.
- Left panel: pinned parts first (NAND, AND, OR, NOT, XOR, input,
output, lamp, clock to start with; kept per browser, components by
name so they follow you into every project), then the circuits list.
The long list of built-in parts and the connector list moved to the
bar.
- Slimmer top bar and side panels; notices sit above the bar.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:04:43 +00:00
}
if ( ! ed . canPlaceKind ( kind ) ) {
ed . play ( 'error' )
return ed . notify ( lockedHint ( kind ) , 'error' )
}
ed . placing . value = { kind , chip , . . . ( conn ? { conn } : { } ) }
}
/** Dragging a part onto the canvas places it where it is dropped. */
function dragStart ( e : DragEvent , kind : NodeKind , chip? : string , conn? : string ) {
if ( ( chip && ! ed . canPlace ( chip ) ) || ! ed . canPlaceKind ( kind ) ) {
e . preventDefault ( )
return
}
e . dataTransfer ? . setData ( 'application/x-logigate' , JSON . stringify ( { kind , chip , conn } ) )
if ( e . dataTransfer ) e . dataTransfer . effectAllowed = 'copy'
ed . dragPart . value = { kind , chip , . . . ( conn ? { conn } : { } ) }
}
function dragEnd() {
ed . dragPart . value = null
}
const pinOf = ( kind : NodeKind , def? : ComponentDef ) = > ( def ? ` name: ${ def . name } ` : kind )
const isPinned = ( kind : NodeKind , def? : ComponentDef ) = > pins . value . includes ( pinOf ( kind , def ) )
function togglePin ( kind : NodeKind , def? : ComponentDef ) {
const key = pinOf ( kind , def )
pins . value = pins . value . includes ( key ) ? pins . value . filter ( k = > k !== key ) : [ . . . pins . value , key ]
try {
localStorage . setItem ( PIN_KEY , JSON . stringify ( pins . value ) )
} catch { }
}
function unpin ( key : string ) {
pins . value = pins . value . filter ( k = > k !== key )
try {
localStorage . setItem ( PIN_KEY , JSON . stringify ( pins . value ) )
} catch { }
}
/** The pinned parts as they stand in this project. */
const pinned = computed < PinnedPart [ ] > ( ( ) = >
pins . value . flatMap ( ( pin ) : PinnedPart [ ] = > {
if ( pin . startsWith ( 'name:' ) ) {
const name = pin . slice ( 5 )
const d = ed . project . value . components . find ( c = > c . name === name && c . id !== ed . def . value . id ) ? ? ed . project . value . components . find ( c = > c . name === name )
const usable = ! ! d && d . id !== ed . def . value . id && ed . canPlace ( d . id ) && defUsable ( ed . project . value , d )
return [ { pin , kind : 'chip' as NodeKind , chip : d?.id , name , icon : 'lucide:box' , missing : ! usable } ]
}
const p = BASIC_PARTS . find ( b = > b . kind === pin )
return p ? [ { pin , kind : p.kind , name : p.name , icon : p.icon , key : p.key , missing : ! ed . canPlaceKind ( p . kind ) } ] : [ ]
} ) ,
)
return { place , dragStart , dragEnd , lockedHint , pinned , isPinned , togglePin , unpin }
}