-
Notifications
You must be signed in to change notification settings - Fork 26
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
Light and Dark Mode #38
Comments
Cool idea! Have you seen colinfay/darkmode, that's probably a good place to start (and it doesn't work out of the box with remarkjs). The other way to go is to take advantage of the fact that the slide theme is powered entirely by CSS variables. With this route, you can use the @media (prefers-color-scheme: dark) {
:root {
/* invert foreground/background colors for "dark mode" */
--text-color: #FFFFFF;
--background-color: #000000;
/* ... etc ... */
}
} This happens passively based on OS settings, so it isn't as fancy as a JavaScript implementation... but it works pretty well. I guess we'd only need a helper function for appending the media query, something like |
Oh also here's the full list of CSS variables xaringanthemer/inst/resources/template.css Lines 26 to 59 in c375a3d
|
Kind of related - do I need to use JavaScript to inject font-awesome into the head of the slide/markdown doc? I tried using htmltools::htmlDependency for it (I have the functionality almost but I want to make the button a cute icon 😊 ) |
Nope, you can throw That said... FontAwesome is a huge dependency and I highly recommend avoiding depending on the whole thing if you can. Two options: you can download the SVG for the icon you're using and then embed the SVG inline. Or you can similarly pick out the SVG for icons from other packs, like Feather or Tabler icons. Both of those projects use an MIT license. Also definitely check out mitchelloharawild/icon, it's an awesome R package that also embeds icons from FA as SVGs directly. |
Oh love that SVG idea! I'll keep working on my little reprex and if you like it we can decide if its a better fit here or GExtra :) thanks! |
Leaving this note for myself for a half baked idea that you could prob beat me to executing but let the user add a little button to the top right of their slides so the viewer can toggle between light and dark mode which would invert their color palettes (and obviously with a cute little sun icon to toggle to light and moon for dark)
The text was updated successfully, but these errors were encountered: