Files
fizzy/app/views/layouts/_theme_preference.html.erb
Kevin McConnell 87ad234f32 Apply theme preference before body
To avoid any visual flashes of the old theme before the Stimulus
controllers load, we can apply the saved theme from `<head>` whenever
there is a full page load.

This applies to both the regular and public views, as we're doing it in
the shared head partial.
2025-12-12 14:17:58 +00:00

7 lines
183 B
Plaintext

<%= javascript_tag nonce: true do %>
const theme = localStorage.getItem("theme")
if (theme && theme !== "auto") {
document.documentElement.dataset.theme = theme
}
<% end %>