@astryxdesign/native 0.7.6-canary.cd40b8b → 0.7.6-canary.cdc5ec0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,219 +0,0 @@
1
- ---
2
- schema_version: 3
3
- template_version: 7
4
- kind: component
5
- id: component:swift/Avatar
6
- platform_of: component:Avatar
7
- authority: draft
8
- archive_reason: null
9
- superseded_by: null
10
- approved_by: null
11
- approved_at: null
12
- owners: [cixzhang]
13
- review_triggers: [public-api, behavior, layout, theming, accessibility]
14
- verified_by:
15
- [
16
- packages/native/apple/Tests/AstryxTests/AvatarTests.swift,
17
- packages/native/apple/Tests/AstryxTests/AvatarStatusDotTests.swift,
18
- packages/native/src/contract/contracts.test.ts,
19
- packages/native/src/contract/parseDocType.test.ts,
20
- ]
21
- modules: []
22
- families: []
23
- design_specs: []
24
- architecture: []
25
- contributing: []
26
- system_specs: [spec:AST-082, spec:AST-093]
27
- ---
28
-
29
- # Avatar (Swift) component contract
30
-
31
- ## Contract at a glance
32
-
33
- | Area | Contract |
34
- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
35
- | Public contract | `Avatar(_ name: String? = nil, src:, fallbackSrc:, alt:, size: AvatarSize?, shape: AvatarShape?, tooltip: AvatarTooltip?, href:, status:, onClick:)` and `Avatar(_ props: AvatarProps, status:)`, a SwiftUI `View` in module `Astryx`. `size` is the named sizes `xsm` to `xl`. |
36
- | Behavior | Draws the image at `src`, else `fallbackSrc`, else initials from `name` on the theme's neutral plate, else a person symbol, clipped to its shape. With `href` it is a SwiftUI `Link`; with only `onClick` it is a button; it draws the same either way. |
37
- | End-user impact | A person sees the same picture, initials, and shape as on the web, and VoiceOver reads the avatar's name, or skips a decorative one. |
38
- | Builder impact | An app passes a name and an image URL, and optionally tooltip words and an `AvatarStatusDot`. Pixel sizes, `target`, and `rel` have no Swift form; an `href` must be an absolute URL. |
39
- | Compatibility/readiness | Additive: a new view and generated `AvatarProps`. Draft; built and tested on macOS and the iOS Simulator; device captures are attached to the change. |
40
- | Review checks | Reject a size or shape beyond the contract, a disabled state, a link or button that draws differently from the static avatar, a layout that grows for the touch target, or a static avatar VoiceOver reads without a name. |
41
- | Governing rules | `spec:AST-082` FR3, FR4, FR7; `spec:AST-093` FR1–FR5; the Swift component API (A1–A9), theme environment, and accessibility records under `packages/native/specs/swift/library/`. |
42
-
43
- This table is a review projection; the body below is authoritative.
44
-
45
- ## Intent
46
-
47
- Avatar on Apple platforms shows a person's or an entity's picture with core's
48
- fallback order, sizes, shapes, and naming, drawn with SwiftUI's own image
49
- loading and link and button controls.
50
-
51
- ## Compatibility and migration
52
-
53
- - Released default preserved: `not yet released`
54
- - Compatibility class: additive
55
- - Controlled/uncontrolled behavior: not applicable
56
- - Migration decision: none
57
-
58
- Consumer migration instructions belong in consumer docs and release notes.
59
-
60
- ## Ownership boundary
61
-
62
- **Owns**
63
-
64
- - Loading `src`, then `fallbackSrc`, with SwiftUI `AsyncImage`.
65
- - Initials, the person symbol, the plate color, and the shape clip.
66
- - Switching to a SwiftUI `Link` or `Button` for `href` or `onClick` without
67
- changing the drawing.
68
- - The avatar's VoiceOver name and its touch target.
69
-
70
- **Does not own / non-goals**
71
-
72
- - The meaning of the props, the initials rule, and the size scale — owned by
73
- `component:Avatar`.
74
- - Avatar groups, which have no Swift view.
75
-
76
- ## Public concepts
77
-
78
- | Concept | Closed values or states | Meaning | Availability by variant/orientation/state | Default | Owner | Stability | Invalid-value behavior |
79
- | ------- | ---------------------------------------------- | --------------------------------------------------- | ----------------------------------------- | -------- | ------------------------ | ------------ | -------------------------------------------------------------------------- |
80
- | size | `xsm`, `sm`, `md`, `lg`, `xl` | 20, 24, 36, 48, 128 points at the default text size | always | `md` | `component:Avatar` | experimental | core's pixel sizes have no Swift form |
81
- | shape | `circle`, `rounded`, `square` | full round, the theme's element radius, no radius | always | `circle` | `component:Avatar` | experimental | none |
82
- | picture | image, fallback image, initials, person symbol | the first that is available, in that order | always | — | `component:Avatar` | experimental | an empty or unloadable URL moves to the next |
83
- | control | static, link (`href`), button (`onClick`) | how a tap behaves; the drawing is the same | always | static | `component:swift/Avatar` | experimental | an `href` that is not an absolute URL leaves the avatar static or a button |
84
-
85
- ## Behavioral and layout contract
86
-
87
- | ID | Candidate invariant | Basis | Draft review state |
88
- | --- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- | ------------------ |
89
- | FR1 | The view MUST show the image at `src`; when it is absent or fails, the image at `fallbackSrc`; then initials from a `name` that is not blank; then a person symbol. The fallback image loads only after `src` fails or when there is no `src`; while an image loads, the initials or the person symbol show. | core `Avatar` fallback order; `spec:AST-093` FR2 | verify |
90
- | FR2 | Initials MUST follow core's rule: the first letter, digit, or emoji of the first and last words that have one, uppercased, skipping leading punctuation, keeping a whole emoji, flag, or joined emoji sequence. A name with none shows the person symbol and still names the avatar. | core `Avatar` initials | verify |
91
- | FR3 | The avatar MUST be a square of 20, 24, 36, 48, or 128 points for `xsm` to `xl` at the default text size, grown with Dynamic Type up to 1.6 times and never shrunk, so it and its initials grow with the name beside them without swallowing a row (`spec:AST-082` FR11). It is clipped to a circle, to the theme's `radius.element`, or to a square. | core `Avatar` sizes and shapes | verify |
92
- | FR4 | Initials and the person symbol MUST draw in `color.textSecondary` on `color.neutral`; initials use the theme's body family at medium weight and 40% of the side. | core `Avatar` fallback styles; `spec:AST-093` FR4 | verify |
93
- | FR5 | With an `href` that is an absolute URL (it has a scheme), the avatar MUST be a SwiftUI `Link`; with `onClick` too, `onClick` runs as it opens and the URL then goes to the app's own URL handler, or the system's. An `href` that is not an absolute URL, such as a web path, MUST stop a development build with a message naming it; a release build draws the avatar without a link, as a button with `onClick` or static. With only `onClick`, a SwiftUI `Button`. Either draws exactly as the static avatar, and the avatar has no disabled state. | Swift component API A4 | verify |
94
- | FR6 | Both initializers MUST build the same `AvatarProps`; `name` is the unlabeled first parameter, a single trailing closure is the status, and `onClick` comes last. Base props come through `AvatarProps`: with `isHidden` the view draws nothing; `id` becomes the accessibility identifier. | Swift component API A2–A4, A7; `spec:AST-082` FR7 | verify |
95
- | FR7 | The `status` slot MUST draw its content, usually one `AvatarStatusDot`, outside the avatar's clip, placed from the content's own size, in the same layout pass, as core places any status: on a circle centered on the circle's edge at the bottom trailing 45° point, on a rounded or square avatar overhanging the bottom trailing corner by a quarter of its size, mirrored in right-to-left layouts. It MUST NOT change the avatar's size or layout, gives a dot the avatar's side for its size tier, and lets other content grow with Dynamic Type no faster than the avatar, up to the text size at its 1.6 times growth: the content still grows with Dynamic Type (`spec:AST-082` FR11), up to its owner's growth, since the owner sizes what it holds (Swift slots S4). | core `Avatar` status position; Swift slots S4 | verify |
96
- | FR8 | `tooltip` MUST resolve, as core does, to the name for `nil` or `true`, the given words for a string, and nothing for `false` or blank words, and MUST show through the Astryx tooltip (`architecture:native-swift-library-tooltip`), with the focus and touch the Tooltip by input table below states: a static avatar is a tab stop and opens on a tap; a link or button keeps its focus and its tap. Given words are the VoiceOver hint. On the wire it is the web value, a string or a Bool. | core `Avatar` `tooltip`; core `Tooltip`; `spec:AST-082` FR3 | verify |
97
-
98
- **Tooltip by input (FR8).** The Astryx tooltip's rules apply; this table
99
- states Avatar's choices.
100
-
101
- | Input | Default name | Given words | Off (`false` or blank) |
102
- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------ |
103
- | Pointer | the bubble shows the name above the avatar after 200 ms, stays while the pointer is on it, and a press hides it | the same, with the words | nothing |
104
- | Keyboard focus | the bubble shows the name at once and Escape hides it; a static avatar is a tab stop | the same, with the words | nothing; a static avatar is not a tab stop |
105
- | Touch tap | a direct tap on a static avatar opens the bubble with the name; another tap on it, or a tap anywhere else, closes it, and that tap still reaches what it lands on; the tap is shared with an enclosing row; a link or button keeps its tap | the same, with the words | nothing |
106
- | VoiceOver | the name is read once, as the avatar's own; the bubble is hidden and the tap is left alone | the words are the hint, as core puts them in the description | nothing |
107
-
108
- ### Allowed variation
109
-
110
- - **AV1 — Loading.** While an image loads, the initials or the person symbol
111
- show instead of an empty plate.
112
- - **AV2 — Glyph.** The person symbol is the SF Symbol `person.fill`, not core's
113
- SVG.
114
-
115
- - **AV3 — Tooltip surface.** The tooltip is the Astryx tooltip's bubble in
116
- core's tooltip colors on every input. SwiftUI's `.help` does not fit: it is
117
- also the VoiceOver hint, so it would read the name twice, and it shows with
118
- the system's look and delay, never on keyboard focus or a tap.
119
-
120
- ### Representative states
121
-
122
- | State | Required invariant | Allowed variation |
123
- | ------------------------------ | -------------------------------------- | ----------------- |
124
- | image | the image fills the shape | image content |
125
- | failed image with a fallback | the fallback image | none |
126
- | initials, every size and shape | initials centered on the neutral plate | glyph metrics |
127
- | no name | the person symbol at 60% of the side | none |
128
- | link and button | the same drawing as static | none |
129
- | light and dark, two themes | each theme's plate and text color | none |
130
-
131
- ### Transformation and precedence order
132
-
133
- - **ORD1 — Picture.** `src` → `fallbackSrc` → initials → person symbol.
134
- - **ORD2 — Name.** `alt` → `name`, where a blank string is none; then
135
- compose with the status label (AR6), a dot's label before another
136
- element's.
137
- - **ORD3 — Control.** `href` (link) → `onClick` (button) → static.
138
-
139
- ### Performance and resources
140
-
141
- - **PR1 — System loading.** Images load through `AsyncImage` and the system
142
- URL cache; the view keeps no image cache of its own.
143
-
144
- ## Accessibility contract
145
-
146
- - **AR1 — Named or decorative.** A static avatar with a name is one image
147
- element named by `alt`, else `name`, composed with its status label (AR6);
148
- without a name and without a status label it is hidden from VoiceOver.
149
- A link or button avatar is one element with the link or button trait and the
150
- same name; the initials are never an element of their own (Swift
151
- accessibility X1, X5).
152
- - **AR2 — Touch target.** A link or button avatar, and a static avatar whose
153
- tap opens its tooltip, answers taps across at least 44 by 44 points without
154
- changing its drawn size or layout (X7).
155
- - **AR3 — Rendered tree not measured.** Tests assert what the view sets; the
156
- rendered accessibility tree and the hit region are not measured until an
157
- app-hosted target exists.
158
- - **AR4 — Unnamed taps are flagged.** A link or button avatar without `alt`
159
- or `name` logs a development warning, as core warns.
160
- - **AR5 — Initials contrast.** The initials draw in core's tokens,
161
- `color.textSecondary` on `color.neutral`, as core's Avatar does. In the
162
- default and neutral themes' dark appearance that pair is below 4.5:1, in
163
- core as well; the fix belongs to the theme tokens.
164
- - **AR6 — Status in the name.** The status label joins the avatar's name as
165
- core's message composes it ("Ada Lovelace, Online"); a status label alone
166
- names an otherwise unnamed avatar. The label comes from an `AvatarStatusDot` or a labeled `Icon` in the slot, at any depth, as core reads the `label` of the element passed as `status`, and a dot's label wins, as core's reported dot label does; SwiftUI cannot read a label from other
167
- views, so theirs does not join.
168
-
169
- ## Design relationships
170
-
171
- | Anatomy or state | Design requirement | Representation authority | Hierarchy role | Component contract |
172
- | ---------------- | ---------------------------------------- | ------------------------ | -------------- | ------------------ |
173
- | Photo, initials | Apple Human Interface Guidelines, Images | prescribed by core | prominent | FR1–FR4 |
174
-
175
- The component implements design requirements without copying their rationale.
176
-
177
- Platform controls: SwiftUI `AsyncImage` for the images, SwiftUI `Link` for
178
- `href`, and SwiftUI `Button` for `onClick` (`spec:AST-093` FR2). SwiftUI has no
179
- avatar control, so the plate, initials, and clip are drawn here. Guideline
180
- pages: Images, Buttons, and Accessibility in the Apple Human Interface
181
- Guidelines.
182
-
183
- Theme values read: `color.neutral`, `color.textSecondary`, `radius.element`,
184
- `font.family.body`, `font.weight.medium`, and Bold Text; for the tooltip bubble,
185
- `color.textPrimary`, `color.backgroundSurface`, `space.s1`, `space.s2`,
186
- `radius.container`, and the body text size and weight.
187
-
188
- ## Family and system relationships
189
-
190
- - `component:Avatar` owns the props, the sizes, the initials rule, and the
191
- fallback order; this record states only how Swift draws them.
192
- - An owner that holds an Avatar in a slot leaves an unsized Avatar at `md`
193
- (Swift slots S4).
194
-
195
- ## Verification map
196
-
197
- | Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
198
- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------- |
199
- | FR1, FR2 | `AvatarTests.swift` initials and fallback tests | core's initials cases; blank and symbol names | a wrong initial or a missing person symbol fails | `audit:swift/Avatar/picture` |
200
- | FR3, FR4 | `AvatarTests.swift` size, text-size growth, shape, and two-theme renders | each size; xx-large and the largest text size; circle and square; light, dark, butter | a wrong side, no growth or growth past 1.6 times, an unclipped corner, or a color of its own fails | `audit:swift/Avatar/look` |
201
- | FR5, AR2, AR4 | `AvatarTests.swift` link and button renders; tap, trait, tap-area, warning, `linkURL`, and web-path tests | static, link, button; malformed, relative, and empty `href` | a link or button that draws differently, a malformed `href` made a link, a web path not flagged, or an unflagged unnamed tap fails | `audit:swift/Avatar/control` |
202
- | FR8 | `AvatarTests.swift` tooltip words, focus and touch, VoiceOver hint, and wire tests; `TooltipPresenterTests.swift` for each input; `contracts.test.ts`; `parseDocType.test.ts` | name, `true`, words, `false`, blank, no name; static, link, button | a wrong tooltip, a static avatar that is not a tab stop or does not open on a tap, a control that loses its tap, or a wire value that is not the web's fails | `audit:swift/Avatar/tooltip` |
203
- | FR6 | `AvatarTests.swift` initializer and hidden tests; `contracts.test.ts` | both initializers; `isHidden`; named sizes | differing props, a drawn hidden avatar, or a pixel size in Swift fails | `audit:swift/Avatar/api` |
204
- | FR7, AR6 | `AvatarStatusDotTests.swift` placement renders of a dot and of other content at its measured place, size, an icon's growth at the largest text size, dot-label-wins, and name tests; the label preference that carries a label into the rendered name is not measured (AR3) | circle and square at `lg`; name with and without a status | a dot that changes the avatar's size, sits off the edge, or leaves the name without its label fails | `audit:swift/Avatar/status` |
205
- | AR1 | `AvatarTests.swift` naming and trait tests | `alt`, `name`, blank, none | a wrong name or a named decorative avatar fails | `audit:swift/Avatar/a11y` |
206
- | AR5 | `AvatarTests.swift` two-theme renders draw the initials in core's tokens | default and neutral, light and dark | initials in tokens other than core's fail | `audit:swift/Avatar/look` |
207
-
208
- ## Decision log
209
-
210
- No component-local decision is recorded.
211
-
212
- ## Open questions
213
-
214
- None.
215
-
216
- ## Content boundary
217
-
218
- This file does not duplicate consumer prop tables/examples, current audit
219
- results, implementation steps, or family/system rules. It links to their owners.
@@ -1,162 +0,0 @@
1
- ---
2
- schema_version: 3
3
- template_version: 7
4
- kind: component
5
- id: component:swift/AvatarStatusDot
6
- platform_of: component:AvatarStatusDot
7
- authority: draft
8
- archive_reason: null
9
- superseded_by: null
10
- approved_by: null
11
- approved_at: null
12
- owners: [cixzhang]
13
- review_triggers: [public-api, behavior, theming, accessibility]
14
- verified_by:
15
- [
16
- packages/native/apple/Tests/AstryxTests/AvatarStatusDotTests.swift,
17
- packages/native/src/contract/contracts.test.ts,
18
- ]
19
- modules: []
20
- families: []
21
- design_specs: []
22
- architecture: []
23
- contributing: []
24
- system_specs: [spec:AST-082, spec:AST-093]
25
- ---
26
-
27
- # AvatarStatusDot (Swift) component contract
28
-
29
- ## Contract at a glance
30
-
31
- | Area | Contract |
32
- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
33
- | Public contract | `AvatarStatusDot(variant: AvatarStatusDotVariant? = nil, label: String? = nil)` and `AvatarStatusDot(_ props: AvatarStatusDotProps)`, a SwiftUI `View`, placed in `Avatar`'s `status` slot. |
34
- | Behavior | Draws core's dot at the tier for its avatar's size: `success` filled, `neutral` a ring, `error` a minus bar, each in theme tokens with a surface border. Its label joins the avatar's name. |
35
- | End-user impact | A person sees who is online, away, or busy by shape as well as color, and VoiceOver reads it with the person's name ("Ada Lovelace, Online"). |
36
- | Builder impact | An app puts the dot in the avatar's trailing closure with a label. A custom icon inside the dot has no Swift form. |
37
- | Compatibility/readiness | Additive: a new view, generated `AvatarStatusDotProps`, and core's name-with-status message in the Swift string catalogs. Draft; built and tested on macOS and the iOS Simulator; device captures are attached. |
38
- | Review checks | Reject a status shown by color alone, a dot that resizes or moves the avatar, a dot that VoiceOver reads separately inside an avatar, or a color that is not a theme token. |
39
- | Governing rules | `spec:AST-082` FR4, FR7; `spec:AST-093` FR1–FR5; the Swift component API, slots (S4), theme environment, and accessibility (X1, X6) records under `packages/native/specs/swift/library/`. |
40
-
41
- This table is a review projection; the body below is authoritative.
42
-
43
- ## Intent
44
-
45
- AvatarStatusDot on Apple platforms shows a person's status on their avatar by
46
- shape and color, sized from the avatar, and gives the avatar its words.
47
-
48
- ## Compatibility and migration
49
-
50
- - Released default preserved: `not yet released`
51
- - Compatibility class: additive
52
- - Controlled/uncontrolled behavior: not applicable
53
- - Migration decision: none
54
-
55
- Consumer migration instructions belong in consumer docs and release notes.
56
-
57
- ## Ownership boundary
58
-
59
- **Owns**
60
-
61
- - The dot's size tier, fill, border, and shape glyph per variant.
62
- - Reporting its label to the avatar that holds it.
63
-
64
- **Does not own / non-goals**
65
-
66
- - Where the dot sits and how the name is composed — owned by
67
- `component:swift/Avatar` (FR7, AR6).
68
- - The meaning of the variants — owned by `component:AvatarStatusDot`.
69
-
70
- ## Public concepts
71
-
72
- | Concept | Closed values or states | Meaning | Availability by variant/orientation/state | Default | Owner | Stability | Invalid-value behavior |
73
- | ------- | ----------------------------- | -------------------------------------------------------- | ----------------------------------------- | --------- | --------------------------- | ------------ | ---------------------- |
74
- | variant | `success`, `neutral`, `error` | filled dot, ring, minus bar | always | `success` | `component:AvatarStatusDot` | experimental | none |
75
- | tier | small, medium, large | 10, 20, 32 point dot for avatars up to 36, 72, and above | from the avatar; small alone | small | `component:AvatarStatusDot` | experimental | none |
76
-
77
- ## Behavioral and layout contract
78
-
79
- | ID | Candidate invariant | Basis | Draft review state |
80
- | --- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | ------------------ |
81
- | FR1 | The dot MUST take core's tier for its avatar's side: up to 36 points a 10-point dot with a 1-point border and 1-point glyph stroke; up to 72 a 20-point dot, 2-point border, 1.5-point stroke; larger a 32-point dot, 4-point border, 2-point stroke. Outside an avatar it is small. | core `AvatarStatusDot` size tiers | verify |
82
- | FR2 | `success` MUST fill with `color.success` and draw no glyph; `neutral` MUST fill with `color.backgroundSurface` and draw a ring in `color.textSecondary` on the inner field; `error` MUST fill with `color.error` and draw a round-capped bar in `color.onError` across three quarters of the inner field. Every dot has a `color.backgroundSurface` border. The plates are the strong status fills, `color.success` and `color.error`, and their ink is the matching content role, `color.onSuccess` and `color.onError`, as core's are (`architecture:theme-tokens` INV11). | core `AvatarStatusDot` styles | verify |
83
- | FR3 | Both initializers MUST build the same `AvatarStatusDotProps`. Base props come through `AvatarStatusDotProps`: with `isHidden` the view draws nothing; `id` becomes the accessibility identifier. | Swift component API A2, A3, A7 | verify |
84
-
85
- ### Allowed variation
86
-
87
- - **AV1 — Glyph drawing.** The ring and bar are SwiftUI shapes at core's stroke
88
- widths, not core's SVG.
89
-
90
- ### Representative states
91
-
92
- | State | Required invariant | Allowed variation |
93
- | -------------------------- | ---------------------------------- | ----------------- |
94
- | each variant | its fill, glyph, and border | AV1 |
95
- | each tier | its dot, border, and stroke | none |
96
- | on a circle and a square | placed by `component:swift/Avatar` | none |
97
- | light and dark, two themes | each theme's colors | none |
98
-
99
- ### Transformation and precedence order
100
-
101
- - **ORD1 — Tier.** The avatar's side → small outside an avatar.
102
-
103
- ### Performance and resources
104
-
105
- - **PR1 — Shapes only.** The dot draws SwiftUI shapes and loads nothing.
106
-
107
- ## Accessibility contract
108
-
109
- - **AR1 — Inside an avatar.** The dot's label reaches VoiceOver through the
110
- avatar's name, and the dot is not a separate element (Swift accessibility
111
- X5).
112
- - **AR2 — Alone.** A labeled dot outside an avatar is one image element named
113
- by its label; an unlabeled one is hidden (X1).
114
- - **AR3 — Not by color alone.** Each variant has its own shape (X6, Differentiate
115
- Without Color).
116
- - **AR4 — Rendered tree not measured.** Tests assert what the view sets; the
117
- rendered accessibility tree is not measured until an app-hosted target
118
- exists.
119
-
120
- ## Design relationships
121
-
122
- | Anatomy or state | Design requirement | Representation authority | Hierarchy role | Component contract |
123
- | ---------------- | ----------------------------------------------- | ------------------------ | -------------- | ------------------ |
124
- | Dot and glyph | Apple Human Interface Guidelines, Accessibility | prescribed by core | supporting | FR1, FR2 |
125
-
126
- The component implements design requirements without copying their rationale.
127
-
128
- Platform control: SwiftUI has no status badge control for an image, so the dot
129
- is drawn from SwiftUI shapes (`spec:AST-093` FR2). Guideline page:
130
- Accessibility in the Apple Human Interface Guidelines.
131
-
132
- Theme values read: `color.success`, `color.error`, `color.onSuccess`, `color.onError`, `color.backgroundSurface`,
133
- `color.textSecondary`.
134
-
135
- ## Family and system relationships
136
-
137
- - `component:AvatarStatusDot` owns the variants and tiers; this record states
138
- only how Swift draws them.
139
- - `component:swift/Avatar` owns the dot's placement and the composed name.
140
-
141
- ## Verification map
142
-
143
- | Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
144
- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------- |
145
- | FR1 | `AvatarStatusDotTests.swift` tier test | 36, 48, 128 points; no avatar | a wrong dot, border, or stroke fails | `audit:swift/AvatarStatusDot/tier` |
146
- | FR2 | `AvatarStatusDotTests.swift` variant render, ring sides, and the busy bar in Y2K | each variant at the large tier; neutral, butter, dark; Y2K light, where on-error and the surface differ | a wrong fill, a missing ring side or glyph, a bar not in on-error, or a glyph on success fails | `audit:swift/AvatarStatusDot/look` |
147
- | FR3 | `AvatarStatusDotTests.swift` initializer test; `contracts.test.ts` | both initializers | differing props fail | `audit:swift/AvatarStatusDot/api` |
148
- | AR1, AR2 | `AvatarStatusDotTests.swift` composed-name, standalone-trait, and hidden tests; the label the dot reports to its avatar in a rendered tree is not measured (`component:swift/Avatar` AR3) | name with and without a status; a dot alone with and without a label | a composed name without the status label, or a standalone dot without its label and image trait, fails | `audit:swift/AvatarStatusDot/a11y` |
149
-
150
- ## Decision log
151
-
152
- No component-local decision is recorded.
153
-
154
- ## Open questions
155
-
156
- - **OQ1 — A custom icon in the dot.** (`human-api`) Core's `icon` is free-form
157
- content; it reaches Swift once the contract has the shared icon-name slot.
158
-
159
- ## Content boundary
160
-
161
- This file does not duplicate consumer prop tables/examples, current audit
162
- results, implementation steps, or family/system rules. It links to their owners.
@@ -1,174 +0,0 @@
1
- ---
2
- schema_version: 3
3
- template_version: 7
4
- kind: component
5
- id: component:swift/Button
6
- platform_of: component:Button
7
- authority: draft
8
- archive_reason: null
9
- superseded_by: null
10
- approved_by: null
11
- approved_at: null
12
- owners: [cixzhang]
13
- review_triggers: [public-api, behavior, theming, accessibility]
14
- verified_by: [packages/native/apple/Tests/AstryxTests/ButtonTests.swift]
15
- modules: []
16
- families: [family:buttons, family:navigation-destinations]
17
- design_specs: []
18
- architecture: [architecture:public-component-api]
19
- contributing: []
20
- system_specs: [spec:AST-082, spec:AST-093]
21
- ---
22
-
23
- # Button (Swift) component contract
24
-
25
- ## Contract at a glance
26
-
27
- | Area | Contract |
28
- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29
- | Public contract | `Button(label:variant:size:elevation:isLoading:isInterruptible:isDisabled:width:tooltip:href:base:onClick:)` and `Button(_ props: ButtonProps)`, a SwiftUI `View` in module `Astryx`. |
30
- | Behavior | A SwiftUI `Button` drawn with the Astryx button style, or a SwiftUI `Link` when an enabled Button has `href`. While loading, a spinner covers the label, which keeps its place, and presses wait unless it is interruptible. |
31
- | End-user impact | A person gets one action control whose width holds while it loads and which never runs twice by accident; a link Button stays a link while busy, so VoiceOver and keyboard focus stay on it. |
32
- | Builder impact | An app passes core's Button props; `href` makes the same view open a destination through the system. |
33
- | Compatibility/readiness | Breaking for canary callers: `action:`, `fillsWidth:`, `icon:`, and the hand-written `AstryxButtonVariant` and `AstryxButtonSize` give way to the generated `ButtonProps` (`onClick:`, `width:`, `ButtonVariant`, `ButtonSize`). Draft; built and tested on macOS and the iOS Simulator. |
34
- | Review checks | Reject a loading link that swaps to a button, a loading Button that runs `onClick` or opens its link while not interruptible, a size change while loading, or a disabled Button with `href` that opens. |
35
- | Governing rules | `component:Button` FR7–FR11; `spec:AST-082` FR3; `spec:AST-093` FR1–FR5; the Swift component API record (A2–A5) under `packages/native/specs/swift/library/`. |
36
-
37
- This table is a review projection; the body below is authoritative.
38
-
39
- ## Intent
40
-
41
- Button on Apple platforms is core's action control drawn with SwiftUI's own
42
- button and link, so presses, focus, and VoiceOver work the platform's way while
43
- its look, loading, and link behavior follow the core `Button` contract.
44
-
45
- ## Compatibility and migration
46
-
47
- - Released default preserved: `not yet released`
48
- - Compatibility class: breaking for canary callers (hand-written parameters → generated `ButtonProps`)
49
- - Controlled/uncontrolled behavior: not applicable
50
- - Migration decision: none
51
-
52
- Consumer migration instructions belong in consumer docs and release notes.
53
-
54
- ## Ownership boundary
55
-
56
- **Owns**
57
-
58
- - How Swift draws core's Button: the SwiftUI control it uses, the loading
59
- presentation, when presses land, and when `href` makes it a link.
60
-
61
- **Does not own / non-goals**
62
-
63
- - The meaning of Button's props, its variants and sizes, and its pending and
64
- disabled states — owned by `component:Button`.
65
- - Which destinations a link may open — owned by
66
- `family:navigation-destinations`.
67
- - How a prop switches to a different SwiftUI control in general — owned by the
68
- Swift component API record (A2).
69
-
70
- ## Public concepts
71
-
72
- | Concept | Closed values or states | Meaning | Availability by variant/orientation/state | Default | Owner | Stability | Invalid-value behavior |
73
- | ------------- | ----------------------------- | ------------------------------------------------------------- | ----------------------------------------- | -------- | ------------------------ | ------------ | ------------------------------------------- |
74
- | control | button; link | a SwiftUI `Button`, or a SwiftUI `Link` for an enabled `href` | always | button | `component:swift/Button` | experimental | an `href` that is not a URL leaves a button |
75
- | loading | idle; loading | `isLoading`: spinner over the label, presses wait | always | idle | `component:Button` | experimental | none |
76
- | interruptible | off; on | `isInterruptible`: presses and link opens land while loading | while loading | off | `component:Button` | experimental | none |
77
- | availability | operable; busy-only; disabled | disabled wins over loading | always | operable | `component:Button` | experimental | none |
78
-
79
- ## Behavioral and layout contract
80
-
81
- | ID | Candidate invariant | Basis | Draft review state |
82
- | --- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ------------------ |
83
- | FR1 | Both initializers MUST build the same `ButtonProps`; base props (`id`, `isHidden`) come through `ButtonProps`. | Swift component API A2, A3 | verify |
84
- | FR2 | While loading, the view MUST draw a spinner over the label, keep the label's place so its size does not change, stay at full opacity, and read as busy ("Loading", core's catalog message) to VoiceOver. It MUST NOT run `onClick` while loading unless it is interruptible; an interruptible loading Button runs `onClick` on each press. | `component:Button` FR7–FR9 | verify |
85
- | FR3 | An enabled Button with `href` MUST draw a SwiftUI `Link` to that destination, in the Astryx button style, which VoiceOver reads as a link. A disabled Button with `href` MUST draw its disabled button, which never opens. | `component:Button` FR11; `spec:AST-082` FR3 | verify |
86
- | FR4 | A loading Button with `href` MUST stay a `Link`: it 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. | `component:Button` FR9 ("a link-mode Button stays a link while busy-only"), FR11 | verify |
87
- | FR5 | A Button whose `href` is a script URL (`javascript:`, `vbscript:`) or an HTML document in a `data:` URL MUST NOT open it, after core's normalization (control characters removed, whitespace trimmed, the scheme compared in lowercase without spaces after its colon): it draws its enabled button, which runs `onClick` and does not look disabled. | `component:Button` FR11; `family:navigation-destinations` | verify |
88
- | FR6 | A disabled Button MUST keep its keyboard focus stop and show its tooltip on focus, draw its disabled look, read as a dimmed button to VoiceOver, and never run `onClick`; a focused Button that becomes disabled keeps one view structure and its focus. A Button with `href` keeps its `Link` and its disabled button in one structure, and focus moves from the link to the button when it becomes disabled, and back when it is enabled, so focus stays inside the component. | `component:Button` FR10; `family:buttons` FR3 | verify |
89
-
90
- ### Allowed variation
91
-
92
- - **AV1 — Platform controls.** The control is SwiftUI's `Button` or `Link`, so
93
- focus rings, press feedback, and how the system opens a destination are the
94
- platform's own.
95
-
96
- ### Representative states
97
-
98
- | State | Required invariant | Allowed variation |
99
- | ------------------------- | ---------------------------------------------- | ----------------------- |
100
- | loading | same size as idle; spinner; busy; presses wait | spinner is the system's |
101
- | loading and interruptible | presses land | none |
102
- | enabled with `href` | a `Link` | none |
103
- | disabled with `href` | a dimmed button that never opens | none |
104
- | loading with `href` | a `Link` that does not open until loading ends | none |
105
-
106
- ### Transformation and precedence order
107
-
108
- - **ORD1 — Availability.** Disabled, then loading (busy-only unless
109
- interruptible), then operable, as in core.
110
-
111
- ### Performance and resources
112
-
113
- - **PR1 — No work while idle.** The view holds no timers or tasks; loading is a
114
- prop the caller sets.
115
-
116
- ## Accessibility contract
117
-
118
- - **AR1 — Name and state.** The label names the control in every state; a
119
- loading Button adds core's "Loading" message as its value and announces it
120
- when loading starts. A link Button reads as a link, a disabled one as dimmed.
121
- - **AR2 — Rendered tree not measured.** Tests assert what the view sets; the
122
- rendered accessibility tree is not measured until an app-hosted target exists.
123
-
124
- ## Design relationships
125
-
126
- | Anatomy or state | Design requirement | Representation authority | Hierarchy role | Component contract |
127
- | ---------------- | ------------------------------- | -------------------------- | -------------- | ------------------ |
128
- | Spinner | the system's activity indicator | prescribed by the platform | supporting | FR2, FR4 |
129
-
130
- The component implements design requirements without copying their rationale.
131
-
132
- Platform control: SwiftUI `Button` and `Link` with `ProgressView`; they are the
133
- platform's own controls and satisfy the contract (`spec:AST-093` FR2). A
134
- `tooltip` shows through the shared Astryx tooltip (`library/tooltip.spec.md`).
135
- Guideline pages: Buttons, Progress indicators, and Accessibility in the Apple
136
- Human Interface Guidelines (`spec:AST-093` FR3).
137
-
138
- Theme values read (`spec:AST-093` FR4): `color.accent`, `color.onAccent`,
139
- `color.error`, `color.onError`, `color.neutral`, `color.textPrimary`,
140
- `size.elementSm`, `size.elementMd`, `size.elementLg`, `radius.element`,
141
- `space` steps for padding, `font.label` and `font.family.body`, the
142
- `shadow.low`, `shadow.med`, and `shadow.high` layers, and the Dynamic Type
143
- scale.
144
-
145
- ## Family and system relationships
146
-
147
- - `component:Button` owns the props, the pending and disabled states, and link
148
- mode; this record states only how Swift draws them.
149
- - `family:navigation-destinations` owns destination handling for links.
150
-
151
- ## Verification map
152
-
153
- | Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
154
- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
155
- | FR1 | `ButtonTests.swift` initializer test | both initializers | differing props fail | `audit:swift/Button/api` |
156
- | FR2 | `ButtonTests.swift` loading, width, and interruptible tests | loading; loading and interruptible | a press that lands while loading, a size change, or dimming fails | `audit:swift/Button/loading` |
157
- | FR3 | `ButtonTests.swift` `href` test | enabled and disabled with `href` | a disabled Button that opens, or an enabled one that is not a link, fails | `audit:swift/Button/link` |
158
- | FR4 | `ButtonTests.swift` `href` test with loading, and with loading and interruptible | loading with `href`; interruptible | a busy link that swaps to a button or opens before loading ends fails | `audit:swift/Button/link` |
159
- | FR5 | `ButtonTests.swift` refused-destination and normalization tests | `javascript:`, `vbscript:`, `data:text/html`, padded, mixed case, with controls, and `data: text/html`; a `data:image` and a `mailto:` that still open | a refused destination that opens, an unnormalized one that slips through, or a refused one that looks disabled, fails | `audit:swift/Button/link` |
160
- | FR6 | `ButtonTests.swift` disabled tests, including a disabled Button with `href` keeping its destination for one structure; the focus stop and the focus move are not measured until an app-hosted test can observe them | disabled with and without a tooltip; disabled with `href` | a disabled Button that runs `onClick` or opens its link, or one marked without its focus stop, fails | `audit:swift/Button/disabled` |
161
- | AR1 | `ButtonTests.swift` accessibility assertions | idle; loading; link | a missing name, value, or announcement fails | `audit:swift/Button/a11y` |
162
-
163
- ## Decision log
164
-
165
- No component-local decision is recorded.
166
-
167
- ## Open questions
168
-
169
- None.
170
-
171
- ## Content boundary
172
-
173
- This file does not duplicate consumer prop tables/examples, current audit
174
- results, implementation steps, or family/system rules. It links to their owners.