diff --git a/assets/js/theme.js b/assets/js/theme.js deleted file mode 100644 index 5d7ad30a..00000000 --- a/assets/js/theme.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Theme setting - */ - -function setThemeCookie() { - if (window.matchMedia('(prefers-color-scheme: dark)').matches) { - document.cookie = `theme=dark; path=/; max-age=788923800; samesite=lax`; - } else { - document.cookie = `theme=light; path=/; max-age=788923800; samesite=lax`; - } -} - -export { setThemeCookie }; diff --git a/assets/js/when-ready.js b/assets/js/when-ready.js index 6bec6a1f..4f52a875 100644 --- a/assets/js/when-ready.js +++ b/assets/js/when-ready.js @@ -32,7 +32,6 @@ import { setupTimestamps } from './timeago'; import { setupImageUpload } from './upload'; import { setupSearch } from './search'; import { setupToolbar } from './textiletoolbar'; -import { setThemeCookie } from './theme'; import { hideStaffTools } from './staffhider'; import { pollOptionCreator } from './poll'; @@ -64,8 +63,7 @@ whenReady(() => { setupTimestamps(); setupImageUpload(); setupSearch(); - setupToolbar() - setThemeCookie(); + setupToolbar(); hideStaffTools(); pollOptionCreator(); diff --git a/lib/philomena_web/views/layout_view.ex b/lib/philomena_web/views/layout_view.ex index 810028d6..aec16af8 100644 --- a/lib/philomena_web/views/layout_view.ex +++ b/lib/philomena_web/views/layout_view.ex @@ -64,24 +64,14 @@ defmodule PhilomenaWeb.LayoutView do Config.get(:footer) end - def stylesheet_path(conn, %{theme: "default"}), - do: Routes.static_path(conn, "/css/default.css") - def stylesheet_path(conn, %{theme: "dark"}), do: Routes.static_path(conn, "/css/dark.css") def stylesheet_path(conn, %{theme: "red"}), do: Routes.static_path(conn, "/css/red.css") - def stylesheet_path(conn, _user) do - case conn.cookies do - %{"theme" => "dark"} -> - Routes.static_path(conn, "/css/dark.css") - - _ -> - Routes.static_path(conn, "/css/default.css") - end - end + def stylesheet_path(conn, _user), + do: Routes.static_path(conn, "/css/default.css") def theme_name(%{theme: theme}), do: theme def theme_name(_user), do: "default"