Fix light mode secondary/tertiary colors rendering as white (#854)#878
Merged
twostraws merged 1 commit intotwostraws:mainfrom Apr 24, 2026
Conversation
…s#854) The default `secondary` and `tertiary` colors used `opacity: 0.75` and `opacity: 0.5` (both `Double`s), which caused Swift to prefer the `Color(red: Double, green: Double, blue: Double, opacity: Double)` initializer over the intended `Color(red: Int, green: Int, blue: Int, opacity: Percentage)` one. The `Double` init treats its RGB arguments as 0–1 floats and multiplies by 255, so values like `Color(red: 33, green: 37, blue: 41, opacity: 0.75)` produced `rgb(8415 9435 10455)` in the generated CSS. Browsers clamp each channel to 255, so the text rendered as pure white — invisible on a light background. Using `75%` / `50%` (a `Percentage`) makes the integer RGB initializer the unambiguous match, so the channels are preserved as-is. Adds regression tests covering secondary and tertiary for both default themes.
Owner
|
Thank you! |
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.
Fixes #854.
Summary
.foregroundStyle(.secondary)(and.tertiary) rendered as pure white in light mode, making text invisible on the default white background. The root cause is an initializer-overload mismatch inTheme-DefaultImplementation.swift:0.75is aDouble, not aPercentage, so Swift picks theDoubleRGB initializer that treats each channel as a 0–1 float and multiplies by 255:The emitted CSS for
--bs-secondarybecomesrgb(8415 9435 10455 / 75%). Browsers clamp each channel to255, so the color resolves to white (reported in the issue as "50 000+" channel values — same bug, seen through the devtools rounding).Dark mode happened to look OK because white text on a dark background is still readable (it just wasn't the intended 75%-opacity light grey).
Fix
Switch the four affected call sites from
Doubleopacities toPercentage:75%/50%produce aPercentage, which is the only type that matches the integer-RGB initializer'sopacity:parameter. The channels stay33/37/41and222/226/230, matching the inline-comment intent (Bootstrap's standard light/dark text colors).This touches only
Theme-DefaultImplementation.swift— the defaultsecondaryandtertiaryBootstrap color variables. Custom themes that overridesecondary/tertiaryare unaffected. No behavior change in dark mode beyond finally hitting the intended 75%/50% opacity values instead of white.Test plan
Tests/IgniteTesting/Themes/ThemeDefaultColors.swiftthat assertDefaultLightTheme().secondary/DefaultDarkTheme().secondary/.tertiaryresolve to the expected RGB + opacity values. The tests fail onmain(e.g.color.red → 8415) and pass with this change.swift test— all 1124 tests pass.swiftlint lint— no issues on touched files.swift build— clean.🤖 Generated with Claude Code