Skip to content
Open
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
13 changes: 13 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { AppProps } from "next/app";
import { useRouter } from "next/router";
import Script from "next/script";
import { ThemeProvider } from "next-themes";
import { useEffect } from "react";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import tw from "twin.macro";

Expand All @@ -28,6 +29,18 @@ const NextApp = ({ Component, pageProps }: AppProps) => {
const client = useApollo(pageProps);
const router = useRouter();

// Add a page class to the body. Useful for things like hiding the ZE chat widget on the Share page
useEffect(() => {
const pathName = router.pathname.replaceAll("/", "");
// add class to body element
document.body.classList.add(`page-${pathName}`);

// clean-up
return () => {
document.body.classList.remove(`page-${pathName}`);
};
}, []);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add [router.asPath] as a dependency here so it updates as routes change? Also, we'll need to remove the old path class before doing this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Thanks. Cleaning up the last effect (ie. lines 39–41) should remove that old path class.

Doing Monday.


// Datadog RUM initialization
datadogRum.init({
applicationId: process.env.NEXT_PUBLIC_DATADOG_APP_ID as string,
Expand Down
5 changes: 5 additions & 0 deletions src/styles/GlobalStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ const stylesBase = css`
iframe[title="Message from company"] {
color-scheme: auto;
}
/* Hide ZenDesk widget on the Share page */
.page-share iframe[title="Message from company"],
.page-share iframe[title="Button to launch messaging window"] {
display: none;
}
`;

const GlobalStyles = () => (
Expand Down