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 afront-mobile-apporapp-pdp-financementcomponent 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 thanStack(e.g.Scroll). - Node ids are unique across the whole prototype —
validatePrototyperejects duplicates. Two inputs share a value only through agroupProp(e.g.RadioCard.group): the field key is the group, else the node id, andvisibleWhen.fieldpoints at that key. RadioCards with the samegroupshare one field keyed by the group name: it holds the checked card's node id, soshowWhenreads{ field: '<group>', equals: '<card id>' }.- Check
src/registrybefore adding a descriptor. A new one usesdefineDescriptorand renders a uimmo component.outsideDs: trueonly 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 intoprototypeDescriptorsinsrc/registry/registry.ts: the display panel lists those as Nouveau. validatePrototyperuns 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>.tsxholds onlyexport defaultof 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
*UIfile, 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
useStateand 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.tsxexportingName. Named like a product component, it is Modifié (Actuelle = product); otherwise Nouveau. EachName.<n>.tsxadds 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
devafter adding a copy: Metro reads the swaps at start. display:scanlists the page and every modal opened withopenModalor registered withuseModalScreens, and puts each component on the screen that renders it.typecheckfails whensrc/prototypes/generated/is stale: runpnpm display:scanfirst.- A route in
prototypeDisplays.tsreplaces the scan only forstates: 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.
/runbuilds its panel from the document: each page is a screen.
Done means¶
pnpm --filter @bricks/sandbricks typecheck,lintandbuild:webpass.- 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.