automatically apply system-wide theme preference for anonymous users

This commit is contained in:
byte[] 2020-12-08 00:24:32 -05:00
parent 5c51775f94
commit 5b49eb0b9d
2 changed files with 5 additions and 0 deletions

View file

@ -11,6 +11,8 @@ html lang="en"
- else - else
' Derpibooru ' Derpibooru
link rel="stylesheet" href=stylesheet_path(@conn, @current_user) link rel="stylesheet" href=stylesheet_path(@conn, @current_user)
= if is_nil(@current_user) do
link rel="stylesheet" href=dark_stylesheet_path(@conn) media="(prefers-color-scheme: dark)"
link rel="icon" href="/favicon.ico" type="image/x-icon" link rel="icon" href="/favicon.ico" type="image/x-icon"
link rel="icon" href="/favicon.svg" type="image/svg+xml" link rel="icon" href="/favicon.svg" type="image/svg+xml"
meta name="generator" content="philomena" meta name="generator" content="philomena"

View file

@ -73,6 +73,9 @@ defmodule PhilomenaWeb.LayoutView do
def stylesheet_path(conn, _user), def stylesheet_path(conn, _user),
do: Routes.static_path(conn, "/css/default.css") do: Routes.static_path(conn, "/css/default.css")
def dark_stylesheet_path(conn),
do: Routes.static_path(conn, "/css/dark.css")
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"