From 382fdddc68b5dc6f361f6924970c84b748f1bbe8 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sat, 20 Jun 2026 14:47:08 +0200 Subject: [PATCH] feat(editor): give each Stock a unit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A Stock can carry a display unit (°C, people, $, …): a new optional field, an inspector text input, validation + round-trip in io, and a readout beside the live value on the canvas. Equip the demonstrative samples (Water L, Balance $, Coffee °C, Population/Epidemic people, Yeast cells). Also bumps the fill gauge opacity for a more vivid level. --- src/components/Inspector.vue | 40 ++++++++++++++++++++++-------- src/components/nodes/StockNode.vue | 5 ++-- src/model/io.ts | 3 +++ src/model/samples.ts | 8 ++++++ src/model/types.ts | 2 ++ src/store/model.ts | 12 +++++++++ 6 files changed, 57 insertions(+), 13 deletions(-) diff --git a/src/components/Inspector.vue b/src/components/Inspector.vue index 4f43401..615a025 100644 --- a/src/components/Inspector.vue +++ b/src/components/Inspector.vue @@ -62,6 +62,12 @@ function onInitial(event: Event): void { if (Number.isFinite(n)) store.setInitialValue(el.id, n) } +function onUnit(event: Event): void { + const el = element.value + if (el?.kind !== "stock") return + store.setUnit(el.id, (event.target as HTMLInputElement).value) +} + function onKind(event: Event): void { const el = element.value if (el?.kind !== "flow" && el?.kind !== "converter") return @@ -97,17 +103,29 @@ const RULE_HINT: Record = { {{ KIND_LABEL[element.kind] }} - - + +