Skip to content

Commit

Permalink
Add: Entry introduce top level app dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rdig committed Jan 22, 2025
1 parent 690b86f commit e03ed93
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
mergeNetworks,
} from '@dynamic-labs/sdk-react-core';
import { PostHogProvider } from 'posthog-js/react';
import React from 'react';
import React, { useEffect, useState } from 'react';
import { HelmetProvider } from 'react-helmet-async';
import { IntlProvider } from 'react-intl';
import { Provider as ReduxProvider } from 'react-redux';
Expand Down Expand Up @@ -43,10 +43,25 @@ if (__COMMIT_HASH__) {

const Entry = ({ store }: Props) => {
const apolloClient = getContext(ContextModule.ApolloClient);
const [isDarkMode, setIsDarkMode] = useState(
localStorage.getItem('isDarkMode') === 'true' || false,
);

useEffect(() => {
function checkAppTheme() {
setIsDarkMode(localStorage.getItem('isDarkMode') === 'true');
}
window.addEventListener('storage', checkAppTheme);

return () => {
window.removeEventListener('storage', checkAppTheme);
};
}, []);

return (
<DynamicContextProvider
mobileExperience="redirect"

Check failure on line 63 in src/Entry.tsx

View workflow job for this annotation

GitHub Actions / build

Type '{ children: Element; mobileExperience: string; theme: "light" | "dark"; logLevel: string; settings: { environmentId: string; walletConnectors: ((props: any) => WalletConnectorConstructor[])[]; initialAuthenticationMode: "connect-only"; enableVisitTrackingOnConnectOnly: false; recommendedWallets: { ...; }[]; override...' is not assignable to type 'IntrinsicAttributes & DynamicContextProps'.
theme={isDarkMode ? 'dark' : 'light'}
logLevel={import.meta.env.DEV ? 'warn' : 'error'}
settings={{
environmentId: import.meta.env.DYNAMIC_ENV_ID,
Expand Down

0 comments on commit e03ed93

Please sign in to comment.