Skip to content

feat(native): Swift Card takes core's props; theme shadows reach Swift - #8307

Merged
cixzhang merged 6 commits into
mainfrom
native/swift-card-props
Oct 25, 2026
Merged

cixzhang merged 6 commits into
mainfrom
native/swift-card-props

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What changes for people

An iOS developer gets core's whole Card: every padding step including 0.5 and 1.5 (Card(padding: .v0_5)), every background variant (muted, transparent, the twelve colors), and elevation drawn with the theme's own shadow. A screen a logic core sends now draws its cards and their text through the same views.

What this does

  • Card takes the generated CardProps (AST-093 FR5; Swift component API A2, A3): a labeled initializer with padding, variant, elevation, base, and a @ViewBuilder content slot, and a props initializer that takes the children as wire nodes ([AstryxNode]) with send for their callbacks.
  • Every prop is honored with core's meaning:
    • padding: core's spacing steps, from the theme's typed spacing tokens. The border sits inside the padding, so the content inset equals the step, as in core. When nil, step 4: core's default without a theme.
    • variant: core's ground for each variant. Only default draws the border; transparent draws neither ground nor border.
    • elevation: the theme's shadow-low, -med, or -high, drawn like CSS box-shadow: drop layers only outside the card, so a see-through card shows no shadow beneath it, plus inset rings inside its edge.
    • Base props: id and isHidden.
  • AstryxNodeView draws a wire node with its Astryx view (Text, Heading, and Card so far). A component with no Swift view yet draws nothing.
  • Spec change, theme generator G5, G6, and G7:
    • G5 keeps shadow-low, shadow-med, and shadow-high, the elevations core's Card and Button draw (shadow.low, …), in the same pull request as the first component that reads them, as G5 asks.
    • G7 reads a box-shadow list as [ShadowLayer] (drop layers with no spread, inset rings) with a light-dark() color per mode, and reads oklch() colors exactly through OKLab, because neutral writes its shadows that way.
    • The acceptance row's failing example becomes color-mix().
  • README: Card is off the interim-exemption list.

Lands after #8303 (Text and Heading props) and #8299 (the Astryx names), which this branch builds on.

Not in this pull request

  • A theme can set its own card padding through component CSS; the Swift Card uses core's default step until component-level theme values reach native.
  • TextInput and Button move onto their props next.

Captures (AST-093 FR5)

Capture set: iPhone 16 simulator, iOS 18.5, Xcode 16.4, built from adce2d0; the head since (e56c79d) changes only tests and the rebase onto main after #8418, so the views draw the same. Each capture shows padding 0.5 to 8, all 13 variants, each elevation, a wire tree with a node the package cannot draw rendered in place as unsupported (its siblings still render), content, and neutral and butter at elevation high.

Light Dark Light, largest text Light, largest text, end Dark, largest text Dark, largest text, end
Card, Light Card, Dark Card, Light, largest text Card, Light, largest text, end Card, Dark, largest text Card, Dark, largest text, end

Accessibility tree: not measured in these captures; the Swift tests check names, traits and values.

Testing

  • Swift tests:
    • both initializers build the same props;
    • every variant's ground, and only default has a border;
    • elevation reads the theme's shadows (neutral's end with a ring);
    • half steps are spacing tokens;
    • an elevated card draws a shadow below it;
    • a transparent card draws nothing of its own;
    • a card decoded from wire JSON draws its Text child.
  • Generator tests: neutral's --shadow-low becomes two drop layers and a ring with its color per mode; a drop spread or a blurred inset fails; oklch() values convert exactly; the drift test passes over the regenerated themes.
  • swiftc -typecheck of both modules, the tests, and the templates passes; pnpm -F @astryxdesign/native typecheck passes; the Swift tests run in CI on the iOS Simulator.

Every changed file is under packages/native/.

@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 25, 2026 5:02pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 24, 2026
@astracat-bot

astracat-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 25, 2026, 5:30 PM UTC

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

48 of 502 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
RichTextEditor Markdown parity: side by side probe dark 556,900
RichTextEditor Markdown parity: side by side probe light 538,816
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
AppShell With Mobile Nav probe light 217,010
AppShell With Mobile Nav probe dark 216,960
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
AppShell Playground neutral dark 65,198
AppShell Playground neutral light 63,788
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232

