In my root component, RootApp.jsx handles the component tree:
import { Suspense } from 'react';
import { HashRouter as Router } from 'react-router-dom';
import { Provider } from 'react-redux';
import store from '@/redux/store';
import PageLoader from '@/components/PageLoader';
import '@/style/app.css';
import '@/style/index.css';
import '@/style/tailwind.css'
import ERP_SODEOs from '@/apps/IdurarOs';
import { ThemeProvider } from '@/context/ThemeContext/ThemeContext'; // Import ThemeProvider
export default function RoutApp() {
return (
<Router>
<Provider store={store}>
<ThemeProvider>
<Suspense fallback={<PageLoader />}>
<ERP_SODEOs />
</Suspense>
</ThemeProvider>
</Provider>
</Router>
);
}
Within <ERP_SODEOs>, there are multiple components. The main component handling the child components is ErpApp.jsx:
return (
<Layout hasSider>
<Navigation onPathChange={handlePathChange} />
{isMobile ? (
<Layout style={{ marginLeft: 0 }}>
<HeaderContent />
<Content
style={{
margin: '40px auto 30px',
overflow: 'initial',
width: '100%',
padding: '0 25px',
maxWidth: 'none',
}}
>
<AppRouter />
</Content>
</Layout>
) : (
<Layout style={{ marginLeft: isNavMenuClose ? 100 : 220 }}>
<HeaderContent currentPath={currentPath} />
<Content
style={{
margin: '30px auto 30px',
overflow: 'initial',
width: '100%',
padding: '0px 10px 0px 0px',
maxWidth: isNavMenuClose ? 1700 : 1600,
}}
>
<AppRouter />
</Content>
</Layout>
)}
</Layout>
);
}
I am attempting to implement dark mode inside my HeaderContent.jsx using a custom CSS file imported globally. However, this implementation is not working as expected.
The dropdown button in HeaderContent allows users to change the theme of the application. When the user selects the "Dark" option, the header color should change. I have also created a context that can be used in other components. Additionally, I have updated the tsconfig file with darkMode: 'class'.