mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
Revert "automatically apply system-wide theme preference for anonymous users (fixes philomena-dev/philomena#36)"
This reverts commit edcd4ebfde
.
This commit is contained in:
parent
edcd4ebfde
commit
5c51775f94
3 changed files with 3 additions and 28 deletions
|
@ -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 };
|
|
|
@ -32,7 +32,6 @@ import { setupTimestamps } from './timeago';
|
||||||
import { setupImageUpload } from './upload';
|
import { setupImageUpload } from './upload';
|
||||||
import { setupSearch } from './search';
|
import { setupSearch } from './search';
|
||||||
import { setupToolbar } from './textiletoolbar';
|
import { setupToolbar } from './textiletoolbar';
|
||||||
import { setThemeCookie } from './theme';
|
|
||||||
import { hideStaffTools } from './staffhider';
|
import { hideStaffTools } from './staffhider';
|
||||||
import { pollOptionCreator } from './poll';
|
import { pollOptionCreator } from './poll';
|
||||||
|
|
||||||
|
@ -64,8 +63,7 @@ whenReady(() => {
|
||||||
setupTimestamps();
|
setupTimestamps();
|
||||||
setupImageUpload();
|
setupImageUpload();
|
||||||
setupSearch();
|
setupSearch();
|
||||||
setupToolbar()
|
setupToolbar();
|
||||||
setThemeCookie();
|
|
||||||
hideStaffTools();
|
hideStaffTools();
|
||||||
pollOptionCreator();
|
pollOptionCreator();
|
||||||
|
|
||||||
|
|
|
@ -64,24 +64,14 @@ defmodule PhilomenaWeb.LayoutView do
|
||||||
Config.get(:footer)
|
Config.get(:footer)
|
||||||
end
|
end
|
||||||
|
|
||||||
def stylesheet_path(conn, %{theme: "default"}),
|
|
||||||
do: Routes.static_path(conn, "/css/default.css")
|
|
||||||
|
|
||||||
def stylesheet_path(conn, %{theme: "dark"}),
|
def stylesheet_path(conn, %{theme: "dark"}),
|
||||||
do: Routes.static_path(conn, "/css/dark.css")
|
do: Routes.static_path(conn, "/css/dark.css")
|
||||||
|
|
||||||
def stylesheet_path(conn, %{theme: "red"}),
|
def stylesheet_path(conn, %{theme: "red"}),
|
||||||
do: Routes.static_path(conn, "/css/red.css")
|
do: Routes.static_path(conn, "/css/red.css")
|
||||||
|
|
||||||
def stylesheet_path(conn, _user) do
|
def stylesheet_path(conn, _user),
|
||||||
case conn.cookies do
|
do: Routes.static_path(conn, "/css/default.css")
|
||||||
%{"theme" => "dark"} ->
|
|
||||||
Routes.static_path(conn, "/css/dark.css")
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
Routes.static_path(conn, "/css/default.css")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def theme_name(%{theme: theme}), do: theme
|
def theme_name(%{theme: theme}), do: theme
|
||||||
def theme_name(_user), do: "default"
|
def theme_name(_user), do: "default"
|
||||||
|
|
Loading…
Reference in a new issue