Repository navigation
feat(native): Button width projects to content or fill on native platforms - #8305
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression46 of 504 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 26 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
No changes requested: Button width projects to content or fill exactly as AST-082 FR4 describes, the generated native TypeScript types accept only those two values, and the Swift binding builds and passes its tests on macOS and the iOS simulator. Nothing more is needed in this pull request; the visible full-width behavior on Apple platforms arrives when the Swift Button view moves onto ButtonProps and replaces fillsWidth, as the description plans.
[Automated review]
| }); | ||
| expect(sized.webOnly).toEqual([]); | ||
| const webValues = Object.values(sized.projections?.width ?? {}); | ||
| expect(new Set(webValues).size).toBe(webValues.length); |
There was a problem hiding this comment.
Non-blocking: this compares the fixture's own two web values, and fromComponentDoc stores that same object without checking distinctness, so the assertion passes even if no projection is recorded (webValues is then empty). The Button assertion in contracts.test.ts already proves the mapping; consider dropping this line or asserting something fromComponentDoc enforces.
… tokens (#8310) ## What changes for people An iOS developer gets core's whole Button: - `width: .fill` for a full-width button; - `href`, which makes the button a real link the system opens and VoiceOver reads as a link; - `tooltip` as a pointer tip and a VoiceOver hint; - `elevation` drawn with the theme's shadow; - `isInterruptible`, so a loading button can still be pressed to interrupt it. With this, every Swift view that has a core contract takes its generated props, and every view reads the theme through typed tokens. The Login template's Sign in button fills its card through `width: .fill`, as on the web. ## What this does - `Button` takes the generated `ButtonProps` (AST-093 FR5; Swift component API A2, A3, A4): a labeled initializer with the press last as a trailing closure (`onClick`), and the props initializer. - Each prop follows core: - `href` on an enabled button draws a SwiftUI `Link` styled with the Astryx button style; a disabled one stays a disabled button. - A loading link stays a link, focusable and busy, and opens nothing until loading ends unless it is interruptible. The open goes through SwiftUI's `openURL`, so `onClick` runs on every activation: tap, VoiceOver, or keyboard. - `tooltip` is SwiftUI's `.help`: a hover tip with a pointer and a hint VoiceOver reads; a tap belongs to the button, as with core's `touchTrigger: auto`. - `elevation` draws the theme's shadow; `width` is `content` or `fill`; `size` and `variant` come from typed tokens. - `AstryxNodeView` also draws Button and TextInput nodes. - **G9:** - Banner and the Login template read typed tokens. - The by-name lookups (`astryx.color("…")`, `size`, `space`, `fontSize`, `font(size:…)`) are no longer public. - **New spec record, `component:swift/Button`** (`packages/native/apple/Sources/Astryx/Button/Button.spec.md`, draft), per Cindy's decision that the loading rule belongs on the Swift Button spec. FR4 holds the loading-link rule: a loading Button with `href` stays a `Link`, keeps focus, shows its spinner, reads as busy, and does not open its destination until loading ends, unless the Button is interruptible, in which case each activation opens it. It never swaps to a button while busy (core Button FR9 and FR11). FR1–FR3 record the initializers, the loading presentation, and enabled or disabled `href`; FR5 says a script URL (`javascript:`, `vbscript:`) or an HTML document in a `data:` URL never opens, and the Button stays an enabled button. FR6: every disabled Button keeps its keyboard focus stop and shows its tooltip on focus, draws dimmed, reads as a dimmed button, and never runs `onClick` (core Button FR10, buttons family FR3); the focus stop is not measured until an app-hosted test can observe it. Each has a verification row. The record names the Apple guideline pages it follows (Buttons, Progress indicators, Accessibility) and the theme values Button reads. The shared component API record keeps no loading rule, only a pointer to Button FR4, and states no general rule. Theme environment's Current state describes the `Astryx` product. - README: the interim-exemption list is gone; Banner, which has no native contract yet, is the one view with hand-written parameters. **Landing order:** after #8307 (Card) and #8308 (TextInput); #8305 (Button `width`) is on `main`. This branch carries #8308's commit so it builds; it is rebased onto `main` as each lands, leaving only its own change (8 files). - `tooltip` shows through the shared Astryx tooltip on hover and keyboard focus, its words the VoiceOver hint; no view uses `.help`. **Compatibility:** breaking for canary callers. `action:`, `fillsWidth:`, `icon:`, and the hand-written `AstryxButtonVariant` and `AstryxButtonSize` give way to the generated `ButtonProps` (`onClick:`, `width:`, `ButtonVariant`, `ButtonSize`); the record states it. ## Writing rubric results - R1 present tense: `component:swift/Button` and the component API pointer describe the system as it is. - R2 research in the record: none. - R3 evidence naming a change: none. Verification rows name tests, not pull requests. - R4 rejected alternatives: none. - R5 user impact first: the record's End-user impact row leads with a width that holds and a link that stays a link. - R6 open questions: none. ## Captures (AST-093 FR5) Capture set: iPhone 16 simulator, iOS 18.5, Xcode 16.4, built from this PR's head (`6cad853`). Each capture shows each variant and size, loading and disabled, full width, `href` as a link, loading and disabled links, each elevation, and two themes. | Light | Dark | Light, largest text | Light, largest text, end | Dark, largest text | Dark, largest text, end | |---|---|---|---|---|---| | <img src="https://raw.githubusercontent.com/cixzhang/astryx-pixel-gallery/27f10ad1a94648b64447aba2a1ec79bfe79c13c3/pr-shots/8310/Button-light-large.png" width="150" alt="Button, Light"> | <img src="https://raw.githubusercontent.com/cixzhang/astryx-pixel-gallery/27f10ad1a94648b64447aba2a1ec79bfe79c13c3/pr-shots/8310/Button-dark-large.png" width="150" alt="Button, Dark"> | <img src="https://raw.githubusercontent.com/cixzhang/astryx-pixel-gallery/27f10ad1a94648b64447aba2a1ec79bfe79c13c3/pr-shots/8310/Button-light-ax5.png" width="150" alt="Button, Light, largest text"> | <img src="https://raw.githubusercontent.com/cixzhang/astryx-pixel-gallery/27f10ad1a94648b64447aba2a1ec79bfe79c13c3/pr-shots/8310/Button-light-ax5-end.png" width="150" alt="Button, Light, largest text, end"> | <img src="https://raw.githubusercontent.com/cixzhang/astryx-pixel-gallery/27f10ad1a94648b64447aba2a1ec79bfe79c13c3/pr-shots/8310/Button-dark-ax5.png" width="150" alt="Button, Dark, largest text"> | <img src="https://raw.githubusercontent.com/cixzhang/astryx-pixel-gallery/27f10ad1a94648b64447aba2a1ec79bfe79c13c3/pr-shots/8310/Button-dark-ax5-end.png" width="150" alt="Button, Dark, largest text, end"> | Accessibility tree: not measured in these captures; the Swift tests check names, traits and values. **Banner** (statuses; two themes): <img src="https://raw.githubusercontent.com/cixzhang/astryx-pixel-gallery/27f10ad1a94648b64447aba2a1ec79bfe79c13c3/pr-shots/8310/Banner-light-large.png" width="150"> <img src="https://raw.githubusercontent.com/cixzhang/astryx-pixel-gallery/27f10ad1a94648b64447aba2a1ec79bfe79c13c3/pr-shots/8310/Banner-dark-large.png" width="150"> <img src="https://raw.githubusercontent.com/cixzhang/astryx-pixel-gallery/27f10ad1a94648b64447aba2a1ec79bfe79c13c3/pr-shots/8310/Banner-light-ax5.png" width="150"> <img src="https://raw.githubusercontent.com/cixzhang/astryx-pixel-gallery/27f10ad1a94648b64447aba2a1ec79bfe79c13c3/pr-shots/8310/Banner-dark-ax5.png" width="150"> ## Testing - Swift tests: - both initializers build the same props; - an interruptible loading button takes presses, and a plain loading one does not; - `href` makes an enabled button a link and a disabled one a button; - a loading link stays a link and accepts no press, and an interruptible loading link opens; - every disabled Button keeps its focus stop and takes no press; - `javascript:`, `vbscript:`, and `data:text/html` destinations never open and leave an enabled button, while `data:image` and `mailto:` still open; - `fill` takes the whole width, in pixels; - elevation reads the theme's shadows; - Banner's typed colors; - the existing loading, disabled, 44-point, and Dynamic Type tests. - `swiftc -typecheck` of both modules, the tests, and the templates passes; the Swift tests run in CI on the iOS Simulator. Every changed file is under `packages/native/`.
What changes for people
An iOS developer can ask for a full-width button the way core does,
width: .fill, instead of a Swift-only spelling. A logic core sends the same value on the wire. Other web widths (a pixel number, a percentage other than 100%) stay web-only, so a native type never receives a width it cannot draw.What this does
Applies AST-082 FR4's projected-prop rule to Button
width, as the owner decided (portable closed formcontent|fill):NativeAdditions.projectionsnames a prop whose web type is wider than a portable kind, with each portable value mapped to the one web value it means. Button declareswidth: {content: 'auto', fill: '100%'};contentis the default.fromComponentDocputs a projected prop in the core as a closed set of those values, documents the mapping on the prop, and records it on the contract (projections). Without a projection the prop stays in the web contract, as before.ButtonWidth(content,fill), andwidthonButtonPropsandButtonNodefor iOS and macOS. The TypeScript native types getwidth?: 'content' | 'fill'.The Swift
Buttonview adoptswidthwhen it moves ontoButtonProps, in a following pull request; until then it keeps its interimfillsWidth.Testing
pnpm vitest run --project node packages/native/src/contract: a projected prop enters the core at its portable values with distinct web values; the same prop without a projection stays web-only; core's Button contract haswidthascontent|fillmapped to'auto'and'100%'.pnpm -F @astryxdesign/native typecheckpasses;swiftc -typecheckof both Swift modules, the tests, and the templates passes.Every changed file is under
packages/native/.