Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/DevDocTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ const DevDocTemplate: FC<DevDocTemplateProps> = (props) => {
if (typeof window === 'undefined') return false;
// In-product (embedded) presentation always uses light mode — product UI has no theme toggle.
if (!isPublicSite(location.search)) return false;
// URL param takes highest priority (set by embedding product to pass its theme).
const urlParams = new URLSearchParams(window.location.search);
const darkModeParam = urlParams.get('isDarkMode');
if (darkModeParam !== null) {
const isDark = darkModeParam === 'true';
localStorage.setItem('themeMode', isDark ? 'dark' : 'light');
return isDark;
}
/* themeMode is only written when the user explicitly clicks the toggle.
If absent, follow OS preference fresh every load. */
const explicitChoice = localStorage.getItem('themeMode');
Expand Down Expand Up @@ -265,6 +273,7 @@ const isVersionedIframe = VERSION_DROPDOWN.some(
const newDarkMode = darkModeParam === 'true';
setDarkMode(newDarkMode);
localStorage.setItem('theme', newDarkMode ? 'dark' : 'light');
localStorage.setItem('themeMode', newDarkMode ? 'dark' : 'light');
}
}
}, [location.search]);
Expand Down
Loading