I have a template that has config.js file which loads theme configs I want to add toggle switch from Light mode to Dark mode. Theme changes when you make changes in config.js but I don't know how to change values in config.js dynamically.
I'm Planning to have a toggle in the index file.
config.js
export default {
defaultPath: '/dashboard/default',
basename: '',
layout: 'vertical',
preLayout: '',
collapseMenu: false,
layoutType: 'dark', // menu-light
navIconColor: true,
headerBackColor: 'header-default', // header-dark
navBackColor: 'navbar-dark', // navbar-dark
navBrandColor: 'brand-dark', // brand-dark
navBackImage: false,
rtlLayout: false,
navFixedLayout: true,
headerFixedLayout: false,
boxLayout: false,
navDropdownIcon: 'style1',
navListIcon: 'style1',
navActiveListColor: 'active-*', // active-dark
navListTitleColor: 'title-default', // title-dark
navListTitleHide: false,
configBlock: false,
layout6Background : 'linear-gradient(to right, #A445B2 0%, #D41872 52%, #FF0066 100%)',
layout6BackSize : '',
};
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import { createStore } from 'redux';
import {Provider} from 'react-redux';
import {BrowserRouter} from 'react-router-dom';
import App from './App/index';
import * as serviceWorker from './serviceWorker';
import reducer from './store/reducer';
import config from './config';
const store = createStore(reducer);
const app = (
<Provider store={store}>
<BrowserRouter basename={config.basename}>
{/* basename="/datta-able" */}
<App />
</BrowserRouter>
</Provider>
);
ReactDOM.render(app, document.getElementById('root'));