Repository navigation
feat: implement design-system.md's four micro-animations, gated on reduce-motion - #783
Merged
Merged
Conversation
design-system.md's Motion table mandates every transform animation be OFF (not shortened) under accessibilityReduceMotion, but that gate existed at exactly one call site in the repo (SettingsUI/ReminderPrimerSheet) as an inline ternary — every other animatable surface had no animation at all, so no gate either. Centralizes the ternary in GameShellUI so the upcoming board/completion animations (and future ones) can't reintroduce an ungated animation by omission. Co-Authored-By: Claude Fable 5 <[email protected]>
Implements the three per-cell rows from design-system.md's Motion table that BoardCellView had zero coverage for (repo-wide, only one unrelated file gated any animation before this branch): - Cell tap → selection: 100 ms ease-out on the background fill, scoped to isSelected alone so the peer-highlight / same-digit / given background swaps (not covered by this row) stay instant. - Cell digit place: 80 ms ease-out with a 0.9→1.0 scale transition. `.id(digit)` forces every new digit — including overwriting an existing one — to re-insert rather than update in place, since `.transition` only fires on insertion/removal. - Error highlight pulse: two explicit 200 ms ease-in-out legs (dip to 0.55 opacity, then recover) fired from `onChange(of: isError)`, rather than `Animation.repeatCount(_:autoreverses:)`, whose repeat/autoreverse combination leaves the final model value ambiguous. All three route through MotionGate and read `@Environment(\.accessibilityReduceMotion)`, so they turn off (not shorten) under reduced motion, per the spec's Reduced-motion column. Co-Authored-By: Claude Fable 5 <[email protected]>
MS's equivalent of design-system.md's "Cell digit place" row (80 ms scale 0.9→1.0 ease-out) is a cell's content appearing on reveal (number or mine glyph) or on flag placement — both surface through the same `content` switch, so one MotionGate-routed `.animation(value: cell.state)` plus a `.transition(.scale(scale: 0.9))` on each glyph covers both. MS has no per-cell equivalent of Sudoku's "Cell tap → selection" (no persistent selected-cell concept — each tap immediately reveals or flags) or "Error highlight pulse" (no per-cell wrong-state; a hit mine is a terminal/board-level event handled by the completion overlay, not a transient per-cell error), so those two rows are intentionally not mapped here. Co-Authored-By: Claude Fable 5 <[email protected]>
… hatch Implements design-system.md's "CompletionView hero stat reveal" (350 ms fade + 8 pt rise, staggered 60 ms per element) in the shared GameShellUI.CompletionScreen, so it covers both apps' completion/win/loss screens from one place. Reduced motion drops straight to the revealed state (instant fade, no rise), routed through MotionGate like the board animations in the prior two commits. CompletionScreen's `.onAppear`-driven reveal does not fire on an NSHostingView that's never attached to a real window — confirmed empirically by re-recording the hero snapshots and finding a permanently blank card, unchanged by adding a several-hundred-ms wait beforehand. That's exactly how the snapshot-test harness (`hostingView(...)`) AND the ASC screenshot emitter (`emitASCScreenshot`, which routes through the same helper) render every fixture: a single synchronous frame with zero elapsed wall-clock time, so `.onAppear` never runs and the state that would flip the hero visible never flips. Without a fix, App Store screenshots of the completion screen would ship blank. Adds `completionHeroSkipsReveal`, an `@Environment` escape hatch mirroring the existing `bannerSlotLoadingPreview` pattern (#732: same class of problem — a genuinely timing-dependent view needing a deterministic override for offline rendering). `false` by default (the live app is unaffected); the snapshot tests and ASC emitters for both apps now inject `true` at their `CompletionView`/`MinesweeperCompletionView` call sites. An earlier attempt to set this globally in the shared `hostingView(...)` helper was reverted — it broke unrelated Home/DailyHub structural-baseline tests by changing every hosted view's mangled type signature, so the override is scoped to each Completion-rendering call site instead. All affected Completion snapshot baselines were re-recorded and are byte-identical to the pre-existing committed PNGs (the reveal animation's settled end-state renders the same as the old static, unanimated render), so no baseline files changed. Co-Authored-By: Claude Fable 5 <[email protected]>
wei18
added a commit
that referenced
this pull request
Jul 13, 2026
…ode-toggle contrast (#798) Three non-blocking follow-ups from the #780/#783 reviews (issue #786): 1. Spacing literal (MinesweeperBoardView.modeToggle): `.padding(.horizontal, 12)` snapped to `theme.spacing.small` (8) — SpacingTokens names no 12 step, and `medium` (16) is reserved by the design-system pairing table for card-level internal padding. The chip's `.frame(minWidth: 44, minHeight: 44)` keeps the HIG tap-target floor independent of the padding value. 2. MotionGate consistency (SudokuKit BoardCellView error pulse): the hand-written `guard !reduceMotion` now routes through the shared `MotionGate.animation(_:reduceMotion:)` via `guard let`, matching the two `.animation` modifiers in the same file. `guard let` (not `withAnimation(nil)`) keeps behavior identical: reduce-motion on means no pulse at all — the opacity value never dips. 3. Mode-toggle contrast (MinesweeperBoardView.modeToggle reveal state): `.white` on `accent.primary` hard-failed AA in dark mode. WCAG ratios: - before: white / 0x3E6B8C light = 5.70:1 (pass); white / 0x7FAFCF dark = 2.35:1 (FAIL) - no text.* token passes dark either (text.primary 0xEEF1F4 / 0x7FAFCF = 2.07:1) — the accent ramp flips light<->dark opposite to the text ramp - after: `theme.surface.primary` (0xFFFFFF light / 0x1C2026 dark) = 5.70:1 light / 6.96:1 dark — both AA (>= 4.5:1). Light mode renders byte-identically (still white). Re-recorded the 11 MS board baselines that contain the mode toggle (covered light/dark/iPad, banner-reserved light/dark, flagged/midReveal/mineHit light/dark); terminal-overlay baselines are pixel-identical (overlay covers the toggle) and were left untouched. Pixel-diff confined to the toggle chip bbox in every re-recorded PNG; eyeballed light (white on slate, narrower chip) and dark (dark ink on light blue, readable). Note for the record: the first re-record attempt captured Flag mode because the swiftpm test host's UserDefaults domain (`swiftpm-testing-helper`) carried a leaked `com.wei18.minesweeper.board.tapMode = flag` from an earlier run (#720 G3 seeds the toggle from UserDefaults.standard at view init). The key was cleared before the final recording; the snapshot render's dependence on host defaults remains a latent recording hazard. Part of #786. Co-authored-by: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implements the four micro-animations
design-system.md§Motion specifies, none of which existed in the UI layer before this branch (repo-wide, exactly one file —SettingsUI/ReminderPrimerSheet— gated any animation behindaccessibilityReduceMotion; everywhere else had no animation, hence no gate, either).BoardCellView's background fill, scoped toisSelectedalone.BoardCellView's digitText; MS's equivalent content-appearing moment (reveal glyph / flag icon) inMinesweeperCellButton.BoardCellView, two explicitwithAnimation(...completion:)legs rather thanAnimation.repeatCount(_:autoreverses:)(see commit message for why).GameShellUI.CompletionScreen, so it covers both apps' completion/win/loss screens.Every animation routes through a new
MotionGatehelper (GameShellKit/Sources/GameShellUI/Motion/MotionGate.swift) reading@Environment(\.accessibilityReduceMotion), so reduced motion turns each one OFF (not shorter), per the spec.MS scope note: MS has no per-cell equivalent of "cell tap → selection" (no persistent selected-cell state — each tap immediately reveals/flags) or "error highlight pulse" (no per-cell wrong state; a hit mine is a terminal/board-level event, not a transient per-cell error). Both are intentionally left unmapped for MS rather than inventing new behavior; see the MS commit message.
No animation is added to completion beyond the spec — no celebration/confetti effects, matching the design-system's explicit restriction.
Why a 4th, unplanned fix is in here
Implementing the completion hero reveal via the standard
.onAppear+ state-flip idiom broke the snapshot-test baselines in a way that turned out not to be "needs re-recording" but a real correctness bug:.onAppearnever fires on anNSHostingViewthat isn't attached to a real window, which is exactly how both the snapshot-test harness and the ASC screenshot emitter (emitASCScreenshot, real App Store screenshot generation) render every fixture — a single synchronous frame, zero elapsed wall-clock time. Confirmed empirically (re-recorded, got a permanently blank hero card; adding a 600ms wait before capture didn't help, because the callback that would flip the reveal state never runs there at all, not because it hadn't finished yet).Fixed with
completionHeroSkipsReveal, an@Environmentescape hatch mirroring an existing pattern in this codebase (BannerSlotView.bannerSlotLoadingPreview, #732 — same class of problem: a genuinely timing-dependent view needing a deterministic override for offline rendering). Defaultsfalse(live app unaffected); the snapshot tests and ASC emitters for both apps injecttrueat theirCompletionView/MinesweeperCompletionViewcall sites only.An earlier attempt set this globally inside the shared
hostingView(...)test helper instead of at each call site — reverted because it changed every hosted view's mangled type signature, breaking unrelated Home/DailyHub structural-baseline tests (assertViewStructure). Scoped to Completion call sites only in the final version.Evidence / verification
swift buildclean for GameShellKit, SudokuKit, MinesweeperKit.swift test(all targets): GameShellKit 16/16, SudokuKit 287/287, MinesweeperKit 240/240 — all green.SnapshotMode.recordModeto.all, scoped to the affected suites) and turned out byte-identical to the pre-existing committed PNGs — the reveal animation's settled end-state renders the same as the old unanimated static render — so no baseline files changed in this PR.mise run lint:swift: clean.mise run scan:l10n: passes (no new user-facing strings).mise run scan:hygiene/ gitleaks: clean.Not verified
design-system.md's table..onAppearbehavior (confirmed not to fire in the offline harness, hence the escape hatch) was not independently re-verified as correctly firing in a real windowed app — this is standard, well-established SwiftUI behavior, not something this PR changes, but it's called out for completeness since the bug that motivated the escape hatch was only caught by empirical testing in the offline harness.🤖 Generated with Claude Code