and 28 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision on the draft theme-generator changes in this pull request (G5's three shadow tokens, G6's shadow row, and G7's oklch() and [ShadowLayer] rules with the rewritten acceptance row): any engineering owner, the author included, records it by commenting /approve-spec <full head SHA> on this pull request or asks for amendments. Independently of that decision, a few fixes are needed:

  • AstryxNodeView draws nothing for unsupported nodes and for every component other than Card, Text and Heading (a VStack root included), where AST-082 FR19 asks a host to draw every node it can read and render the rest as unsupported in place.
  • A theme whose shadow token is none now fails Swift generation, and mapping it to an empty layer list keeps such themes working.
  • The new shadow-<level> row in G6 sits outside the table, and the collision rule below it lost its indent.
  • AST-093 FR5 asks for the Swift tests to run on this head and for light, dark and largest-text captures, and neither is there yet.

[Automated review]

case .text(let text): Text(text.viewProps(send: send))
case .heading(let heading): Heading(heading.viewProps(send: send))
case .card(let card): Card(card.viewProps(send: send), children: card.props.children ?? [], send: send)
default: EmptyView()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default: EmptyView() draws the .unsupported case and every other component (vStack, hStack, button, switch, …) as nothing, so a tree rooted in a VStack draws a blank screen. AST-082 FR19 asks a host to draw every node it can read and render the rest as unsupported in its place; a visible unsupported placeholder here (and SwiftUI stacks for VStack/HStack) would conform.

/^(inset\s+)?(\S+)\s+(\S+)\s+(\S+)(?:\s+(\S+))?\s+((?:light-dark|rgba?|hsla?|oklch)\(.*\)|#[0-9A-Fa-f]+|[a-z]+)$/s.exec(
layer,
);
if (!m) return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none does not match the layer pattern, so a theme with --shadow-low: none (valid CSS, zero layers) now fails Swift generation entirely, where it generated before shadows were kept. Returning [] for none keeps such themes working.


Two tokens that map to the same member, or a member that is a Swift keyword
or does not start with a letter, fail the run with both token names.
| `shadow-<level>` | `shadow.<level>`: `shadow-low` → `shadow.low` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This row sits outside the G6 table (column 0, after a blank line), so it renders as a literal | … | paragraph, and lines 87-88 lost their indent, which moves the collision rule out of G6 and splits the requirements list. Deleting the blank line above, indenting this row by two spaces and re-indenting 87-88 fixes both.

#expect(labeled.props.elevation == fromProps.props.elevation)
}

@Test func everyVariantDrawsCoresGroundAndOnlyDefaultHasABorder() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test checks the ground of 4 of the 13 variants and no borders; looping over CardVariant.allCases and asserting the border per variant would match its name.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision on the draft theme-generator changes in this pull request (G5's three shadow tokens, G6's shadow-<level> row, and G7's oklch() and [ShadowLayer] rules with the rewritten acceptance row): an engineering owner records it by commenting /approve-spec <full head SHA> on this pull request, which the author may do as an engineering owner, or asks for amendments. Independently of that decision, these need fixing:

  • AstryxNodeView draws nothing for unsupported nodes and for every component other than Card, Text and Heading (a VStack root included), where AST-082 FR19 asks a host to draw every node it can read and render the rest as unsupported in place.
  • A theme whose shadow token is none now fails Swift generation, and reading it as an empty layer list keeps such themes working.
  • The new G6 row sits outside the table, and the collision rule below it lost its indent.
  • AST-093 FR5's Swift test run on this revision, a largest-text Card test, and light, dark and largest-text captures are still missing.

[Automated review]

case .text(let text): Text(text.viewProps(send: send))
case .heading(let heading): Heading(heading.viewProps(send: send))
case .card(let card): Card(card.viewProps(send: send), children: card.props.children ?? [], send: send)
default: EmptyView()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default: EmptyView() draws .unsupported and every component other than Card, Text and Heading as nothing, so a tree rooted in a VStack (the shape WireTests.swift decodes) draws a blank screen. AST-082 FR19 asks a host to draw every node it can read and render the rest as unsupported in its place; a visible placeholder here, plus a test that draws such a tree, would meet it.

/^(inset\s+)?(\S+)\s+(\S+)\s+(\S+)(?:\s+(\S+))?\s+((?:light-dark|rgba?|hsla?|oklch)\(.*\)|#[0-9A-Fa-f]+|[a-z]+)$/s.exec(
layer,
);
if (!m) return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none does not match the layer pattern, so a theme with --shadow-low: none (valid CSS, zero layers) now fails Swift generation entirely, where the base skipped shadows and generated it. Returning [] for none keeps such themes working and has an exact Swift form.


Two tokens that map to the same member, or a member that is a Swift keyword
or does not start with a letter, fail the run with both token names.
| `shadow-<level>` | `shadow.<level>`: `shadow-low` → `shadow.low` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This row is at column 0 after a blank line, so GFM renders it as a literal | … | paragraph outside the G6 table, and lines 87-88 lost their indent, which ends the G6 item and splits the requirements list. Deleting the blank line above and indenting this row and lines 87-88 by two spaces keeps both inside G6.

#expect(labeled.props.elevation == fromProps.props.elevation)
}

