An open source design system that's fully customizable and agent ready
TypeScript
fix(native): an inset ring draws inside a card's border, as CSS does; component API current state names the wire placeholder (#8433)
Cindy Zhang1e84ea459a99
diff --git a/packages/native/apple/Sources/Astryx/Card/Card.swift b/packages/native/apple/Sources/Astryx/Card/Card.swiftindex 24ee57c057..4809dbe040 100644--- a/packages/native/apple/Sources/Astryx/Card/Card.swift+++ b/packages/native/apple/Sources/Astryx/Card/Card.swift@@ -41,7 +41,10 @@ public struct Card<Content: View>: View {shape.strokeBorder(astryx.tokens.color.border, lineWidth: astryx.tokens.size.borderWidth)}}- .astryxShadow(Self.shadow(props.elevation ?? .none, astryx.tokens.shadow), in: shape)+ .astryxShadow(+ Self.shadow(props.elevation ?? .none, astryx.tokens.shadow), in: shape,+ borderWidth: variant == .default ? astryx.tokens.size.borderWidth : 0+ ).astryxBase(props.base)}diff --git a/packages/native/apple/Sources/Astryx/Theme/Shadow.swift b/packages/native/apple/Sources/Astryx/Theme/Shadow.swiftindex 41a3d06601..9bc65f3409 100644--- a/packages/native/apple/Sources/Astryx/Theme/Shadow.swift+++ b/packages/native/apple/Sources/Astryx/Theme/Shadow.swift@@ -3,8 +3,10 @@extension View {/// Draws a theme shadow around this view's shape, as CSS `box-shadow` does:/// drop layers only outside the shape, so a see-through view shows no- /// shadow beneath it, and inset rings inside its edge.- func astryxShadow<S: InsettableShape>(_ layers: [ShadowLayer], in shape: S) -> some View {+ /// shadow beneath it, and inset rings inside its edge. A view with a border+ /// passes its width, and inset rings draw inside the border, as CSS draws an+ /// inset shadow inside an element's border.+ func astryxShadow<S: InsettableShape>(_ layers: [ShadowLayer], in shape: S, borderWidth: CGFloat = 0) -> some View {background {ZStack {ForEach(Array(layers.enumerated()), id: \.offset) { _, layer in@@ -26,7 +28,7 @@ extension View {.overlay {ForEach(Array(layers.enumerated()), id: \.offset) { _, layer inif layer.isInset {- shape.strokeBorder(layer.color, lineWidth: layer.spread)+ shape.inset(by: borderWidth).strokeBorder(layer.color, lineWidth: layer.spread)}}}diff --git a/packages/native/apple/Tests/AstryxTests/CardTests.swift b/packages/native/apple/Tests/AstryxTests/CardTests.swiftindex 5365cb4dc3..b5edc6c23e 100644--- a/packages/native/apple/Tests/AstryxTests/CardTests.swift+++ b/packages/native/apple/Tests/AstryxTests/CardTests.swift@@ -132,3 +132,18 @@ import Testing#expect(hasBorder == (variant == .default), "\(variant.rawValue)")}}++@MainActor+@Test func anInsetRingDrawsInsideTheDefaultCardsBorder() {+ // As CSS draws an inset shadow inside an element's border: the border on the+ // edge, the ring just inside it.+ var theme = Theme.default+ theme.light.color.border = Color(astryxRGBA: 0xFF00FFFF)+ theme.light.size.borderWidth = 1+ theme.light.shadow.low = [ShadowLayer(x: 0, y: 0, blur: 0, spread: 1, isInset: true, color: Color(astryxRGBA: 0x00FFFFFF))]+ let card = Astryx.Card(elevation: .low) { Color.black.frame(width: 40, height: 40) }.frame(width: 80)+ let pixels = Pixels(card, theme: theme)+ let x = pixels.width / 2+ #expect(close(pixels.at(x, 0), [255, 0, 255, 255], within: 8))+ #expect(close(pixels.at(x, 1), [0, 255, 255, 255], within: 8))+}diff --git a/packages/native/specs/swift/library/component-api.md b/packages/native/specs/swift/library/component-api.mdindex 650eaeed68..3a92cad431 100644--- a/packages/native/specs/swift/library/component-api.md+++ b/packages/native/specs/swift/library/component-api.md@@ -148,8 +148,12 @@ same generated contract.(SwiftUI views with core's names, `Button`, `Text`, and so on, re-exportingSwiftUI and the contracts) and the `AstryxNative` product (generated contracttypes, unprefixed: `ButtonProps`, `ButtonVariant`).-- All six views still take hand-written parameters until each moves onto its- generated `<Name>Props`; Banner has no generated contract.+- Card, Heading, Icon, and Text take their generated `<Name>Props`; Button and+ TextInput still take hand-written parameters until each moves onto its+ generated props; Banner has no generated contract.+- `AstryxNodeView` draws Card, Heading, Icon, and Text wire nodes. Any other+ node, HStack and VStack included, renders in its place as unsupported, and+ its siblings still render, until the logic host draws stacks (A9).- The generated iOS `SwitchProps` still declares `size`, the generated`SwitchProps` still declare `labelPosition` and `labelSpacing` on iOS andmacOS, and `HStackProps` and `VStackProps` are still generated for iOS anddiff --git a/packages/native/specs/swift/library/theme-generator.md b/packages/native/specs/swift/library/theme-generator.mdindex da8b83ed9a..e79e1d0269 100644--- a/packages/native/specs/swift/library/theme-generator.md+++ b/packages/native/specs/swift/library/theme-generator.md@@ -108,7 +108,8 @@ re-implements theme logic.- Font families are `[String]`, quotes removed, in the CSS stack's order.- Shadows are `[ShadowLayer]`, one per `box-shadow` layer in order: a droplayer `x y blur color` with no spread, or an inset ring- `inset 0 0 0 <width> color`. A `light-dark()` color inside a layer is+ `inset 0 0 0 <width> color`, which a view draws inside its border, as CSS+ draws an inset shadow. A `light-dark()` color inside a layer istaken per mode.- Any other value in a kept group, such as `color-mix()`,`calc()`, an unresolved `var()`, a nested `light-dark()` outside a shadow@@ -170,7 +171,7 @@ re-implements theme logic.| G7 | A token written as `light-dark(#000, #fff)` generates black in light and white in dark. `hsl(210 100% 50%)` generates the same color as `#0080FF`. Unit tests convert every listed form; `oklch(0 0 0 / 5%)` generates `#0000000D`; `color-mix(in srgb, red, blue)` in a kept group fails with theme, mode, token, and value in the message; neutral's `--shadow-low` generates two drop layers and an inset ring, its ring color taken per mode; `"Figtree", -apple-system, sans-serif` becomes `["Figtree", "-apple-system", "sans-serif"]`. || G8 | Neutral's local tokens generate nothing today and each is reported; a fixture whose local tokens come back per mode generates its values keyed by their exact custom-property names in that theme's `local` maps, none in `Tokens`. || G9 | A source check finds no token lookup by string in any component. |-| G10 | On iOS and macOS, a Swift test with no bundled Figtree resolves `font.family.body` to the system font and with a registered test font resolves to that font; on iOS, both scale between Large and AX5. |+| G10 | On iOS and macOS, a Swift test with no bundled Figtree resolves `font.family.body` to the system font and with a registered test font resolves to that font; on iOS, both scale between Large and AX5. || G11 | `Theme.native` exists, is documented, and holds no values. || G12 | A test reads `packages/themes/*/package.json` and finds one generated file per non-private package plus `default`. A fixture product theme renders through `renderSwiftTheme`. || G13 | Editing one generated value or member name by hand fails the drift test with the regenerate command in the message. |