diff --git a/assets/js/app.js b/assets/js/app.js index acd0e4d4c..3e344c2aa 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,5 +1,4 @@ import "./polyfills/closest" -import "./apply-theme" import 'abortcontroller-polyfill/dist/polyfill-patch-fetch' import Alpine from 'alpinejs' import "./liveview/live_socket" diff --git a/assets/js/apply-theme.js b/assets/js/apply-theme.js deleted file mode 100644 index f715f5580..000000000 --- a/assets/js/apply-theme.js +++ /dev/null @@ -1,37 +0,0 @@ -var pref = document.currentScript.dataset.pref; - -function reapplyTheme() { - var userPref = pref || "system"; - var mediaPref = window.matchMedia('(prefers-color-scheme: dark)').matches; - var htmlRef = document.querySelector('html'); - var hcaptchaRefs = document.getElementsByClassName('h-captcha'); - - htmlRef.classList.remove('dark'); - for (let i = 0; i < hcaptchaRefs.length; i++) { - hcaptchaRefs[i].dataset.theme = "light"; - } - - switch (userPref) { - case "dark": - htmlRef.classList.add('dark'); - for (let i = 0; i < hcaptchaRefs.length; i++) { - hcaptchaRefs[i].dataset.theme = "dark"; - } - break; - case "system": - if (mediaPref) { - htmlRef.classList.add('dark'); - for (let i = 0; i < hcaptchaRefs.length; i++) { - hcaptchaRefs[i].dataset.theme = "dark"; - } - } - break; - } -} - -reapplyTheme(); -window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', reapplyTheme); - -window.onload = function() { - reapplyTheme(); -}; diff --git a/lib/plausible_web/components/layout.ex b/lib/plausible_web/components/layout.ex new file mode 100644 index 000000000..48b1e84de --- /dev/null +++ b/lib/plausible_web/components/layout.ex @@ -0,0 +1,36 @@ +defmodule PlausibleWeb.Components.Layout do + @moduledoc false + + use Phoenix.Component + + def theme_script(assigns) do + ~H""" + + """ + end + + defp current_theme(nil), do: "system" + defp current_theme(user), do: user.theme +end diff --git a/lib/plausible_web/templates/layout/app.html.eex b/lib/plausible_web/templates/layout/app.html.eex deleted file mode 100644 index 81c5bc9ec..000000000 --- a/lib/plausible_web/templates/layout/app.html.eex +++ /dev/null @@ -1,40 +0,0 @@ - - -
- - - - - <%= if @conn.assigns[:connect_live_socket] do %> - - - <% end %> - - "> - -- © <%= DateTime.utc_now().year() %> Plausible Analytics. All rights reserved. -
- - - - diff --git a/lib/plausible_web/templates/layout/focus.html.heex b/lib/plausible_web/templates/layout/focus.html.heex new file mode 100644 index 000000000..16f90460a --- /dev/null +++ b/lib/plausible_web/templates/layout/focus.html.heex @@ -0,0 +1,58 @@ + + + + + + + + + <%= if assigns[:connect_live_socket] do %> + + + <% end %> + ++ © <%= DateTime.utc_now().year() %> Plausible Analytics. All rights reserved. +
+ +