Skip to content

Commit

Permalink
fix testnet. for some reason nested theme was not contained. conditio…
Browse files Browse the repository at this point in the history
…nal CssBaseline fixes it??
  • Loading branch information
lukaw3d committed Mar 12, 2024
1 parent 9a46cd2 commit 487af40
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/app/components/AnalyticsConsent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useScreenSize } from 'app/hooks/useScreensize'
import * as matomo from './initializeMatomo'
import { legalDocuments } from '../../utils/externalLinks'
import { ThemeByNetwork } from '../ThemeByNetwork'
import { Network } from '../../../types/network'

const AnalyticsContext = createContext<{
reopenAnalyticsConsent: () => void
Expand Down Expand Up @@ -65,7 +66,7 @@ export const AnalyticsConsentProvider = (props: { children: React.ReactNode }) =
<AnalyticsContext.Provider value={{ reopenAnalyticsConsent: () => setHasAccepted('not-chosen') }}>
{props.children}
{/* Theme is needed because AnalyticsConsentProvider is outside network-themed routes */}
<ThemeByNetwork network="mainnet">
<ThemeByNetwork isRootTheme={false} network={Network.mainnet}>
<AnalyticsConsentView
isOpen={hasAccepted === 'not-chosen'}
onAccept={async () => {
Expand Down
10 changes: 7 additions & 3 deletions src/app/components/ThemeByNetwork/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ import { getThemesForNetworks } from '../../../styles/theme'
import CssBaseline from '@mui/material/CssBaseline'
import { fixedNetwork } from '../../utils/route-utils'

export const ThemeByNetwork: FC<{ network: Network; children: React.ReactNode }> = ({
export const ThemeByNetwork: FC<{ network: Network; isRootTheme: boolean; children: React.ReactNode }> = ({
network,
isRootTheme,
children,
}) => (
<ThemeProvider theme={getThemesForNetworks()[network]}>
<CssBaseline />
{isRootTheme && <CssBaseline />}
{children}
</ThemeProvider>
)

export const withDefaultTheme = (node: ReactNode, alwaysMainnet = false) => (
<ThemeByNetwork network={alwaysMainnet ? Network.mainnet : fixedNetwork ?? Network.mainnet}>
<ThemeByNetwork
isRootTheme={true}
network={alwaysMainnet ? Network.mainnet : fixedNetwork ?? Network.mainnet}
>
{node}
</ThemeByNetwork>
)
2 changes: 1 addition & 1 deletion src/app/pages/HomePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const HomePage: FC = () => {
</InfoScreenBtn>
)}
</SearchInputContainer>
<ThemeByNetwork network={network}>
<ThemeByNetwork isRootTheme={false} network={network}>
<Box sx={{ zIndex: zIndexHomePage.paraTimeSelector }}>
<ParaTimeSelector
step={step}
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/RoutingErrorPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Network } from '../../../types/network'
export const RoutingErrorPage: FC = () => {
const scope = useScopeParam()
return (
<ThemeByNetwork network={scope?.network ?? Network.mainnet}>
<ThemeByNetwork isRootTheme={true} network={scope?.network ?? Network.mainnet}>
<PageLayout>
<Divider variant="layout" />
<ErrorDisplay error={useRouteError()} />
Expand Down
2 changes: 1 addition & 1 deletion src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { FC, useEffect } from 'react'
import { AnalyticsConsentProvider } from './app/components/AnalyticsConsent'

const NetworkSpecificPart = () => (
<ThemeByNetwork network={useRequiredScopeParam().network}>
<ThemeByNetwork isRootTheme={true} network={useRequiredScopeParam().network}>
<Outlet />
</ThemeByNetwork>
)
Expand Down

0 comments on commit 487af40

Please sign in to comment.