feat: support physical dimension units (pt, mm, cm, in) for print/PDF design systems - #164
Open
SomSamantray wants to merge 5 commits into
Open
Conversation
zachshallbetter
added a commit
to zachshallbetter/design.md
that referenced
this pull request
Aug 11, 2026
Implemented support for axis-specific padding properties (paddingX and paddingY) inside component token definitions (resolves Issue google-labs-code#160). * Background & Motivation: - By default, the linter and spec support a uniform 'padding' sub-token for components. However, asymmetric layouts (e.g. button rows or inputs with larger horizontal than vertical insets) are standard in production design systems. Adding 'paddingX' and 'paddingY' solves this gap natively. - This matches common framework models (Tailwind's px/py, SwiftUI, Flutter) and avoids nested layout complexity (such as the schemas discussed in Issue google-labs-code#17). - This aligns with the philosophy of PR google-labs-code#89 (avoiding CSS property bloat like paddingLeft/paddingTop) by introducing structural layout minimums rather than exhaustive box-model properties. - Sourced independently from PR google-labs-code#164 to prevent merge conflicts. * Changes: - Add 'paddingX' and 'paddingY' to component_sub_tokens list in spec-config.yaml. - Update the valid component properties list in README.md. - Regenerate docs/spec.md using the compiler script. * Test Coverage: - Add validation tests in broken-ref.test.ts to verify that components using paddingX and paddingY do not trigger unrecognized sub-token warnings.
This was referenced Aug 11, 2026
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.
Summary
Widens the Dimension grammar from
px/em/remto also acceptpt,mm,cm,in— the print-native units CSS already supports — so print/PDF-targeting DESIGN.md files (academic papers, book layouts,page.pdf()/WeasyPrint pipelines) can express normative values without lossy conversion.Closes #162.
What's in here
spec-config.yaml): addedpt,mm,cm,into theunits:list — the single source of truth re-exported asSTANDARD_UNITS. No new print-specific category; per the issue, this is straightforward acceptance, not a new taxonomy.model/handler.ts): theroundedandtypography(fontSize/lineHeight/letterSpacing) blocks each hand-spelled aunit !== 'px' && unit !== 'rem' && unit !== 'em'literal check that bypassed the config entirely — widening the YAML alone would have updated the docs while the linter kept rejecting the new units. Both sites now check against aSTANDARD_UNIT_SETderived from the same config, so there's one source of truth and the next unit addition only touchesspec-config.yaml.spec-config.yaml'stypes.Dimensionhad its own hardcodedunits:sub-list, stale and separate from the top-level list. Removed it so the doc renderer's existing fallback (config.STANDARD_UNITS) is the only path.docs/spec.mdregenerated viabun run spec:gen(never hand-edited); README's token-type table updated to match.Review notes
A simplify pass caught a subtlety worth flagging: the first version of the
handler.tsfix called the existingisStandardDimension(raw)helper, which re-parses the raw string internally — but both call sites already have the parsed dimension in hand (resolved/parsed) from aparseDimension()call one line earlier. Three independent review lenses (reuse, quality, efficiency) all flagged the same redundant re-parse; fixed by checking the already-parsed.unitagainstSTANDARD_UNIT_SETdirectly instead.Testing
bun test— 315 pass, 0 fail.bunx tsc --noEmitclean.bun run spec:gen --checkconfirms deterministic doc generation.roundedandtypography, non-standard units (vh) still rejected, and px/em/rem behavior unchanged.🤖 Assisted by Compound Engineering