Skip to content

feat: add adaptive SwiftUI colours and text styles - #10

Merged
lemarier merged 2 commits into
mainfrom
lemarier/swiftui-adaptive-tokens
Sep 24, 2026
Merged

lemarier merged 2 commits into
mainfrom
lemarier/swiftui-adaptive-tokens

Conversation

@lemarier

@lemarier lemarier commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Swift apps could read Origin89Tokens.light and .dark, but every view had to choose between them from colorScheme, and fonts were only available as PostScript name strings. The Apps setup flow (origin89hq/apps#1) needs brand colours and type in its own screens.

The generator now also emits Origin89Tokens.adaptive, whose colours resolve per appearance through UIColor/NSColor providers, so it stays generated from @origin89/brand and covered by brand:check. Views write .foregroundStyle(.origin89.muted) or Color.origin89.surface. Font.origin89Label, .origin89Value and .origin89Data wrap the bundled faces with Dynamic Type scaling and register them on first use. Registration is now a once-per-process static, so Origin89Fonts.register() no longer needs the main actor. Origin89Reading uses the new API with no visual change. It needs no changeset: after #11 the Swift package is released with just swift-release.

Validation: swift test (6 tests: every palette key against the fixed light and dark values, the shorthand, and that the bundled fonts load by name), the iOS 17 Simulator build, and pnpm check pass. Swapping light and dark in the provider fails 33 expectations. The colour tests run on the main actor: AppKit never returns from resolve(in:) for appearance-backed colours off the main thread, including NSColor.labelColor.

Copilot AI lite review requested due to automatic review settings September 24, 2026 13:11
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The SwiftUI package adds an adaptive palette generated from light and dark tokens, a public shape style, and three Dynamic Type-aware font styles backed by bundled fonts. Origin89Reading now uses the new styles instead of selecting palette colors and creating fonts by name. The change also adds theme tests, updates the Swift usage instructions, and refreshes the generated-token hash.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: 🔵 Low · up to 44359

Custom text styles can fall back to a system font if registration fails. This is a bounded issue to fix or explicitly accept before release.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 5 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main changes: adaptive SwiftUI colors and text styles.
Description check ✅ Passed The description directly explains the adaptive color API, bundled text styles, font registration, affected views, and validation results.
Full details: Docstring Coverage

Explanation

Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 5 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

🟡 Other comments (1)
platforms/swiftui/Sources/Origin89UI/Theme.swift-32-32 (1)

32-32: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Handle non-duplicate font registration failures.

The bundled font files exist, and the font test confirms the normal registration path. However, CTFontManagerRegisterFontsForURL can return false for errors other than CTFontManagerError.alreadyRegistered. This closure ignores that result and marks registration complete, so later Font.origin89* calls do not retry and can use a fallback font. Capture and report the CFError, while treating alreadyRegistered as success.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: QUIET

Plan: Advanced

Run ID: fd0d439f-cb1b-4b6f-9fe4-17cd3ec0ca83

📥 Commits

Reviewing files that changed from the base of the PR and between eca5951 and 44359b8.

📒 Files selected for processing (7)
  • README.md
  • brand-provenance.json
  • platforms/swiftui/Sources/Origin89UI/GeneratedTokens.swift
  • platforms/swiftui/Sources/Origin89UI/Reading.swift
  • platforms/swiftui/Sources/Origin89UI/Theme.swift
  • platforms/swiftui/Tests/Origin89UITests/ThemeTests.swift
  • scripts/generate-brand.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@lemarier
lemarier merged commit 8c120dc into main Sep 24, 2026
4 checks passed
@lemarier
lemarier deleted the lemarier/swiftui-adaptive-tokens branch September 24, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants