fix(docs): Fix light mode text visibility in custom CSS#332
fix(docs): Fix light mode text visibility in custom CSS#332Sridhar1030 wants to merge 3 commits intokubeflow:mainfrom
Conversation
Furo sets data-theme on body, not :root. Custom CSS used :root:not([data-theme="light"]) so dark overrides always applied. Switched to body-based selectors and added explicit body[data-theme="light"] block for correct light-mode colors. Fixes kubeflow#331 Signed-off-by: Sridhar1030 <sridharpillai75@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
This PR fixes a light mode text visibility bug in the documentation where text appeared almost invisible (light grey on white background) when users switched to Light mode using the Furo theme switcher. The root cause was that the custom CSS was checking for data-theme on :root when Furo actually sets it on the body element, causing dark mode color variables to always apply.
Changes:
- Updated CSS selectors from
:root-based tobody-based to correctly detect Furo theme - Added explicit
body[data-theme="light"]block to ensure proper light mode colors when user selects Light theme - Updated comment to clarify that Furo sets data-theme on body, not :root
Comments suppressed due to low confidence (1)
docs/source/_static/custom.css:73
- The
--kf-accentvariable is missing from this dark mode block (it's defined in:rootat line 21). For consistency and maintainability, all CSS custom properties should be explicitly defined in each theme block. The dark mode might benefit from a different accent color, or it should explicitly set the same value for clarity.
body[data-theme="dark"] {
--kf-blue: #63b3ed;
--kf-blue-light: #90cdf4;
--kf-blue-dark: #4299e1;
--kf-heading: #e2e8f0;
--kf-text: #cbd5e0;
--kf-text-light: #a0aec0;
--kf-bg-subtle: #2d3748;
--kf-border: #4a5568;
--kf-api-name: #63b3ed;
--kf-api-param: #a0aec0;
--kf-api-text: #e2e8f0;
}
| @@ -43,7 +43,22 @@ | |||
| } | |||
There was a problem hiding this comment.
The --kf-accent variable is missing from this media query dark mode block (it's defined in :root at line 21). For consistency and maintainability, all CSS custom properties should be explicitly defined in each theme block.
docs/source/_static/custom.css
Outdated
| /* Explicit light mode - ensure light vars when user selects Light */ | ||
| body[data-theme="light"] { | ||
| --kf-blue: #4299e1; | ||
| --kf-blue-light: #63b3ed; | ||
| --kf-blue-dark: #3182ce; | ||
| --kf-heading: #2d3748; | ||
| --kf-text: #4a5568; | ||
| --kf-text-light: #718096; | ||
| --kf-bg-subtle: #f7fafc; | ||
| --kf-border: #e2e8f0; | ||
| --kf-accent: #81e6d9; | ||
| --kf-api-name: #3182ce; | ||
| --kf-api-param: #4a5568; | ||
| --kf-api-text: #000; | ||
| } | ||
|
|
There was a problem hiding this comment.
The body[data-theme="light"] block duplicates the exact same variable values already defined in :root, which increases the chance the light palette drifts out of sync over time; consider removing this block or limiting it to only the variables that truly need to differ from the :root defaults.
| /* Explicit light mode - ensure light vars when user selects Light */ | |
| body[data-theme="light"] { | |
| --kf-blue: #4299e1; | |
| --kf-blue-light: #63b3ed; | |
| --kf-blue-dark: #3182ce; | |
| --kf-heading: #2d3748; | |
| --kf-text: #4a5568; | |
| --kf-text-light: #718096; | |
| --kf-bg-subtle: #f7fafc; | |
| --kf-border: #e2e8f0; | |
| --kf-accent: #81e6d9; | |
| --kf-api-name: #3182ce; | |
| --kf-api-param: #4a5568; | |
| --kf-api-text: #000; | |
| } |
| @@ -52,6 +69,7 @@ | |||
| --kf-text-light: #a0aec0; | |||
| --kf-bg-subtle: #2d3748; | |||
| --kf-border: #4a5568; | |||
| --kf-accent: #81e6d9; | |||
| --kf-api-name: #63b3ed; | |||
| --kf-api-param: #a0aec0; | |||
| --kf-api-text: #e2e8f0; | |||
There was a problem hiding this comment.
The dark palette variables are defined twice (once in the @media (prefers-color-scheme: dark) block and again in body[data-theme="dark"]), which creates a maintenance hazard if one set of values is updated without the other; consider factoring the shared dark values so there is a single source of truth (e.g., alias variables or a shared selector strategy).
… comments Remove duplicate body[data-theme="light"] block since :root values are inherited when the media-query selector stops matching. Add explanatory comment documenting why two dark blocks are needed (system-dark auto vs explicit dark selection). Signed-off-by: Sridhar1030 <sridharpillai75@gmail.com>
|
/assign @kramaranya |
Summary
:root:not([data-theme="light"])for dark overrides, but Furo setsdata-themeonbody, not:root— so dark variable overrides always applied even in Light modebody-based selectors and added explicitbody[data-theme="light"]block for correct light-mode colorsBefore
Fixes #331
After
Test plan
make docsormake docs-serve