From 03a4d558340b443b4c49b0b1fceaa911b041a130 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Sat, 17 Oct 2026 12:49:38 +0200 Subject: [PATCH] A logigate: NAND-only logic editor and simulator with components, challenges and examples Draw circuits from NAND gates, package them as components and reuse them. Event-driven simulation runs live while drawing. IEC/ANSI symbols, truth tables, 17 challenges, example library up to a 4-bit counter. Deploys to edgerealm like autismus-spektrum (logicate.blax.at). Co-Authored-By: Claude Opus 5.5 (1M context) --- .dockerignore | 19 + .editorconfig | 18 + .env.example | 2 + .gitignore | 35 + Dockerfile.build | 13 + Dockerfile.serve | 12 + README.md | 41 + app/app.vue | 3 + app/assets/css/main.css | 1147 +++++ app/components/editor/Canvas.vue | 564 +++ app/components/editor/Help.vue | 64 + app/components/editor/Inspector.vue | 247 + app/components/editor/NodeView.vue | 140 + app/components/editor/Palette.vue | 140 + app/components/editor/Toolbar.vue | 122 + app/composables/useEditor.ts | 509 ++ app/lib/draw.ts | 103 + app/lib/logic/analyze.ts | 124 + app/lib/logic/challenges.ts | 100 + app/lib/logic/compile.ts | 254 + app/lib/logic/examples.ts | 274 ++ app/lib/logic/geometry.ts | 204 + app/lib/logic/ops.ts | 292 ++ app/lib/logic/sim.ts | 110 + app/lib/logic/storage.ts | 50 + app/lib/logic/types.ts | 76 + app/pages/index.vue | 31 + deploy.sh | 112 + docker-compose.yml | 45 + nuxt.config.ts | 76 + package.json | 29 + pnpm-lock.yaml | 6974 +++++++++++++++++++++++++++ pnpm-workspace.yaml | 5 + public/favicon.svg | 1 + public/robots.txt | 2 + tests/logic.test.ts | 165 + tsconfig.json | 1 + vitest.config.ts | 5 + 38 files changed, 12109 insertions(+) create mode 100644 .dockerignore create mode 100644 .editorconfig create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 Dockerfile.build create mode 100644 Dockerfile.serve create mode 100644 README.md create mode 100644 app/app.vue create mode 100644 app/assets/css/main.css create mode 100644 app/components/editor/Canvas.vue create mode 100644 app/components/editor/Help.vue create mode 100644 app/components/editor/Inspector.vue create mode 100644 app/components/editor/NodeView.vue create mode 100644 app/components/editor/Palette.vue create mode 100644 app/components/editor/Toolbar.vue create mode 100644 app/composables/useEditor.ts create mode 100644 app/lib/draw.ts create mode 100644 app/lib/logic/analyze.ts create mode 100644 app/lib/logic/challenges.ts create mode 100644 app/lib/logic/compile.ts create mode 100644 app/lib/logic/examples.ts create mode 100644 app/lib/logic/geometry.ts create mode 100644 app/lib/logic/ops.ts create mode 100644 app/lib/logic/sim.ts create mode 100644 app/lib/logic/storage.ts create mode 100644 app/lib/logic/types.ts create mode 100644 app/pages/index.vue create mode 100755 deploy.sh create mode 100644 docker-compose.yml create mode 100644 nuxt.config.ts create mode 100644 package.json create mode 100644 pnpm-lock.yaml create mode 100644 pnpm-workspace.yaml create mode 100644 public/favicon.svg create mode 100644 public/robots.txt create mode 100644 tests/logic.test.ts create mode 100644 tsconfig.json create mode 100644 vitest.config.ts diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c0431b1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,19 @@ +.git +.gitignore +.env +.env.* +node_modules +docker-data +.nuxt +.output +.nitro +.data +.cache +dist +_* +localhost.pem +localhost-key.pem +*.pem +*.key +*.map +*.log diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..22d31f4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ + +[*] +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 2 + +[*.yml] +indent_style = space +indent_size = 2 + +[*.xml] +indent_style = space +indent_size = 4 + +[*.gradle] +indent_style = space +indent_size = 4 diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..ccc95f4 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +# Canonical origin, used for absolute links in meta tags. +NUXT_PUBLIC_SITE_URL=https://logicate.blax.at diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8ddf438 --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +# Nuxt build output +.nuxt +.output +.data +.nitro +.cache +dist + +# Node +node_modules +*.log +*.tsbuildinfo + +# Env (commit only the example) +.env +.env.* +!.env.example + +# IDE +.vscode +.idea +*.swp + +# OS +.DS_Store + +# Throwaway artefacts +_* + +# Docker volumes +docker-data/ + +# Playwright artefacts +test-results/ +playwright-report/ diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..e59c5f0 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,13 @@ +# Reusable build environment. The source is bind-mounted, not copied. +FROM node:current-slim + +WORKDIR /app +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 +# Lets pnpm purge a stale bind-mounted node_modules without a TTY prompt. +ENV CI=true + +RUN npm install -g --force corepack && corepack enable + +CMD ["sh", "-c", "pnpm install --frozen-lockfile && pnpm run build && find .output -type f -name '*.map' -delete && find .output -type f \\( -name '*.js' -o -name '*.mjs' -o -name '*.css' \\) -exec sed -i -e '/^[[:space:]]*\\/\\/# sourceMappingURL=.*$/d' -e '/^[[:space:]]*\\/\\*# sourceMappingURL=.*\\*\\/[[:space:]]*$/d' {} +"] diff --git a/Dockerfile.serve b/Dockerfile.serve new file mode 100644 index 0000000..cf987b9 --- /dev/null +++ b/Dockerfile.serve @@ -0,0 +1,12 @@ +# Lightweight server — .output is bind-mounted from the host. +FROM node:current-slim + +WORKDIR /app + +ENV HOST=0.0.0.0 +ENV PORT=3000 +ENV NODE_ENV=production + +EXPOSE 3000 + +CMD ["node", ".output/server/index.mjs"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..7ca8550 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# Logigate + +Logic circuit editor and simulator at , in the spirit of the game "Turing Complete". NAND is the only gate. You draw circuits with it, package them as components, and reuse those in bigger circuits, up to a CPU. Everything runs live while you draw: green wires carry a 1, grey wires a 0. + +Nuxt 4 (client-only, `ssr: false`), Tailwind CSS v4, Lucide icons via `@nuxt/icon`, Inter and JetBrains Mono self-hosted via `@nuxt/fonts`. No backend, no tracking: projects live in the browser's localStorage and can be exported as JSON. + +## What it does + +- Parts: NAND, input switch, output pin, lamp, push button, clock, constant 1, ground, hex display, note. +- Every circuit is a component. Its input and output nodes become its pins, ordered top to bottom. Double-click a component to open it. +- 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. +- Truth table, NAND count, gate delay, and loop detection for the open circuit. +- 17 challenges (NOT up to a D flip-flop) checked against a truth table or a step sequence. +- Example library, all built from NAND: NOT, AND, OR, NOR, XOR, XNOR, Mux, Half/Full Adder, SR Latch, D Latch, D Flip-Flop, Register 4, Increment 4, Adder 4, Counter 4, and a counter demo with a hex display. + +## How the simulation works + +All in [app/lib/logic/](app/lib/logic/), plain TypeScript with no Vue dependency: + +- `compile.ts` flattens the component tree into a list of NAND gates over numbered nets. Chip boundaries and pins are aliases, merged with union-find. Net 0 is constant 0, net 1 constant 1. +- `sim.ts` is event-driven: a net change queues the gates that read it, and gates run in FIFO order on the newest values. NAND latches settle deterministically; a loop with an odd number of inversions never settles and the top bar shows "Oscillating". +- Gate outputs are keyed by their path ("chipNode/chipNode/nand"), so latch state survives editing. +- `analyze.ts` builds truth tables, counts NANDs, computes the longest gate path, and runs challenge tests. +- `examples.ts` builds the example library with a small builder; `ops.ts` holds project edits (package selection, copy/paste, prune dangling wires, recursion check). + +The editor UI is in [app/components/editor/](app/components/editor/) with state in [app/composables/useEditor.ts](app/composables/useEditor.ts). + +## Develop + +```bash +pnpm install +pnpm dev # http://localhost:3000 +pnpm test # engine tests (vitest) +pnpm typecheck +pnpm build # .output/ +``` + +## Deploy + +Same pattern as autismus-spektrum. On edgerealm the repo lives in `/mnt/HC_Volume_102040804/srv/logigate`; run `./deploy.sh` there. It pulls, builds in a one-shot container and recreates the `logigate` container. Host nginx terminates TLS with the `*.blax.at` wildcard cert and forwards to Traefik, which routes `logicate.blax.at` and `logigate.blax.at` by the labels in [docker-compose.yml](docker-compose.yml). diff --git a/app/app.vue b/app/app.vue new file mode 100644 index 0000000..8f62b8b --- /dev/null +++ b/app/app.vue @@ -0,0 +1,3 @@ + diff --git a/app/assets/css/main.css b/app/assets/css/main.css new file mode 100644 index 0000000..b2e1ace --- /dev/null +++ b/app/assets/css/main.css @@ -0,0 +1,1147 @@ +@import "tailwindcss"; + +@source "../../../app/**/*.{vue,ts}"; + +@theme { + --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif; + --font-mono: "JetBrains Mono", ui-monospace, monospace; +} + +/* Dark workbench palette. Green = a wire carrying 1, grey = 0. */ +:root { + --bg: #0e1116; + --panel: #13181f; + --panel-2: #1a212b; + --border: #252e3a; + --text: #dbe2ea; + --muted: #8592a3; + --accent: #4cc2ff; + --on: #3ddc84; + --on-dim: rgb(61 220 132 / 0.22); + --off: #3b4554; + --chip: #18202a; + --chip-stroke: #5a6779; + --danger: #ff6b6b; + --lamp: #ffd34d; + color-scheme: dark; +} + +html, +body, +#__nuxt { + height: 100%; +} + +body { + margin: 0; + background: var(--bg); + color: var(--text); + font-family: var(--font-sans); + font-size: 14px; + overflow: hidden; + -webkit-font-smoothing: antialiased; +} + +kbd { + font-family: var(--font-mono); + font-size: 10px; + line-height: 1; + padding: 2px 4px; + border: 1px solid var(--border); + border-bottom-width: 2px; + border-radius: 4px; + color: var(--muted); + background: var(--panel-2); +} + +/* ── Layout ─────────────────────────────────────────────────────── */ +.app { + display: grid; + grid-template-rows: 48px 1fr; + height: 100dvh; +} + +.workspace { + display: grid; + grid-template-columns: 236px 1fr 300px; + min-height: 0; +} + +.stage { + position: relative; + min-width: 0; + overflow: hidden; +} + +.palette, +.inspector { + background: var(--panel); + min-height: 0; + display: flex; + flex-direction: column; +} + +.palette { + border-right: 1px solid var(--border); +} + +.inspector { + border-left: 1px solid var(--border); +} + +.scroll { + overflow-y: auto; + flex: 1; + min-height: 0; + scrollbar-width: thin; + scrollbar-color: var(--border) transparent; +} + +@media (max-width: 1100px) { + .workspace { + grid-template-columns: 210px 1fr 260px; + } +} + +@media (max-width: 820px) { + .workspace { + grid-template-columns: 1fr; + grid-template-rows: 1fr 40%; + } + .palette { + display: none; + } + .inspector { + border-left: 0; + border-top: 1px solid var(--border); + } +} + +/* ── Toolbar ────────────────────────────────────────────────────── */ +.toolbar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + padding: 0 10px; + background: var(--panel); + border-bottom: 1px solid var(--border); + min-width: 0; +} + +.brand { + display: flex; + align-items: center; + gap: 8px; + font-weight: 700; + letter-spacing: -0.01em; + color: var(--on); + padding-right: 6px; +} + +.brand span { + color: var(--text); +} + +.tb-btn { + display: inline-flex; + align-items: center; + gap: 6px; + height: 32px; + padding: 0 8px; + border-radius: 6px; + color: var(--text); + font-size: 13px; + max-width: 180px; +} + +.tb-btn:hover:not(:disabled) { + background: var(--panel-2); +} + +.tb-btn.active { + color: var(--accent); + background: rgb(76 194 255 / 0.12); +} + +.tb-btn:disabled, +.tb-select:disabled { + opacity: 0.35; + cursor: not-allowed; +} + +.tb-select, +.circuit-select select { + height: 32px; + border-radius: 6px; + background: var(--panel-2); + border: 1px solid var(--border); + color: var(--text); + font-size: 13px; + padding: 0 6px; +} + +.circuit-select { + display: flex; + align-items: center; + gap: 6px; + min-width: 0; +} + +.circuit-select select { + max-width: 220px; + font-weight: 600; +} + +.cycles { + font-family: var(--font-mono); + font-size: 12px; + color: var(--muted); + padding: 0 4px; +} + +.status { + display: inline-flex; + align-items: center; + gap: 6px; + font-size: 12px; + color: var(--muted); + padding: 4px 8px; + border-radius: 999px; + background: var(--panel-2); +} + +.status .dot { + width: 7px; + height: 7px; + border-radius: 50%; + background: var(--on); +} + +.status.busy .dot { + background: var(--lamp); +} + +.status.oscillating { + color: var(--danger); +} + +.status.oscillating .dot { + background: var(--danger); +} + +.seg { + display: inline-flex; + border: 1px solid var(--border); + border-radius: 6px; + overflow: hidden; +} + +.seg button { + font-size: 12px; + font-weight: 600; + padding: 0 8px; + height: 30px; + color: var(--muted); +} + +.seg button.active { + background: rgb(76 194 255 / 0.15); + color: var(--accent); +} + +.menu-backdrop { + position: fixed; + inset: 0; + z-index: 40; +} + +.menu { + position: absolute; + right: 0; + top: 38px; + z-index: 41; + width: 260px; + padding: 6px; + background: var(--panel-2); + border: 1px solid var(--border); + border-radius: 8px; + box-shadow: 0 12px 30px rgb(0 0 0 / 0.45); +} + +.menu > button { + display: flex; + width: 100%; + align-items: center; + gap: 8px; + padding: 7px 8px; + border-radius: 5px; + font-size: 13px; + text-align: left; +} + +.menu > button:hover { + background: var(--panel); +} + +.menu hr { + border: 0; + border-top: 1px solid var(--border); + margin: 4px 0; +} + +/* ── Palette ────────────────────────────────────────────────────── */ +.tabs { + display: flex; + border-bottom: 1px solid var(--border); +} + +.tabs button { + flex: 1; + height: 38px; + font-size: 13px; + font-weight: 600; + color: var(--muted); + border-bottom: 2px solid transparent; +} + +.tabs button.active { + color: var(--text); + border-bottom-color: var(--accent); +} + +.tabs .count { + font-family: var(--font-mono); + font-size: 10px; + margin-left: 4px; + color: var(--muted); +} + +.palette h3, +.inspector h3 { + font-size: 11px; + font-weight: 700; + letter-spacing: 0.06em; + text-transform: uppercase; + color: var(--muted); +} + +.palette h3 { + padding: 14px 12px 6px; +} + +.items { + padding: 0 6px; +} + +.item { + display: flex; + align-items: center; + gap: 8px; + width: 100%; + padding: 5px 6px; + border-radius: 6px; + font-size: 13px; + text-align: left; + cursor: grab; +} + +.item:hover { + background: var(--panel-2); +} + +.item.active { + background: rgb(76 194 255 / 0.14); + color: var(--accent); +} + +.item.current { + color: var(--accent); +} + +.item.blocked:not(.current) { + opacity: 0.4; + cursor: not-allowed; +} + +.editing { + font-size: 10px; + color: var(--accent); +} + +.nand-badge { + display: inline-grid; + place-items: center; + width: 16px; + height: 16px; + border: 1.5px solid var(--on); + border-radius: 3px; + font-family: var(--font-mono); + font-size: 10px; + font-weight: 700; + color: var(--on); +} + +.comp-row { + display: flex; + align-items: center; +} + +.comp-row .open { + opacity: 0; + padding: 5px; + border-radius: 5px; + color: var(--muted); +} + +.comp-row:hover .open { + opacity: 1; +} + +.comp-row .open:hover { + background: var(--panel-2); + color: var(--text); +} + +.search { + display: flex; + align-items: center; + gap: 6px; + margin: 14px 10px 0; + padding: 0 8px; + border: 1px solid var(--border); + border-radius: 6px; + background: var(--panel-2); +} + +.search input { + background: transparent; + height: 30px; + outline: none; + font-size: 13px; + width: 100%; +} + +.intro { + padding: 12px; + font-size: 13px; + color: var(--muted); + line-height: 1.5; +} + +.challenges { + padding: 0 8px 16px; + display: grid; + gap: 6px; +} + +.challenges li { + padding: 8px; + border: 1px solid var(--border); + border-radius: 8px; + background: var(--panel-2); +} + +.challenges li.solved { + border-color: rgb(61 220 132 / 0.35); +} + +.challenges p { + font-size: 12px; + color: var(--muted); + margin-top: 4px; + line-height: 1.45; +} + +.challenges .pins, +.challenge .pins { + font-family: var(--font-mono); + font-size: 11px; +} + +/* ── Inspector ──────────────────────────────────────────────────── */ +.inspector section { + padding: 14px 14px; + border-bottom: 1px solid var(--border); +} + +.inspector h3 { + display: flex; + align-items: center; + gap: 6px; + margin-bottom: 10px; +} + +.field { + display: block; + margin-bottom: 10px; +} + +.field > span { + display: block; + font-size: 12px; + color: var(--muted); + margin-bottom: 4px; +} + +.field input, +.field textarea, +.field select { + width: 100%; + background: var(--panel-2); + border: 1px solid var(--border); + border-radius: 6px; + padding: 6px 8px; + font-size: 13px; + color: var(--text); + outline: none; +} + +.field input:focus, +.field textarea:focus, +.field select:focus { + border-color: var(--accent); +} + +.field textarea { + resize: vertical; + line-height: 1.4; +} + +.hint { + font-size: 12px; + color: var(--muted); + line-height: 1.5; + margin-bottom: 10px; +} + +.hint a { + color: var(--accent); +} + +.stats { + display: grid; + grid-template-columns: auto 1fr; + gap: 4px 12px; + font-size: 12px; + margin: 2px 0 12px; +} + +.stats dt { + color: var(--muted); +} + +.stats dd { + font-family: var(--font-mono); + text-align: right; +} + +.btn, +.btn-sm { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 6px; + border-radius: 6px; + font-weight: 600; + background: var(--panel-2); + border: 1px solid var(--border); + color: var(--text); +} + +.btn { + height: 32px; + padding: 0 12px; + font-size: 13px; +} + +.btn-sm { + height: 24px; + padding: 0 8px; + font-size: 12px; +} + +.btn:hover, +.btn-sm:hover { + border-color: var(--chip-stroke); +} + +.btn-primary { + background: var(--accent); + border-color: var(--accent); + color: #06121a; +} + +.btn-primary:hover { + filter: brightness(1.1); +} + +.btn-ghost { + background: transparent; + color: var(--muted); +} + +.btn-danger { + background: var(--danger); + border-color: var(--danger); + color: #1a0505; +} + +.result { + display: flex; + gap: 6px; + margin-top: 10px; + font-size: 12px; + line-height: 1.45; +} + +.result.pass { + color: var(--on); +} + +.result.fail { + color: var(--danger); +} + +.challenge { + background: rgb(76 194 255 / 0.06); +} + +.challenge.solved { + background: rgb(61 220 132 / 0.07); +} + +.challenge p { + font-size: 13px; + line-height: 1.5; + margin-bottom: 8px; +} + +.challenge .pins { + color: var(--muted); +} + +.section-toggle { + display: flex; + align-items: center; + gap: 4px; + font-size: 11px; + font-weight: 700; + letter-spacing: 0.06em; + text-transform: uppercase; + color: var(--muted); +} + +.truth { + margin-top: 10px; + max-height: 340px; + overflow: auto; + border: 1px solid var(--border); + border-radius: 6px; +} + +.truth table { + width: 100%; + border-collapse: collapse; + font-family: var(--font-mono); + font-size: 12px; + text-align: center; +} + +.truth th { + position: sticky; + top: 0; + background: var(--panel-2); + color: var(--muted); + font-weight: 600; + padding: 4px 6px; +} + +.truth td { + padding: 2px 6px; + color: var(--muted); +} + +.truth td.one { + color: var(--on); + font-weight: 600; +} + +.truth .sep { + width: 1px; + padding: 0; + background: var(--border); +} + +.truth th.out { + color: var(--text); +} + +.truth tr.unstable td.out { + color: var(--danger); +} + +.actions { + display: flex; + gap: 8px; +} + +/* ── Canvas ─────────────────────────────────────────────────────── */ +.canvas { + position: absolute; + inset: 0; + touch-action: none; + user-select: none; + background: var(--bg); +} + +.grid-dot { + fill: #232c39; +} + +.grid-major { + fill: #303b4c; +} + +.wire-line { + fill: none; + stroke: var(--off); + stroke-width: 2; + stroke-linejoin: round; + stroke-linecap: round; +} + +.wire.on .wire-line { + stroke: var(--on); +} + +.wire.selected .wire-line { + stroke: var(--accent); + stroke-width: 3; +} + +.wire-flow { + fill: none; + stroke: #d2ffe6; + stroke-width: 2; + stroke-linecap: round; + stroke-dasharray: 1.5 10.5; + animation: flow 0.45s linear infinite; + pointer-events: none; + opacity: 0.85; +} + +@keyframes flow { + to { + stroke-dashoffset: -12; + } +} + +.wire-hit { + fill: none; + stroke: transparent; + stroke-width: 10; + cursor: pointer; +} + +.wire-hit.draggable { + cursor: ns-resize; +} + +.wire-hit.draggable.vertical { + cursor: ew-resize; +} + +.junction { + fill: var(--off); +} + +.junction.on { + fill: var(--on); +} + +.temp-wire { + fill: none; + stroke: var(--accent); + stroke-width: 2; + stroke-dasharray: 5 4; + pointer-events: none; +} + +.temp-wire.snapped { + stroke-dasharray: none; +} + +.box-select { + fill: rgb(76 194 255 / 0.08); + stroke: var(--accent); + stroke-dasharray: 4 3; + vector-effect: non-scaling-stroke; +} + +.node { + cursor: move; +} + +.node.ghost { + opacity: 0.55; + pointer-events: none; +} + +.node .body { + fill: var(--chip); + stroke: var(--chip-stroke); + stroke-width: 1.5; +} + +.node .body.prim { + fill: #172231; + stroke: #7d93ad; +} + +.node .chip { + fill: #1a2330; +} + +.node .chip.missing { + stroke: var(--danger); + stroke-dasharray: 4 3; +} + +.node .stub { + fill: none; + stroke: var(--chip-stroke); + stroke-width: 2; +} + +.node .stroke-only { + fill: none; + stroke: var(--chip-stroke); + stroke-width: 1.5; +} + +.gate-label { + fill: var(--text); + font-family: var(--font-mono); + font-size: 12px; + font-weight: 600; + pointer-events: none; +} + +.chip-name { + fill: var(--text); + font-size: 11px; + font-weight: 600; + pointer-events: none; +} + +.pin-label { + fill: var(--muted); + font-family: var(--font-mono); + font-size: 9px; + pointer-events: none; +} + +.pin-label.tiny { + font-size: 8px; +} + +.io-label { + fill: var(--text); + font-family: var(--font-mono); + font-size: 11px; + font-weight: 600; +} + +.switch { + fill: #2a3240; + stroke: #4c586b; + stroke-width: 1.5; + cursor: pointer; +} + +.switch.on { + fill: var(--on-dim); + stroke: var(--on); +} + +.knob { + fill: #e6edf5; + pointer-events: none; +} + +.terminal { + fill: #1f2632; + stroke: #5a6578; + stroke-width: 1.5; +} + +.terminal.on { + fill: var(--on-dim); + stroke: var(--on); +} + +.lamp { + fill: #1f2632; + stroke: #5a6578; + stroke-width: 1.5; +} + +.lamp.on { + fill: var(--lamp); + stroke: #ffe9a3; + filter: drop-shadow(0 0 6px rgb(255 211 77 / 0.75)); +} + +.lamp-cross { + stroke: #5a6578; + stroke-width: 1.5; +} + +.lamp-cross.on { + stroke: #8a6400; +} + +.const { + font-family: var(--font-mono); + font-size: 12px; + font-weight: 700; + fill: var(--on); +} + +.ground { + fill: none; + stroke: var(--chip-stroke); + stroke-width: 2; +} + +.wave { + fill: none; + stroke: var(--muted); + stroke-width: 1.5; +} + +.wave.on { + stroke: var(--on); +} + +.button { + fill: #3a4454; + stroke: #6b778a; + stroke-width: 1.5; + cursor: pointer; +} + +.button.on { + fill: var(--danger); + stroke: #ffb3b3; +} + +.display { + fill: #0a0d11; +} + +.seg { + stroke: #1e2731; + stroke-width: 3.4; + stroke-linecap: round; +} + +.seg.on { + stroke: #ff5a4f; + filter: drop-shadow(0 0 3px rgb(255 90 79 / 0.8)); +} + +.note { + fill: var(--muted); + font-size: 12px; +} + +.note-bg { + fill: transparent; +} + +.sel-outline { + fill: none; + stroke: var(--accent); + stroke-width: 1.5; + stroke-dasharray: 4 3; + pointer-events: none; +} + +.pin { + fill: #6b778a; + pointer-events: none; +} + +.pin.on { + fill: var(--on); +} + +.pin-hit { + fill: transparent; + cursor: crosshair; +} + +.pin-hit:hover { + fill: rgb(76 194 255 / 0.3); +} + +.zoom-controls { + position: absolute; + right: 12px; + bottom: 12px; + display: flex; + align-items: center; + gap: 2px; + padding: 3px; + background: var(--panel); + border: 1px solid var(--border); + border-radius: 8px; + font-family: var(--font-mono); + font-size: 11px; + color: var(--muted); +} + +.zoom-controls button { + display: grid; + place-items: center; + width: 26px; + height: 26px; + border-radius: 5px; + color: var(--text); +} + +.zoom-controls button:hover { + background: var(--panel-2); +} + +.zoom-controls span { + min-width: 40px; + text-align: center; +} + +.empty-hint { + position: absolute; + inset: 0; + display: grid; + place-content: center; + text-align: center; + gap: 6px; + color: var(--muted); + pointer-events: none; +} + +/* ── Overlays ───────────────────────────────────────────────────── */ +.toast { + position: fixed; + left: 50%; + bottom: 24px; + transform: translateX(-50%); + z-index: 60; + padding: 8px 14px; + border-radius: 8px; + font-size: 13px; + background: var(--panel-2); + border: 1px solid var(--border); + box-shadow: 0 10px 30px rgb(0 0 0 / 0.4); +} + +.toast.error { + border-color: var(--danger); + color: #ffc9c9; +} + +.placing-hint { + position: fixed; + left: 50%; + top: 60px; + transform: translateX(-50%); + z-index: 30; + padding: 6px 12px; + border-radius: 999px; + font-size: 12px; + color: var(--muted); + background: var(--panel); + border: 1px solid var(--border); + pointer-events: none; +} + +.fade-enter-active, +.fade-leave-active { + transition: opacity 0.2s; +} + +.fade-enter-from, +.fade-leave-to { + opacity: 0; +} + +.modal-backdrop { + position: fixed; + inset: 0; + z-index: 70; + display: grid; + place-items: center; + padding: 16px; + background: rgb(5 8 12 / 0.7); +} + +.modal { + width: min(640px, 100%); + max-height: calc(100dvh - 32px); + overflow-y: auto; + padding: 22px 24px; + background: var(--panel); + border: 1px solid var(--border); + border-radius: 12px; + box-shadow: 0 30px 80px rgb(0 0 0 / 0.5); +} + +.modal h2 { + font-size: 20px; + font-weight: 700; + letter-spacing: -0.01em; +} + +.modal h3 { + margin: 18px 0 8px; + font-size: 11px; + font-weight: 700; + letter-spacing: 0.06em; + text-transform: uppercase; + color: var(--muted); +} + +.steps { + margin-top: 14px; + padding-left: 20px; + list-style: decimal; + display: grid; + gap: 6px; + font-size: 13.5px; + line-height: 1.5; + color: #c3ccd6; +} + +.steps strong { + color: var(--text); +} + +.shortcuts { + display: grid; + grid-template-columns: minmax(150px, auto) 1fr; + gap: 3px 16px; + font-size: 12.5px; + margin-bottom: 14px; +} + +.shortcuts dt { + font-family: var(--font-mono); + font-size: 12px; + color: var(--accent); +} + +.shortcuts dd { + color: #c3ccd6; +} diff --git a/app/components/editor/Canvas.vue b/app/components/editor/Canvas.vue new file mode 100644 index 0000000..9c64dee --- /dev/null +++ b/app/components/editor/Canvas.vue @@ -0,0 +1,564 @@ + + + diff --git a/app/components/editor/Help.vue b/app/components/editor/Help.vue new file mode 100644 index 0000000..5457e6d --- /dev/null +++ b/app/components/editor/Help.vue @@ -0,0 +1,64 @@ + + + diff --git a/app/components/editor/Inspector.vue b/app/components/editor/Inspector.vue new file mode 100644 index 0000000..05bf1c2 --- /dev/null +++ b/app/components/editor/Inspector.vue @@ -0,0 +1,247 @@ + + +