Check out the demo and swap between Light & Dark themes.
- Clone the repository
- Go to the project directory -
cd ./Switcher
- Start the project -
npm start
By default, the light theme will be used. Its JSON config containing all its variables is found under src/variables/lightTheme.json
.
The dark theme config (src/variables/darkTheme.json
) contains a map of the same keys, just with the values we want to use when the theme switches.
Switcher.js (src/Switcher.js
) handles the logic behind theme switching. It simply sets picks up all values from the theme configs and adds custom CSS4 variables for each one in the :root
of the document.
By default, the demo loads the light theme on load:
Switcher.setTheme('light');
The Switcher package comes prepared for you to build and deploy your changes to Netlify. Parcel will build the app for production and deploy using your Netlify config - run npm run deploy
.
Found any issues with Switcher? Post an issue or PR π
Licensed under MIT