@Test func everyVariantDrawsCoresGroundAndOnlyDefaultHasABorder() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks the ground of 4 of the 13 variants and no borders; looping over CardVariant.allCases and asserting the ground and the border per variant would match the test's name.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision on the draft theme-generator changes in this pull request (G5's three shadow tokens, G6's shadow-<level> row, and G7's oklch() and [ShadowLayer] rules with the rewritten acceptance row, under which a theme whose shadow is none or has a spread now fails Swift generation): any engineering owner, the author included as one, records it by commenting /approve-spec <full head SHA> on this pull request, or asks for amendments. Independently of that decision, these need fixing:

  • AstryxNodeView draws nothing for unsupported nodes and for every component other than Card, Text and Heading (a VStack root included), where AST-082 FR19 asks a host to draw every node it can read and render the rest as unsupported in place.
  • The new G6 row sits outside the table, the collision rule below it lost its indent, and G3 still lists five Tokens groups.
  • AST-093 FR5's Swift test run on this revision, a largest-text Card test, and light, dark and largest-text captures are still missing, and one Card test names a border check it does not make.

[Automated review]

@@ -39,7 +39,7 @@ const REGENERATE = 'pnpm -F @astryxdesign/native generate:swift-ios';
// G5: the token groups Swift keeps. Everything else (shadows, motion, layout

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment still says shadows stay out of Swift, but the pattern below now keeps shadow-low, shadow-med and shadow-high; G3 in theme-generator.md (lines 38-40) likewise still lists five Tokens groups.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision on the draft theme-generator changes in this pull request (G5's three shadow tokens, G6's shadow-<level> row, and G7's oklch() and [ShadowLayer] rules with the rewritten acceptance row, under which a theme whose shadow is none or has a spread now fails Swift generation): an engineering owner records it by commenting /approve-spec <full head SHA> on this pull request, which the author may do as an engineering owner, or asks for amendments. Independently of that decision, these need fixing:

  • AstryxNodeView draws nothing for unsupported nodes and for every component other than Card, Text and Heading (a VStack root included), where AST-082 FR19 asks a host to draw every node it can read and render the rest as unsupported in its place.
  • The new G6 row sits outside the table, the collision rule below it lost its indent, and G3 still lists five Tokens groups.
  • AST-093 FR5's Swift test run on this revision, a largest-text Card test, a test of each variant's border, and light, dark and largest-text captures are still missing.

[Automated review]

case .text(let text): Text(text.viewProps(send: send))
case .heading(let heading): Heading(heading.viewProps(send: send))
case .card(let card): Card(card.viewProps(send: send), children: card.props.children ?? [], send: send)
default: EmptyView()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default: EmptyView() draws .unsupported and every readable component other than Card, Text and Heading (vStack, hStack, button, switch, …) as nothing, so a tree rooted in a VStack (the shape WireTests.swift decodes) draws a blank screen. AST-082 FR19 asks a host to draw every node it can read and render the rest as unsupported in its place; SwiftUI stacks for VStack/HStack, a visible unsupported placeholder here, and a test that draws such a tree would meet it.


Two tokens that map to the same member, or a member that is a Swift keyword
or does not start with a letter, fail the run with both token names.
| `shadow-<level>` | `shadow.<level>`: `shadow-low` → `shadow.low` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This row is at column 0 after a blank line, so GitHub-flavoured Markdown renders it as a literal | … | paragraph outside the G6 table, and lines 87-88 lost their indent, which ends the G6 item and splits the requirements list. Deleting the blank line above and indenting this row and lines 87-88 by two spaces keeps both inside G6. G3 (lines 38-40) also still lists five Tokens groups without shadow.

/^(inset\s+)?(\S+)\s+(\S+)\s+(\S+)(?:\s+(\S+))?\s+((?:light-dark|rgba?|hsla?|oklch)\(.*\)|#[0-9A-Fa-f]+|[a-z]+)$/s.exec(
layer,
);
if (!m) return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none does not match the layer pattern, so a theme with --shadow-low: none (valid CSS, zero layers) now stops Swift generation, where the base skipped shadows and generated it; the same holds for a drop layer with a spread. This is part of the G7 decision the owner is asked to make; reading none as [] would have an exact Swift form.

@@ -39,7 +39,7 @@ const REGENERATE = 'pnpm -F @astryxdesign/native generate:swift-ios';
// G5: the token groups Swift keeps. Everything else (shadows, motion, layout

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment still says shadows stay out of Swift, but the pattern below now keeps shadow-low, shadow-med and shadow-high.

}

