Repository navigation
refactor: move the shadow token into a colorset - #37
Conversation
The toast, nav bar and converter badge drew their icons from string names that conventions.sh could not see; they now use DashIcon cases. NavigationBarElement keeps its public raw values and draws through DashIcon.NavigationBar; a test keeps the two in step. conventions.sh flags a package-bundle lookup whose name is not one literal (outside the Icon_DashUI / Color+DashUI resolvers), a computed name in the host bundle, an empty name and a computed dashAsset() name. A unit test checks that every DashIcon case resolves in the package bundle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Color.dash.shadow was the only token built in code (UIColor(red:) behind a trait switch), which kept Color+DashUI.swift exempt from the "no colors from components" rule. It is now the Shadow colorset, subtle on light and clear on dark, and the rule covers that file too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Resolve and document the shadow colorset Sources/DashUIKit/Foundation/Color+DashUI.swift, docs/foundation.md, docs/navigation-and-containers.md |
DashColors.shadow now uses the Shadow colorset through dashAsset on all supported platforms. The documentation identifies the colorset as the source. |
Check color tokens for hardcoded colors .github/scripts/conventions.sh, .github/scripts/tests/conventions-test.sh |
The conventions script checks Color+DashUI.swift for hardcoded colors and retains its exemption for asset-name checks in the token resolver. A regression test checks that a component-built color in that file is reported. |
Priority:
Estimated code review effort: 2 (Simple) | ~15 minutes
Change: Refactor
Possibly related PRs
- dashpay/DashUIKit#30: Introduced the conventions script and hardcoded-color rule that this change extends.
- dashpay/DashUIKit#36: Expanded asset scanning and
dashAssetchecks related to the resolver rules used by this change.
Merge Risk: 
Minimal · up to 8a4c5
-
The shadow colorset migration and expanded convention checks have no established merge-blocking issue. Merge after normal checks pass.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 3 files. (2 skipped: 2 unsupported.)
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
romchornyi-pitcrew
left a comment
There was a problem hiding this comment.
✅ APPROVE · 5 non-blocking recommendations · no blockers or majors — reviewed at 962cca5140
| Level | Verdict | |
|---|---|---|
| 1 · Idea | ✅ valid | shadow was the only Color.dash token built in code, and it kept all of Color+DashUI.swift out of rule 5. |
| 2 · Architecture | ✅ right layer | A colorset like every other token; the scanner exemption shrinks to what the file still needs (the token resolver). |
| 3 · Completeness | ✅ complete | One user (MenuViewModifier); switchThumbShadow is a separate colorset token and left for a design decision; both docs that describe the token are updated. |
| 4 · Code | ✅ clean | iOS parity checked: light sRGB 0.72/0.76/0.80 @ 0.10 as before, dark alpha 0 (renders as .clear); public name and type unchanged; catalog JSON valid, no namespace, no name clash. |
5 non-blocking recommendations
- "Every token is a colorset" is wider than rule 5 — — rule 5 catches component initializers only; a token written as
DashUIKit/.github/scripts/conventions.sh
Line 20 in 962cca5
.black.opacity(0.1)orColor(uiColor: UIColor { … })without component labels still passes. Requiring everypublic static varinDashColorsto be exactlydashAsset("<literal>")would make the claim true. (not verified) - macOS change is light appearance only — — the catalog's dark entry also applies on macOS, so dark previews stay transparent; the PR description could say "in light appearance".
- Rule 5 message inside
Color+DashUI.swift—— "add a token to Foundation/Color+DashUI.swift" reads oddly for a violation in that very file; "back the token with a colorset and useDashUIKit/.github/scripts/conventions.sh
Line 240 in 962cca5
dashAsset(\"Name\")" fits both places. - Ragged comment wrap — —
DashUIKit/.github/scripts/conventions.sh
Line 195 in 962cca5
# declared. In this packagebreaks mid-sentence; re-wrap lines 192–197. - Doc comment restates catalog values — — no other token documents its values in Swift, and this one goes stale if the colorset changes.
Review details
Triage: normal (token refactor + CI script), stacked on #36. Levels 1–3 inline. Level 4: general lane (`/code-review high`) and a UI specialist lane (colour parity incl. trait coverage, token users, public API, catalog validity, docs). Verifier: no finding of major or higher; parity facts checked against the colorset JSON and the removed code.🤖 Reviewed with Claude Code
…y are
Follow-up to the review of this PR:
- each call's literal names are read once, so a ternary in the host
bundle or a repeated missing name is reported once;
- a .custom(…) that passes a bundle is a lookup wherever it sits, and a
computed name in .main / nil / .none is reported;
- an empty name also gets its bundle checked;
- negative needles ("!text") are checked in pass cases too;
- CLAUDE.md, docs/foundation.md and the script header say what the scan
does and does not follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow-up to the review of this PR: the header no longer claims every token is a colorset (rule 5 only sees colors built from components), the violation message says to add a colorset and a token, and a comment is re-wrapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
romchornyi-pitcrew
left a comment
There was a problem hiding this comment.
✅ no blockers · no majors · 2 non-blocking recommendations — reviewed at 5a8317683b
| Level | Verdict | |
|---|---|---|
| 1 · Idea | ✅ valid | Unchanged since the last review |
| 2 · Architecture | ✅ right layer | Unchanged |
| 3 · Completeness | ✅ complete | Unchanged: one user, both docs updated |
| 4 · Code | ✅ clean | 5a83176 changes only messages and comments. The rest of the new diff is the merge of #36's 3171eed |
Closed since the last review (bot review on 962cca5)
- The rule 5 header now says what it covers in
Color+DashUI.swift: tokens read from colorsets withdashAsset("Name"). It no longer claims "every token is a colorset".DashUIKit/.github/scripts/conventions.sh
Lines 20 to 22 in 5a83176
- The rule 5 message works inside
Color+DashUI.swifttoo ("add a colorset and a token for it … (dashAsset("Name"))").andDashUIKit/.github/scripts/conventions.sh
Line 239 in 5a83176
DashUIKit/.github/scripts/conventions.sh
Line 248 in 5a83176
- The ragged comment wrap is fixed.
DashUIKit/.github/scripts/conventions.sh
Lines 195 to 200 in 5a83176
2 non-blocking recommendations
- Doc comment restates catalog values — https://github.com/dashpay/DashUIKit/blob/5a8317683b751332f10d6008e4dd0a899766c786/Sources/DashUIKit/Foundation/Color+DashUI.swift — the
shadowdoc comment still repeats the colorset's sRGB values. No other token does this, and the comment goes stale if the colorset changes. (open from the last review) - The merged #36 script change carries its own open points — the false
no imageset named "…"for a literal in a ternary's condition, and the per-line duplicates. They are listed on #36 (review 5665698584) and are not repeated here, because they belong to that PR.
Review details
Re-review of the bot review on 962cca5. The new diff is 5a83176 (messages and comments) plus a merge of #36 3171eed, which the bot reviewed on #36 an hour earlier, general lane included. Following the re-review rule, only the touched level was re-checked: level 4, inline, against the diff. No lane was re-run for message-only changes. Two items stay unaddressed and are not repeated, as they were non-blocking: the macOS light-appearance wording in the description, and the doc comment (kept as item 1).
When this review was written, Conventions and both builds were green. Public API, Lint CI config, Before / After screenshots and Validate PR title were still pending.
🤖 Reviewed with Claude Code
…orset # Conflicts: # .github/scripts/conventions.sh # .github/scripts/tests/conventions-test.sh
Issue being fixed or feature implemented
Every
Color.dashtoken is a colorset with light and dark variants, exceptshadow. That token was built in code asUIColor(red: 0.72, green: 0.76, blue: 0.8, alpha: 0.1), wrapped in a trait switch that returns.clearin dark mode. Because of it,conventions.shrule 5 ("no colors built from components") exempted all ofColor+DashUI.swift, so any other color built from components in that file would also have passed.Stacked on #36 (both change
conventions.sh). Once #36 merges, this PR's base becomesmaster.What was done?
Shadow.colorset(Colors/Shadow/): light is sRGB 0.72 / 0.76 / 0.80 at alpha 0.10, dark is fully transparent.Color.dash.shadowis nowdashAsset("Shadow"); its public name and type do not change.Color+DashUI.swiftno longer builds colors in code or imports UIKit.conventions.sh:Color+DashUI.swift.tokens/tokens_fileto say so.Color(red:…)appended to the file fails, at that line.foundation.mdandnavigation-and-containers.mddescribe the token as theShadowcolorset.swift buildand previews, now gets the light shadow in light appearance, where it used to get.clear. Dark appearance stays clear.How Has This Been Tested?
swift build(macOS), the iOS Release device build, andxcodebuild teston the iOS 27 simulator: 18 tests, 0 failures.conventions.shpasses (161 imagesets, 162 colorsets). On the tree before this change, the updated script reports exactly the oldUIColor(red:).tests/conventions-test.shpasses all cases, and shellcheck is clean.api-check.shagainst refactor: route asset names through DashIcon #36's head reports no breaking changes.MenuViewModifier, the only user of the token, was rendered on the iOS simulator in light and dark with a test harness, before and after this change. The PNGs are byte-identical: the 10 % shadow in light, nothing in dark.Before / After
On iOS the same color now comes from the asset catalog. The before and after renders of
MenuViewModifierare byte-identical in light and dark (see "How Has This Been Tested?").Breaking Changes
None.
Checklist:
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Shadowasset across supported platforms, replacing platform-specific behavior.Documentation
Tests