Repository navigation
Add the canvas type axis and an axis-keyed ruleset table - #235
Merged
Merged
Conversation
Phase 30 slice B. canvas_create takes type/device (mobile: device artboard and root safeArea insets the renderer adds to the root padding); canvas_set_type re-declares without touching the root. Genre and preset relaxations move into one ruleset table keyed by type, genre and preset that composes by union and can enable or disable rule ids. Evaluate and autofix report the surface, and generate_design_system pivots on the device body size on mobile.
canvas_set_type's hint now uses the renderer's safeArea validity rule, canvas_autofix reads fresh in propose mode, and clearing a type drops an emptied metadata bag. Docs stop implying mobile rules run yet and answer the cold-read gaps; test-surface covers the mutation survivors.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 30 slice B. A canvas could say what it is for (genre) and what style it uses (preset), but not what medium it is on. This PR adds that third declaration, the canvas type (
webormobile), and moves the genre and preset relaxations into one ruleset table that all three declarations feed.The canvas type
canvas_createacceptstypeanddevice. Withtype: "mobile"the artboard defaults to the device size (390×844 foriphone-390, the only profile so far), and the root gets the device's safe-area insets assafeArea: { top: 47, bottom: 34 }. An explicitwidthorheightstill wins for its side. Passingdevicewithouttype: "mobile", or naming an unknown device, is an error. The result reportstype,typeSource(declaredordefault), and for a mobile canvasdeviceandsafeArea. A canvas created withouttypeis unchanged and is judged as web.The renderer adds the root's
safeAreato its own top and bottom padding, at exact pixels even when the authored padding scales fluidly. In-flow content therefore never sits under the status bar or the home indicator, and the root's fill paints the bands. A root withoutsafeArearenders byte-identically to before.A new tool,
canvas_set_type, declares or clears the type on an existing canvas. It writes only the declaration. It never resizes the artboard or writessafeArea, because either would reflow content the agent already placed. When a mobile result is missing either, itshintnames the exactbatch_designop that adds it. The declaration is metadata, so it does not move theversionHash. State variants copy the type.The type never changes what renders. It selects rules and generator defaults only, so a CI check of a mobile canvas's hash means the same as for a web canvas.
One ruleset table
The genre and preset relaxation tables now live in
src/surfaces.tsas one table keyed by axis (base, type, genre, preset). Each row can relax cliché tells and turn rule ids on or off, and the active rules are the union of the rows that apply. A rule that one row enables and another disables stays on and is reported as a conflict, so combining declarations can never switch a guardrail off.Every enable and disable list is empty in this slice, the mobile row included. A rule id lands in the same change as the check that honours it, and the mobile checks are slice C. Genre behaviour is unchanged: the genre report matched master byte for byte across 360 combinations of preset, stored genre and per-call genre.
The surface report
canvas_evaluateandcanvas_autofixalways return asurfacefield:{ type, device, source, rulesOn, rulesOff, conflicts }. It appears on every mode and category filter, and on the empty-canvas result too. The viewer's score cache now keys on the type and device as well, so re-declaring a canvas re-scores it in the gallery.A mobile type scale
generate_design_systemon a mobile canvas pivots its type scale on the device body size: 17px for every personality exceptdata-dense, which uses 16px. No generated size falls below 11px. An explicitbaseSizestill wins. The result reports the generated pivot asbaseSizeandbaseSizeSource. A$bodyinherited from a workspace or project design system is still preserved by default and listed indesignSystemConflicts, so the docs say to passpreserveInherited: falseto take the mobile body.Device constants
Before the profile table landed, every constant was re-checked against Apple's HIG through its JSON and Markdown endpoints. No value changed. Apple's own pages confirm the 44pt touch target, Body 17, Caption 2 at 11, and "five or fewer" labeled tabs. The insets come from secondary tables that agree with each other. The bar heights, row heights, side margin and home indicator have no Apple source that could be read, so the spec's table now marks them as house values.
Smaller fixes found on the way
canvas_autofixnow reloads the canvas from disk in propose mode too. Before, its proposals and reports could describe a stale copy after a pull or hand-edit.canvas_set_type's hint and the renderer share one rule for whichsafeAreavalues count, so the hint never treats a value the renderer ignores as reserved.Docs
canvas_create,canvas_set_type,canvas_evaluate,canvas_autofixandgenerate_design_systemdocstrings,INSTRUCTIONS,GOTCHAS, the README, and a new "Declaring the medium" section indocs/GUIDELINES.mdcover the type. They state that no mobile rule ids are registered yet. Two GUIDELINES lines that still taughtwidth: 390, height: 844for a phone screen now point attype: "mobile", andsafeAreais listed as a node property.test-discoverability.tsreads the ruleset table directly instead of parsingevaluate.ts, and checks that every canvas type, device profile and surface field is documented. The phase spec records what was built in a slice B "As built" block.Testing
test-surface.ts(Chrome-free, 103 checks): creation defaults and errors,canvas_set_typestorage, persistence and on-disk freshness, variants, ruleset union and conflicts, the surface report,safeArearendering for every padding form, render invariance under the type, the score cache key, and the real tools over MCP stdio.test-design-language.tscovers the mobile pivot for all four personalities.npm run test:fullpasses (107/107), andtscis clean.