-
-
Notifications
You must be signed in to change notification settings - Fork 4k
feat: Add dark mode support and CSS improvements #15753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add CSS custom properties for theming - Implement dark mode with prefers-color-scheme and manual toggle - Add theme toggle button in top-left corner with localStorage persistence - Improve accessibility with focus states and contrast ratios - Enhance responsive design with better breakpoints - Improve code block styling with dark mode syntax highlighting - Add print stylesheet optimizations - Improve mobile navigation styling - Enhance API navigation sidebar responsiveness
|
@vkarpov15 can you approve this please. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive dark mode support to the Mongoose documentation with a manual theme toggle, improving accessibility and user experience. The implementation uses CSS custom properties for theming, supports both system preferences and manual selection, and includes responsive design improvements across all device sizes.
Key Changes:
- Dark mode implementation with three-state theme toggle (system/dark/light) using localStorage persistence
- CSS custom properties system for consistent theming across light and dark modes
- Enhanced accessibility with improved focus states, WCAG-compliant contrast ratios, and keyboard navigation support
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
index.pug |
Added theme toggle button, mongoose5.css inclusion, and cache-busting query parameters to homepage |
docs/layout.pug |
Added theme toggle button and theme-toggle.js script to documentation layout with cache-busting |
docs/js/theme-toggle.js |
New file implementing three-state theme toggle with localStorage persistence |
docs/css/style.css |
Added dark mode support, theme toggle button styles, and enhanced code block styling for homepage |
docs/css/mongoose5.css |
Comprehensive theming system with CSS custom properties, dark mode support, responsive improvements, and print styles |
docs/css/github.css |
Added dark mode syntax highlighting colors and improved code block styling with transitions |
docs/css/api.css |
Enhanced API navigation with dark mode support, custom scrollbars, and responsive breakpoints |
docs/api_split.pug |
Added cache-busting query parameter to API CSS |
Comments suppressed due to low confidence (1)
docs/js/theme-toggle.js:29
- Unused variable theme.
const theme = document.documentElement.getAttribute('data-theme');
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hasezoey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing this, but there are many nitpicks i have:
- I basically agree with all of Copilot's points
- Isnt there some kind of option to de-duplicate
@media colorqueries anddata-themequeries? - Is
body.code-theme-darkreally necessary? - The Theme toggle button should reflect the state of "system" instead of keeping the previous button
Aside from those broad things, some issues i have noticed (they are collapsed to not spam the thread)
Issue Screenshots
Homepage
They are all dark-theme related issues:
Homepage buttons's radius somehow has white:
![]()
Github Sponsers have weird checkered line around them:

External buttons are still white:
![]()
Docs Guides (& API)
While in dark mode, the version selector is still white:
The left sidebar text is, in my opinion, way too similar to the background (especially if it has class selected), maybe boost it a bit more in the white direction?:

Docs API
Due to the right TOC bar now having a different color than the rest of the page, the text should be padded on the left side:

In any mode, it is way too blue:

For comparison, in the current live side, basically all visible blue is a red (which i think is more pleasant on the eyes) and there is a difference between code: color(red) and pre code: color(grey) (note that both do not contain any hljs classes)
Other
The system button should maybe look something along the lines of what docusaurus does:
![]()
| /* Light mode override */ | ||
| [data-theme="light"] { | ||
| --bg-primary: #ffffff; | ||
| --bg-secondary: #eee; | ||
| --bg-tertiary: #fafafa; | ||
| --text-primary: #000000; | ||
| --text-secondary: #333333; | ||
| --text-muted: #777777; | ||
| --link-color: #0971B2; | ||
| --link-hover: #065a8f; | ||
| --border-color: #ddd; | ||
| --code-bg: #f5f5f5; | ||
| --code-text: #333; | ||
| --menu-bg: #eee; | ||
| --menu-hover: rgba(0,0,0, 0.1); | ||
| --menu-selected: rgba(0,0,0, 0.15); | ||
| --shadow: rgba(0, 0, 0, 0.1); | ||
| --focus-ring: #0971B2; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this duplication (compared to the :root definition) really necessary? Wouldnt [data-theme="light"] {}(empty) just use the ones defined in :root?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the issues and late reply @hasezoey and @vkarpov15 I will try to update it as soon as possible and will also resolve all the issues and will check everything before pushing this time so that nothing would be left,
also can you assign this issue to me as I’ve been working through the related code recently, so I can address it efficiently and ensure a clean, complete fix.
| @media (prefers-color-scheme: dark) { | ||
| .search input:focus { | ||
| box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless i missed something, shouldnt this also be applied to data-theme="dark"?
Co-authored-by: Copilot <[email protected]>
Removed version query parameter from API CSS link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 16 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
vkarpov15
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow this PR had a lot of issues. I made a bunch of fixes and improvements, likely a few things I missed but should be good enough to merge and test more locally before release.


Summary
This PR adds comprehensive CSS improvements to the Mongoose documentation, including dark mode support, accessibility enhancements, and responsive design improvements. The changes improve the user experience across all devices and provide users with manual control over their preferred theme.
Motivation
The Mongoose documentation currently only supports light mode and lacks some modern accessibility features. This PR addresses:
Changes Made
prefers-color-schememedia queryExamples
Before:
After:
Files Changed
docs/css/mongoose5.css- Main documentation styles with dark mode and theme toggledocs/css/api.css- API page styles with responsive improvementsdocs/css/github.css- Syntax highlighting with dark mode supportdocs/css/style.css- Homepage styles with dark modedocs/js/theme-toggle.js- Theme toggle functionality (new file)docs/layout.pug- Added theme toggle button to documentation pagesindex.pug- Added theme toggle button and mongoose5.css to homepagedocs/api_split.pug- Added cache-busting query parametersTesting
index.pug)layout.pug)api_split.pug)Notes
npm run docs:clean)