fix(ui): F8-06 calculator polish — always 3-decimal display, mono font, input cap
Owner feedback round 2 on PR #61: - Pad every read-only calculator value to three decimals: tech labels, derived results (mass, speed, attack, defence, bombing, cargo capacity), planet MAT, planet build-rate, modernization cost, and the full-cargo capacity label all read as "1.000" instead of "1", matching the goal-seek back-solved input and the report. Drops thousands grouping so the same `fmt()` string also embeds cleanly in the read-only `<input type="number">` cell. - Switch label and input styling onto the existing `--font-mono` token (right-aligned, tabular-nums) so columns line up vertically across rows like a financial table. - Refuse a fourth decimal as the user types in every calculator number input (DWSC blocks, tech, MAT, custom load, lock value, modernization target tech): the `oninput` truncates the input text past three decimal digits and explicitly writes the truncated value back through `bind:value`, so Svelte's later reactive flush cannot undo the cap. - Doc + tests follow the rule (five new vitest cases covering the 3-decimal label format, the input cap on each input class, and the integer-padding rule for derived results).
This commit is contained in:
@@ -111,13 +111,19 @@ negative, the five blocks follow the engine value rules
|
||||
(`pkg/calc/validator.go`, surfaced per-field by
|
||||
`shipClassFieldErrors`), and a custom load may not exceed cargo capacity.
|
||||
|
||||
Every displayed number — the derived results and the goal-seek
|
||||
back-solved input — is rounded **up** to three decimals through the
|
||||
shared `pkg/calc/number.go.Ceil3` (bridged as `core.ceil3`), so a value
|
||||
is never shown lower than it is (a speed of 5.0003 reads 5.001). The
|
||||
engine keeps its own round-to-nearest `util.Fixed*`; `Ceil3` is a
|
||||
display-only helper that lives in `pkg/calc` so the UI and Go share one
|
||||
implementation.
|
||||
Every displayed number — the derived results, the inherited tech /
|
||||
planet MAT labels, and the goal-seek back-solved input — is rounded
|
||||
**up** to three decimals through the shared `pkg/calc/number.go.Ceil3`
|
||||
(bridged as `core.ceil3`) and always padded to three decimals so the
|
||||
column reads the same on integers and fractions alike (a speed of 20
|
||||
shows as `20.000`, of 5.0003 as `5.001`). Labels and inputs use the
|
||||
monospace stack from the design tokens (`--font-mono`) with
|
||||
right-aligned, tabular numerals so values line up vertically across
|
||||
rows. To match the display rule, every number input also refuses a
|
||||
fourth decimal as the user types: typing `1.2345` clamps the input to
|
||||
`1.234` on input. The engine keeps its own round-to-nearest
|
||||
`util.Fixed*`; `Ceil3` is a display-only helper that lives in `pkg/calc`
|
||||
so the UI and Go share one implementation.
|
||||
|
||||
## Create / load / delete
|
||||
|
||||
|
||||
Reference in New Issue
Block a user