Skip to content

Commit 3daebf4

Browse files
committed
Extend getThemeForScope function to accept layer
1 parent a8c3990 commit 3daebf4

4 files changed

Lines changed: 19 additions & 13 deletions

File tree

src/app/components/ThemeByScope/index.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { ThemeProvider } from '@mui/material/styles'
44
import { getThemeForScope } from '../../../styles/theme'
55
import CssBaseline from '@mui/material/CssBaseline'
66
import { fixedNetwork } from '../../utils/route-utils'
7+
import { Layer } from '../../../oasis-nexus/api'
78

8-
export const ThemeByScope: FC<{ network: Network; isRootTheme: boolean; children: React.ReactNode }> = ({
9-
network,
10-
isRootTheme,
11-
children,
12-
}) => (
13-
<ThemeProvider theme={getThemeForScope(network)}>
9+
export const ThemeByScope: FC<{
10+
network: Network
11+
layer?: Layer
12+
isRootTheme: boolean
13+
children: React.ReactNode
14+
}> = ({ network, layer, isRootTheme, children }) => (
15+
<ThemeProvider theme={getThemeForScope(network, layer)}>
1416
{isRootTheme && <CssBaseline />}
1517
{children}
1618
</ThemeProvider>

src/app/pages/RoutingErrorPage/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Network } from '../../../types/network'
1010
export const RoutingErrorPage: FC = () => {
1111
const scope = useScopeParam()
1212
return (
13-
<ThemeByScope isRootTheme={true} network={scope?.network ?? Network.mainnet}>
13+
<ThemeByScope isRootTheme={true} network={scope?.network ?? Network.mainnet} layer={scope?.layer}>
1414
<PageLayout>
1515
<Divider variant="layout" />
1616
<ErrorDisplay error={useRouteError()} />

src/routes.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ import { ConsensusAccountTransactionsCard } from './app/pages/ConsensusAccountDe
5959
import { FC, useEffect } from 'react'
6060
import { AnalyticsConsentProvider } from './app/components/AnalyticsConsent'
6161

62-
const ScopeSpecificPart = () => (
63-
<ThemeByScope isRootTheme={true} network={useRequiredScopeParam().network}>
64-
<Outlet />
65-
</ThemeByScope>
66-
)
62+
const ScopeSpecificPart = () => {
63+
const { network, layer } = useRequiredScopeParam()
64+
return (
65+
<ThemeByScope isRootTheme={true} network={network} layer={layer}>
66+
<Outlet />
67+
</ThemeByScope>
68+
)
69+
}
6770

6871
/**
6972
* In case of being restricted to a specific layer or layers, jump to a dashboard

src/styles/theme/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import { Network } from '../../types/network'
22
import { defaultTheme } from './defaultTheme'
33
import { testnetTheme } from './testnet/theme'
44
import type { Theme } from '@mui/material/styles/createTheme'
5+
import { Layer } from '../../oasis-nexus/api'
56

67
export { defaultTheme } from './defaultTheme'
78
export { testnetTheme } from './testnet/theme'
89

910
export const tooltipDelay = 500
1011
export const typingDelay = 1000
1112

12-
export const getThemeForScope = (network: Network): Theme => {
13+
export const getThemeForScope = (network: Network, layer?: Layer): Theme => {
1314
switch (network) {
1415
case Network.mainnet:
1516
return defaultTheme

0 commit comments

Comments
 (0)