Skip to content
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

Possible to have different primary color for dark mode? #160

Closed
benbrandt opened this issue Mar 29, 2022 · 3 comments
Closed

Possible to have different primary color for dark mode? #160

benbrandt opened this issue Mar 29, 2022 · 3 comments
Labels
enhancement New feature or request help wanted PRs are encouraged and will be accepted

Comments

@benbrandt
Copy link
Contributor

For our colors, it is helpful to swap out the primary color in dark mode. Would it be possible to have this as an optional parameter in the theme? And if not present, it defaults to the primary color?

I am happy to open a PR myself, but wanted to make sure this was desired before I did so.

@benbrandt
Copy link
Contributor Author

This was the most minimal patch-package change I could do:

diff --git a/node_modules/docusaurus-theme-redoc/dist/redocData.js b/node_modules/docusaurus-theme-redoc/dist/redocData.js
index 5efafe0..21d62ba 100644
--- a/node_modules/docusaurus-theme-redoc/dist/redocData.js
+++ b/node_modules/docusaurus-theme-redoc/dist/redocData.js
@@ -117,9 +117,12 @@ function getRedocThemes(customTheme) {
     };
 }
 exports.getRedocThemes = getRedocThemes;
-function getGlobalData({ primaryColor, theme: customTheme, options, }) {
-    const overrides = getDefaultTheme(primaryColor, customTheme);
-    const { lightTheme, darkTheme } = getRedocThemes(overrides);
+function getGlobalData({ primaryColor, darkPrimaryColor = primaryColor, theme: customTheme, options, }) {
+    const lightThemeOverrides = getDefaultTheme(primaryColor, customTheme);
+    const darkThemeOverrides = getDefaultTheme(darkPrimaryColor, customTheme);
+    const lightTheme = getThemeOptions(lightThemeOverrides, false);
+    const darkTheme = getThemeOptions(darkThemeOverrides, true);
+
     return {
         lightTheme,
         darkTheme,

I think there is a more elegant way to handle this. But it works for me for now, and with patch-package I try and keep the line changes minimal.

@rohit-gohri rohit-gohri added the enhancement New feature or request label Mar 29, 2022
@rohit-gohri
Copy link
Owner

This seems reasonable. Feel free to open a PR

@rohit-gohri rohit-gohri added the help wanted PRs are encouraged and will be accepted label Apr 5, 2022
@benbrandt
Copy link
Contributor Author

This seems reasonable. Feel free to open a PR

Apologies for the delay. Went on parental leave and finally got around to it after coming back. Here's the PR: #216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted PRs are encouraged and will be accepted
Projects
None yet
Development

No branches or pull requests

2 participants