Skip to content

feat: expose the chart display settings and getNumberingSystem() to hosts - #27

Merged
ZoliQua merged 1 commit into
ZoliQua:mainfrom
odontodev:feat/display-settings-api
Sep 22, 2026
Merged

ZoliQua merged 1 commit into
ZoliQua:mainfrom
odontodev:feat/display-settings-api

Conversation

@odontodev

Copy link
Copy Markdown
Contributor

Follow-up to #26, same motivation: a host app that persists the doctor's preferences through onStateChange + the engine getters.

Problem

Five Settings-modal values are React state private to the provider — no getter, no setter, no prop, no notification:

  • Settings → Odontogram: screenToothSpacing, screenToothNumberSize
  • Settings → Tooth details: selectionColor, selectionBorderStyle
  • Settings → General: toothInfo

A host can neither read them after the doctor changes them nor restore them on the next mount, so they silently reset to defaults on every reload. setNumberingSystem() also has no getter, so numbering cannot be persisted either.

Change

  • New src/state/displaySettings.ts following the perioViewMode precedent: module let + getter + setter per value. Setters sanitize to the literal set (setSelectionColor accepts #rrggbb only and lowercases), early-return when unchanged and call notifyStateChange() on a real change.
  • The provider mirrors them through onStateChange (same block as the perioViewMode mirror), and the modal on* handlers write the engine instead of local state — so a host calling the setters directly re-renders the chart, and the modal never shows a stale value.
  • Five controlled props on OdontogramProvider / OdontogramShell (screenToothSpacing, screenToothNumberSize, selectionColor, selectionBorderStyle, toothInfo), defined-gated like the fillings props from feat: expose fillings settings as controlled props on OdontogramShell (issue #17) #19.
  • getNumberingSystem().
  • The three types (ScreenToothSpacing, ScreenToothNumberSize, SelectionBorderStyle) move to the state module; SettingsModal.tsx re-exports them, and App.tsx exports them publicly.

Defaults are unchanged, so the shell DOM golden is byte-identical. The API-surface golden is re-captured for the eleven new exports (API_SURFACE_WRITE=1). The 19 test files that mock ../odontogram with an explicit object gain stubs for the new getters/setters.

Tests

display-settings.test.tsx: each setter (default, notifies on change, silent when unchanged, sanitizing), getNumberingSystem, and the provider round-trip — defaults render as before, controlled props write the engine and the chart's data-screen-spacing / data-tooth-num / --odon-select-* / tooth-info section, a host setter after mount re-renders, and the Settings modal selects write through to the engine.

Full suite, tsc -b --noEmit, eslint and npm run build: clean.

…osts

Settings -> Odontogram chart styling (screenToothSpacing, screenToothNumberSize,
selectionColor, selectionBorderStyle) and the tooth-information toggle were
React state private to the provider, so a host persisting the doctor's
preferences could neither read them after a change nor restore them on the
next mount. They now follow the perioViewMode precedent: a module getter and
an idempotent setter that notifies in src/state/displaySettings.ts, mirrored
into the provider through onStateChange, and each is a controlled prop on
OdontogramProvider/OdontogramShell (defined-gated like the fillings props).

setNumberingSystem() had no getter, so numbering could not be persisted
either; getNumberingSystem() fills that gap.

The API-surface golden is re-captured for the eleven new exports; the shell
DOM golden is untouched because the defaults are unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 20, 2026

Copy link
Copy Markdown

@odontodev is attempting to deploy a commit to the ZoliQua's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-odontogram-modul Ready Ready Preview Sep 22, 2026 5:42am UTC

@ZoliQua
ZoliQua merged commit 3984a22 into ZoliQua:main Sep 22, 2026
7 checks passed
ZoliQua added a commit that referenced this pull request Sep 22, 2026
…, #27)

Neither PR carried its documentation, which this project requires for a new
public API or a changed behaviour.

- CHANGELOG 2.6.0: an Added entry for the five display settings, their
  controlled props and getNumberingSystem(), and a Fixed entry for the three
  mutations that never reached onStateChange. Both credit @odontodev. The Fixed
  entry also names the consequence the PR did not: onStateChange now fires for
  settings changes, so a subscriber persisting the export payload is woken by a
  Settings toggle that does not change the payload (debounced, one redundant
  write at most).
- All twelve language READMEs: the five props in the props table, six rows in
  the API table (getNumberingSystem plus the five getter/setter pairs), and
  @odontodev's contributor line extended.
- The engine's CLAUDE.md gains a "Session settings" section: where the display
  settings live and the contract every session setter follows (sanitize,
  early-return when unchanged, notify on a real change) — so the next setter
  added does not repeat the omission #26 fixed.

This branch was successfully deployed

1 active deployment
Preview — c0db7555 Deployed Sep 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants