Aller au contenu

Sandbricks

Layout, run and deploy: projects/sandbricks/README.md. Import boundary: AGENTS.md, enforced by Biome. PR scope: projects/sandbricks only, enforced by CI — see README § PR scope. Components, tokens, pitfalls and wording: projects/common/uimmo/DESIGN.md.

Pick the mode

Both live in src/prototypes/<name>/, which the prototype owns entirely (see README).

  • Document when the prototype is pages, navigation and form fields. The runner renders it, and it opens as a self-contained /run?doc= link.
  • Hand-coded screen (+ a route in src/app/(prototype)/) when it reuses a front-mobile-app or app-pdp-financement component with its modals, or needs behaviour a descriptor cannot express.

Document

  • Build nodes with @sandbricks/document/nodes (stack, leaf, text, navigate, back, showWhen). A raw node literal only for a container other than Stack (e.g. Scroll).
  • Node ids are unique across the whole prototype — validatePrototype rejects duplicates. Two inputs share a value only through a groupProp (e.g. RadioCard.group): the field key is the group, else the node id, and visibleWhen.field points at that key.
  • RadioCards with the same group share one field keyed by the group name: it holds the checked card's node id, so showWhen reads { field: '<group>', equals: '<card id>' }.
  • Check src/registry before adding a descriptor. A new one uses defineDescriptor and renders a uimmo component. outsideDs: true only when uimmo has no equivalent — it counts as a workaround.
  • A descriptor only one prototype uses stays in src/prototypes/<name>/descriptors.tsx: the shared registry outlives every prototype. Spread it into prototypeDescriptors in src/registry/registry.ts: the display panel lists those as Nouveau.
  • validatePrototype runs when the link opens: an unknown component, prop or page fails there, not at typecheck. Open the prototype once before calling it done.

Hand-coded screen

  • The route src/app/(prototype)/<route>.tsx holds only export default of the screen.
  • Fake data uses the real view types from @bricks-common/api-communication (PDP: @bricks-common/api-communication-project-financing) and their branded constructors (Cents, nanoCents, Percentage, id schemas) — the presentational components expect them. Reuse PDP fixtures (@pdp-modules/*/utils/*Fixtures) before writing new ones.
  • Reuse a whole screen through its *UI file, never the container (it calls the API). Rebuild from sections only when the prototype changes the layout: a rebuilt screen drops blocks silently.
  • Handlers mutate local useState and fake latency with a named delay constant, so loading states stay visible.
  • Wrap a value that must not ship in placeholder() (@sandbricks/mocks/placeholder) and prefix a provisional translation with [PROTO]: the app lint then blocks the copy until real data replaces it. It also rejects fixture, mock and story-arg imports outside stories and tests.

Display panel

  • Every route in src/app/(prototype)/ gets the panel. Choices live in the URL (etape, frame, etat, one param per component), so a link reopens the same display.
  • Change a component by copying it into the prototype folder, never by editing the product or Uimmo: Name.tsx exporting Name. Named like a product component, it is Modifié (Actuelle = product); otherwise Nouveau. Each Name.<n>.tsx adds a version. No setting to write.
  • The screen renders the product or base component; Metro swaps in the URL's version and Isoler wraps it. Never switch versions in the screen. Restart dev after adding a copy: Metro reads the swaps at start.
  • display:scan lists the page and every modal opened with openModal or registered with useModalScreens, and puts each component on the screen that renders it. typecheck fails when src/prototypes/generated/ is stale: run pnpm display:scan first.
  • A route in prototypeDisplays.ts replaces the scan only for states: true (etat): a promise the screen renders each state. Never declare one it ignores.
  • Selecting a modal screen opens it; closing it returns to the page.
  • /run builds its panel from the document: each page is a screen.

Done means

  • pnpm --filter @bricks/sandbricks typecheck, lint and build:web pass.
  • The prototype opens in Chromium with no console error.

This rule holds contracts only. Once the document model and the editor settle, the procedure (mode choice, scaffold, verification, share link) becomes a /sandbricks skill.