Repository navigation
spec(native): augmentable variants on Swift are open types the theme extends - #8039
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 496 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 |
|
/approve-spec 3170c9f |
There was a problem hiding this comment.
Requesting changes before this record merges: V3 has Swift read style data from a theme's web component overrides, which current AST-082 FR18/FR10 and AST-093 FR4 keep in the web part and route through native platform entries, and the record's own OQ1 still calls that source undecided. Please keep V3 source-neutral (or point it at platform-entry components) until the AST-082 amendment lands, or land that amendment first and cite it.
- V4's fallback also covers built-in values a theme leaves unstyled, so under neutral a Swift
primaryorghostButton would draw the defaultsecondarylook; limit it to values with no built-in look and make the baseline independent of the active theme. - The Relation line and V1–V3 cite rules that are not on
mainyet (an augmentable form in AST-082 FR4, a core-contract augmentable marker, and the theme generator's G1, G7, name rule and drift check); merge after those records or name them as pending dependencies.
[Automated review]
| weight, and padding. Values come from the theme's own style declarations, | ||
| resolved per mode with references to tokens replaced by the token's value | ||
| (theme generator G1, G7). A style key Swift does not draw is reported and |
There was a problem hiding this comment.
This makes the theme's web component overrides the Swift style source, but current AST-082 FR18 keeps overrides keyed by web theme targets in the web part and sends native component theming through platform entries (FR10), and AST-093 FR4 lists only tokens and defineNativeTheme as native brand sources. OQ1 below also says the source is still open. Could V3 stay source-neutral, or name platform-entry components, until the AST-082 amendment lands?
| augmentable prop from the theme in the environment, by raw value. A value the | ||
| theme does not style draws the component's base look, the style of the | ||
| prop's default value; a development build logs that fallback once, naming |
There was a problem hiding this comment.
As written, this fallback also covers built-in values a theme leaves unstyled: neutral declares only Button variant:destructive, so .primary and .ghost would draw the default secondary look and log. Suggest limiting the fallback to values with no built-in look and stating that the base look does not depend on the active theme.
| - Relation: applies the native form of the AST-082 FR4 rule for augmentable | ||
| props (a string-backed value with built-in constants, extended by the theme | ||
| generator, that decodes any name and draws an unknown name in the base look) | ||
| to Swift, and extends the theme generator spec. Web augmentation: a theme adds a |
There was a problem hiding this comment.
AST-082 FR4 on main lists closed string sets but no open or augmentable form, and the theme generator record (G1, G7, its name rule and drift check) is not on main yet. Merging after those records, or naming them here as pending dependencies, keeps this citation accurate.
|
/approve-spec 08eb7d2 |
There was a problem hiding this comment.
This revision resolves the earlier review's two main points (V3 now reads native platform entries and V4 keeps built-in looks), but approval now waits on an engineering owner's decision: the draft requirements V1–V5 and their acceptance checks need an approval on the current head, because the earlier /approve-spec named the previous commit, and spec:AST-082 FR4 must carry the open string-set form V1 relies on before this record merges. An engineering owner records that decision by commenting /approve-spec 08eb7d2c8a6c2ad9de7f8b98ada7b53090b9a3b6 on this pull request; the author may do so as an engineering owner. Before merge, please also address:
- V3 and V4 keep one style per value and mode, so a platform entry scoped by
minVersion/maxVersionor underplatforms.macoshas no place, while AST-082 FR10 applies each entry only on its platform and inside its range. - The Relation line, V1, V3 and the Drift row cite an AST-082 FR4 rule and theme-generator clauses that are not on
main; land after #8070 and #8031 or mark them as pending dependencies. - V4's base look (the default value's built-in look) is undefined for Heading
type, which has no default and falls back to its level's look perarchitecture:component-theming-surfaceINV14.
[Automated review]
| - **V3 — Native style data comes from platform entries.** Each theme file | ||
| carries, per mode, the style its native theme's platform entries give a | ||
| value on an augmentable axis (`platforms.ios[].components`, keyed by the |
There was a problem hiding this comment.
This table holds one style per value and mode, read from platforms.ios. AST-082 FR10 lets a platform entry carry minVersion/maxVersion and says it “applies only on its platform and inside its range”, with a later matching entry replacing an earlier one (as resolveNativeTheme does). The Swift binding also builds for macOS. Could V3 keep each entry's platform and range and resolve them against the running OS, say what a macOS build reads, and add a ranged entry and a macOS row to the V3 check?
| - **V3 — Native style data comes from platform entries.** Each theme file | ||
| carries, per mode, the style its native theme's platform entries give a | ||
| value on an augmentable axis (`platforms.ios[].components`, keyed by the | ||
| component's target and the value, such as `'variant:primary-muted'`), added |
There was a problem hiding this comment.
Which shape is this? Read as a component target holding a 'variant:…' key that holds the style map, it is one level deeper than today's PlatformEntry.components (Record<string, Record<string, string | number>>), and a fixture written that way fails to type-check (TS2322). Giving the exact entry shape, and the type change if it is the nested one, would make the V3 check writable.
| restyle. A value with no built-in look that the theme does not style draws | ||
| the component's base look: the built-in look of the prop's default value in | ||
| the core contract, which does not depend on the active theme; a development |
There was a problem hiding this comment.
Heading type is backed by core's augmentable HeadingTypeMap but has no default value; on the web an unknown type keeps the level's look, and architecture:component-theming-surface INV14 names Heading.level as its baseline. Defining the base look as the component's look with the prop absent would cover it.
| - Relation: applies the native form of the AST-082 FR4 rule for augmentable | ||
| props (a string-backed value with built-in constants, extended by the theme | ||
| generator, that decodes any name and draws an unknown name in the base look) | ||
| to Swift, and extends `packages/native/specs/swift/library/theme-generator.md`. |
There was a problem hiding this comment.
On main, AST-082 FR4 lists closed string sets only, and theme-generator.md (with the name rule, G1, G7 and the drift check cited below) does not exist yet. Merging after those records land, or naming them here as pending dependencies, keeps these citations accurate.
|
/approve-spec 8c3c4da |
There was a problem hiding this comment.
Requesting changes before this record merges: the direction in V1–V5 is approved for this head, but V1 needs the open string-set form that AST-082 FR4 on main does not have yet (#8070), and the record extends a theme-generator record that is not on main (#8031). Please land those first and rebase, and also:
- add a Current state line saying
PlatformEntry.componentstakes only flatstring | numbervalues today, since V3 needs the nested'<axis>:<value>'map; - say whether V4's base look follows a platform entry's restyle of the default value, and add a check for that case.
A rebase changes the head, so an engineering owner then records approval again by commenting /approve-spec <full head SHA>; the author may do so as an engineering owner.
[Automated review]
| `components`, a target holds, beside its own style keys, a key | ||
| `'<axis>:<value>'` whose value is that value's style map | ||
| (`components.button['variant:primary-muted'] = {backgroundColor: …}`); the | ||
| `PlatformEntry.components` type allows that nested map. Each theme file keeps |
There was a problem hiding this comment.
PlatformEntry.components is Readonly<Record<string, Readonly<Record<string, string | number>>>> today (packages/native/src/theme/defineNativeTheme.ts), so a 'variant:primary-muted' style map fails to type-check (TS2322). Could Current state say the type takes only flat string | number values today, so readers see that V3 widens it?
| the component's base look: its look with the prop absent, which does not | ||
| depend on the active theme. For a prop with a default in the core contract | ||
| that is the default value's built-in look; for a prop with no default, such |
There was a problem hiding this comment.
When an applying platform entry restyles the default value (Button's variant:secondary), a Button with the prop absent draws that restyle, so "its look with the prop absent" depends on the theme and differs from "the default value's built-in look". Could this say the base look is the built-in look before any platform-entry restyle, and add a V4 check with an entry that restyles the default?
|
/approve-spec 6b596e5 |
There was a problem hiding this comment.
Requesting changes before this record merges: V1–V5 are approved for this exact revision, but the record still rests on two records that are not on main yet, the AST-082 FR4 open string-set form (#8070) and the Swift theme-generator record whose name rule, G1, G7 and drift check it cites (#8031). Please land those first and rebase, and fix V5, which says a custom value changes only paint and shape while V3 also gives it font and padding values. A rebase changes the head, so an engineering owner then records approval again by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.
[Automated review]
| - **V5 — Accessibility does not depend on the variant.** A custom value changes | ||
| only paint and shape. Name, role, and state come from the core contract, as |
There was a problem hiding this comment.
V3 (lines 47–49) gives a custom value font family, size, weight and padding, which are not paint or shape. Saying the value changes only its V3 style keys keeps a V5 check from asserting that text size and spacing stay fixed.
6b596e5 to
dfe19fa
Compare
|
/approve-spec d97b4a3 |
There was a problem hiding this comment.
Requesting changes before this record merges: V1–V5 are approved for this exact revision and the records it builds on are now on main, but V4's fallback does not match AST-082 FR4, which says a native platform draws a name it has no rule for in the component's base look “as the web does”. On the web, a Button, Card or Badge value that a theme adds but does not style draws with no value style at all, while V4 and its check draw the default value's look (Button's filled secondary), so please align V4 and its check with the web's no-match look, or amend FR4 first if the default look is the intended fallback. Two smaller fixes:
- V5 says a custom value changes only paint and shape, but V3 also gives it font and padding values.
- V1 names built-in constants by “the theme generator's name rule”, but G3 allows the keyword
defaultwhile G6 fails the run on it, which decides whether Card's built-indefaultgenerates.
A new commit changes the head, so an engineering owner then records approval again by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.
[Automated review]
| restyle. A value with no built-in look that no applying entry styles draws | ||
| the component's base look: its look with the prop absent, including an | ||
| applying platform entry's restyle of that look, so an unstyled added value | ||
| matches the brand's default. For a prop with a default in the core contract | ||
| that is the default value's built-in look; for a prop with no default, such |
There was a problem hiding this comment.
AST-082 FR4 says a native platform draws a name it has no rule for in the component's base look “as the web does for an augmented name with no built-in style”. On the web, Button, Card and Badge look their value style up by name (Button.tsx:734, Card.tsx:306, Badge.tsx:211), so an added value with no theme rule draws with no value style, not the default value's look; Heading keeps the prop-absent look on purpose (Heading.tsx:251–254). Could V4, and the check at line 78, define the base look as what the web draws, or should FR4 be amended first if the default look is the intended fallback?
| - **V5 — Accessibility does not depend on the variant.** A custom value changes | ||
| only paint and shape. Name, role, and state come from the core contract, as |
There was a problem hiding this comment.
V3 (lines 47–49) also gives a custom value font family, size, weight and padding, which are neither paint nor shape. Saying the value changes only its V3 style keys would keep V5 consistent with V3.
| of a closed `enum`. Each built-in value is a static constant named by the | ||
| theme generator's name rule (`.primary`, `.ghost`). Decoding accepts any |
There was a problem hiding this comment.
theme-generator.md has two naming rules: G3 allows the keyword default (lines 49–51) and G6 fails the run on any keyword (lines 78–79). Card's built-in default generates under one and fails under the other; naming the clause, or saying a keyword built-in is escaped as today's contract generator does, would settle it.
d97b4a3 to
f054792
Compare
|
/approve-spec 23fb1d6 |
There was a problem hiding this comment.
Requesting changes for one sentence: V1–V5 are approved for this exact revision, the records it builds on are on main, and V4 and its check now match AST-082 FR4's base look, but the Summary (lines 16–17) still says a variant name nothing styles "draws the component's default look", which for Button, Card and Badge is another value's look (Button's filled secondary), the fallback V4 now rules out. Please reword it to the base look, for example "A variant name nothing styles draws the component's base look, with no value style, instead of failing." A new commit changes the head, so an engineering owner then records approval again by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.
[Automated review]
| styled as the brand's native theme defines it. A variant name nothing styles | ||
| draws the component's default look instead of failing. |
There was a problem hiding this comment.
This still promises the default look, which for Button, Card and Badge is another value's look (a Button with no variant draws secondary). V4 (lines 61–63), its check (line 78) and AST-082 FR4 say the base look with no value style. Suggested wording: "A variant name nothing styles draws the component's base look, with no value style, instead of failing."
23fb1d6 to
5ebb4fd
Compare
|
/approve-spec 5ebb4fd |
There was a problem hiding this comment.
No changes needed: an engineering owner approved V1–V5 and their checks for this exact revision, the AST-082 FR4 open string set and the Swift theme-generator record they build on are on main, and the Summary now gives an unstyled added value the same base look as V4 and FR4. One optional clarification: V2 does not say where a theme adds a value, and read with V3 only native platform entries can, so a value a theme adds only in its web overrides, such as neutral's Badge gray, would get no Swift constant until its native theme declares it. If you edit the record, the new commit needs a fresh /approve-spec <full head SHA> from an engineering owner, which you may record yourself as one.
[Automated review]
| encodes and decodes the raw string unchanged. Code never switches over every | ||
| value. | ||
| - **V2 — Each theme's added values become static members.** For each | ||
| augmentable axis, the theme generator collects the values a theme adds and |
There was a problem hiding this comment.
Optional clarification: this does not say which declaration adds a value. Read with V3 ("The theme's web component overrides are never read", line 55) and the theme generator's G1, only native platform entries can, so a value a theme adds only in its web overrides, such as neutral's Badge gray, would get no Swift constant until its native theme declares it. Naming the source here, and the kind of fixture in the V2 check (line 76), would settle it.
5ebb4fd to
4b38f3c
Compare
|
/approve-spec 4b38f3c |
There was a problem hiding this comment.
No changes needed: an engineering owner approved V1–V5 and their checks for this exact head, the AST-082 FR4 open string set and the Swift theme-generator record they build on are on main, and the record stays consistent with the unprefixed Theme names and the theme-environment record now on main. Two optional clarifications would help implementers: V2 could name which theme declaration adds a value (read with V3, a value a theme adds only in its web overrides, such as neutral's Badge gray, gets no Swift constant), and V3 could say whether a later platform entry replaces an earlier one per member, as resolveNativeTheme does today, or per value style. If you edit the record, the new commit needs a fresh /approve-spec <full head SHA> from an engineering owner, which you may record yourself as one.
[Automated review]
| style is chosen by AST-082 FR10's entry rule: only entries for the running | ||
| platform whose range holds the running OS version apply, and a later | ||
| matching entry replaces an earlier one. The theme's web component overrides |
There was a problem hiding this comment.
Optional clarification: resolveNativeTheme applies this rule per member, so a later matching entry that carries any components replaces the earlier entry's whole components map (packages/native/src/theme/defineNativeTheme.ts:220–221). Read that way, a version-scoped entry that styles only card drops the Button value styles an earlier entry gave on those OS versions. Saying whether Swift resolves per member, as the TypeScript resolver does, or per value style, and adding that case to the V3 check (line 77), would keep the two resolvers from diverging.
Exact decision needed
How augmentable component props (values a theme adds to a visual axis, such as a new button variant) work in Swift: an open, string-backed type instead of a closed enum, static members for each theme's added values, per-theme style data, and a by-name lookup that falls back to the default. Draft until the owner approves; nothing is built from it before then.
Existing authority searched
spec:AST-082FR4 (portable props). The native form for augmentable props is decided: a string-backed value with built-in constants, extended by the theme generator, decoding any name, with unknown names drawn in the base look. This spec applies it. FR10 (native component theming through platform entries), FR18 (component overrides keyed by web targets are the web part).componentskeys such as'variant:primary-muted'generate a type augmentation in the theme build.Decision
structwith built-ins as static constants; decoding accepts any string; the wire carries the raw string. Swift keywords are written in backticks (Card'sdefaultis.`default`).Variants.swift.defineNativeThemeplatform entries for the platform being built (platforms.ios,platforms.macos), ascomponents.<target>['<axis>:<value>']style maps; entries keep their version ranges and resolve at run time by AST-082 FR10's rule (running platform and OS version; later entry wins); web component overrides are never read.Rejected alternatives
None recorded in the spec.
Claim scope and non-goals
Which props are augmentable is set by the AST-082 FR4 amendment. Style data comes only from native platform entries, as AST-082 FR10/FR18 and AST-093 FR4 require.
Landing order
Applies the AST-082 FR4 amendment for augmentable props (
docs/specs/AST-082-native-first-surfaces/spec.md, #8070) and extendspackages/native/specs/swift/library/theme-generator.md(#8031). Lands after both.Evidence and implementation relationship
One file:
packages/native/specs/swift/library/augmentable-variants.md. Published themes style built-in and added values on augmentable axes (for examplevariant:muted).Writing rubric results
Scope
packages/native/.