@MainActor
@Test func everyVariantDrawsCoresGroundAndOnlyDefaultHasABorder() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks the ground of 4 of the 13 variants and no borders, so a border on every variant, or none on default, still passes every Card test. Looping over CardVariant.allCases and asserting the ground and the border per variant would match the test's name.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision on the draft theme-generator changes in this pull request (G5's three shadow tokens, G6's shadow-<level> row, and G7's oklch() and [ShadowLayer] rules with the rewritten acceptance row, under which a theme whose shadow is none or has a spread now fails Swift generation): an engineering owner records it by commenting /approve-spec <full head SHA> on this pull request, which the author may do as an engineering owner, or asks for amendments. Independently of that decision, these need fixing:

  • AstryxNodeView draws nothing for unsupported nodes and for every component other than Card, Text and Heading (a VStack root included), where AST-082 FR19 asks a host to draw every node it can read and render the rest as unsupported in its place.
  • The new G6 row sits outside the table, the collision rule below it lost its indent, G3 still lists five Tokens groups, and the generator's comment still says shadows stay out of Swift.
  • AST-093 FR5's Swift test run on this revision, a largest-text Card test and a test of each variant's border are still missing, and the new captures show 7 of the 13 variants although the description says each variant.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision on the draft theme-generator changes in this pull request (G5's three shadow tokens, G6's shadow-<level> row, and G7's oklch() and [ShadowLayer] rules with the rewritten acceptance row, under which a theme whose shadow is none or has a spread now fails Swift generation): an engineering owner records it by commenting /approve-spec <full head SHA> on this pull request, which the author may do as an engineering owner, or asks for amendments. Independently of that decision, these need fixing:

  • AstryxNodeView draws nothing for unsupported nodes and for every component other than Card, Text and Heading (a VStack root included), where AST-082 FR19 asks a host to draw every node it can read and render the rest as unsupported in its place.
  • The new G6 row sits outside the table, the collision rule below it lost its indent, G3 still lists five Tokens groups, the G6 names test has no shadow case, and the generator's comment still says shadows stay out of Swift.
  • AST-093 FR5's Swift test run on this revision, a largest-text Card test and a test of each variant's border are still missing, and the captures show 7 of the 13 variants although the description says each variant.

[Automated review]

@cixzhang
cixzhang changed the base branch from native/swift-text-heading-props to main October 25, 2026 14:24
@cixzhang
cixzhang force-pushed the native/swift-card-props branch from 44d3981 to cbaaa44 Compare October 25, 2026 14:29
@cixzhang
cixzhang force-pushed the native/swift-card-props branch from cbaaa44 to 1266c5f Compare October 25, 2026 14:46

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision on the draft theme-generator changes in this pull request (G5's three shadow tokens, G6's shadow-<level> row, and G7's oklch() and [ShadowLayer] rules with the rewritten acceptance row, under which a theme whose shadow is none, has a spread or uses another layer shape now fails Swift generation): an engineering owner records it by commenting /approve-spec <full head SHA> on this pull request, which the author may do as an engineering owner, or asks for amendments. Independently of that decision, these need fixing:

  • AstryxNodeView draws nothing for unsupported nodes and for every component other than Card, Text and Heading (a VStack root included), where AST-082 FR19 asks a host to draw every node it can read and render the rest as unsupported in its place.
  • The new G6 row sits outside the table and the collision rule below it lost its indent, G3 still lists five Tokens groups, the G6 names test has no shadow case, and the generator's comment still says shadows stay out of Swift.
  • AST-093 FR5 still asks for a largest-text Card test, a test of each variant's border, and captures of the six variants the current ones leave out, since the description says each variant is shown.

The Swift tests now pass on macOS and the iOS Simulator for this revision.

[Automated review]

case .text(let text): Text(text.viewProps(send: send))
case .heading(let heading): Heading(heading.viewProps(send: send))
case .card(let card): Card(card.viewProps(send: send), children: card.props.children ?? [], send: send)
default: EmptyView()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default: EmptyView() draws .unsupported and every readable component other than Card, Text and Heading (vStack, hStack, button, switch, …) as nothing, so a tree rooted in a VStack (the shape WireTests.swift decodes) draws a blank screen. AST-082 FR19 asks a host to draw every node it can read and render the rest as unsupported in its place; SwiftUI stacks for VStack/HStack, a visible unsupported placeholder here, and a test that draws such a tree would meet it.


Two tokens that map to the same member, or a member that is a Swift keyword
or does not start with a letter, fail the run with both token names.
| `shadow-<level>` | `shadow.<level>`: `shadow-low` → `shadow.low` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This row is at column 0 after a blank line, so GitHub-flavoured Markdown renders it as a literal | … | paragraph outside the G6 table, and lines 87-88 lost their indent, which ends the G6 item and splits the requirements list. Deleting the blank line above and indenting this row and lines 87-88 by two spaces keeps both inside G6; G3 (lines 38-40) also still lists five Tokens groups without shadow.

@@ -39,7 +39,7 @@ const REGENERATE = 'pnpm -F @astryxdesign/native generate:swift-ios';
// G5: the token groups Swift keeps. Everything else (shadows, motion, layout

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment still says shadows stay out of Swift, but the pattern below now keeps shadow-low, shadow-med and shadow-high.

}

@MainActor
@Test func everyVariantDrawsCoresGroundAndOnlyDefaultHasABorder() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks the ground of 4 of the 13 variants and no borders, so a border on every variant, or none on default, still passes every Card test. Looping over CardVariant.allCases and asserting the ground and the border per variant would match the test's name.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec e56c79d

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommending approval: Swift's Card now takes core's generated CardProps, the theme generator's shadow and oklch() rules carry an engineering owner's exact-head approval, and the Swift tests pass on macOS and the iOS Simulator. Three follow-ups are worth a look, none of them blocking:

  • AstryxNodeView draws HStack and VStack nodes as placeholders, so a stack-rooted wire tree shows a single VStack box until stacks get a view.
  • Neutral's dark inset ring is stroked over the default card's border (Shadow.swift:29), where the web draws it just inside the border.
  • paddingHalfStepsAreCoresSpacingTokens checks only that step 4 is taller than step 0.5 and the ground test covers 4 of the 13 variants; exact heights and a loop over CardVariant.allCases would pin both mappings.

[Automated review]

.overlay {
ForEach(Array(layers.enumerated()), id: \.offset) { _, layer in
if layer.isInset {
shape.strokeBorder(layer.color, lineWidth: layer.spread)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This strokes each ring in the outer spread points of the shape, the same band where Card strokes the default variant's border, so neutral's dark ring lands on the border. CSS paints an inset shadow inside the padding edge, just inside the border; insetting the ring by the border width when the card draws one would match the web.

case .heading(let heading): Heading(heading.viewProps(send: send))
case .card(let card): Card(card.viewProps(send: send), children: card.props.children ?? [], send: send)
case .icon(let icon): Icon(icon.viewProps(send: send))
default: AstryxUnsupportedNode(component: Self.componentName(node))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HStack and VStack nodes land here too, so a stack-rooted tree (like the sample in WireTests.swift) draws one VStack placeholder. Drawing stacks with SwiftUI's own, from their generated props, would be a good next step.

let child = Color(astryxHex: "#FF0000FF").frame(width: 20, height: 20)
let half = Pixels(Astryx.Card(padding: .v0_5) { child }.fixedSize())
let four = Pixels(Astryx.Card(padding: .v4) { child }.fixedSize())
#expect(four.height > half.height)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This passes for any mapping in which step 4 is taller than step 0.5. Asserting the exact height (20 + 2 * Theme.default.light.space.s0_5), and the same for .v1_5 and a nil padding, would pin the mapping the test is named for.

@cixzhang
cixzhang merged commit 372cc2a into main Oct 25, 2026
71 checks passed
@github-actions
github-actions Bot deleted the native/swift-card-props branch October 26, 2026 06:31
cixzhang added a commit that referenced this pull request Oct 30, 2026
… 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/`.

This branch was successfully deployed

1 active deployment
Preview — e56c79da Deployed Oct 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant