-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement live colour palette previews #50
Comments
On a related note, how hard would it be to implement a theme-switching button for this template (aka light/dark mode)? |
A very bare bones solution for the example site could be to add the following HTML and JS <select id="theme-selector">
<option value="base16-light">Base16 Light</option>
<option value="base16-dark">Base16 Dark</option>
<option value="gruvbox-dark">Gruvbox Dark</option>
<option value="gruvbox-light">Gruvbox Light</option>
...
</select> const themeLinkEl = document.querySelector(`link[href^='https://risotto.joeroe.io/css/palettes']`)
document.getElementById('theme-selector').addEventListener('change', e =>
themeLinkEl.href = `https://risotto.joeroe.io/css/palettes/${e.target.value}.css`
) I tried doing this in the devtools and we just need to change the For a light/dark theme switch just change the <link rel="stylesheet" href="default.css">
<link rel="stylesheet" href="light.css" media="(prefers-color-scheme: light)">
<link rel="stylesheet" href="dark.css" media="(prefers-color-scheme: dark)"> (the link tag with the media query prevents the initial flickering and should even work with JS disabled) |
They're just CSS files, so should be possible to switch them without rebuilding the site. Maybe just on the example site, to avoid any JS dependencies.
The text was updated successfully, but these errors were encountered: