Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-13381-added-1770642742964.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Added
---

Light/Dark theme identifier in Cloud Manager for Pendo ([#13381](https://github.com/linode/manager/pull/13381))
15 changes: 12 additions & 3 deletions packages/manager/src/LinodeThemeWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ export const LinodeThemeWrapper = (props: Props) => {
const { children, theme: themeOverride } = props;
const { colorMode } = useColorMode();

const activeTheme = themeOverride ?? colorMode;

// Set custom data attribute on document body for third-party tools (like Pendo) to detect theme
// Pendo can use this as a selector: body[data-theme="dark"] or body[data-theme="light"]
React.useEffect(() => {
document.body.setAttribute('data-theme', activeTheme);
return () => {
document.body.removeAttribute('data-theme');
};
}, [activeTheme]);

return (
<StyledEngineProvider injectFirst>
<ThemeProvider theme={themes[themeOverride ?? colorMode]}>
{children}
</ThemeProvider>
<ThemeProvider theme={themes[activeTheme]}>{children}</ThemeProvider>
</StyledEngineProvider>
);
};