add auto theme

switches between white and dark, based on browser's theme
This commit is contained in:
bopol 2021-01-27 17:39:12 +01:00
parent 1f296ec3aa
commit 9ee2deb460
10 changed files with 19 additions and 9 deletions

View File

@ -3,7 +3,7 @@ html
head head
title about - teddit title about - teddit
include includes/head.pug include includes/head.pug
body(class=""+ user_preferences.theme +"") body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug include includes/topbar.pug
.container .container
.content .content

View File

@ -1,3 +1,5 @@
if(user_preferences.theme === 'auto')
link(rel="stylesheet", type="text/css", href="/css/dark.css", media="(prefers-color-scheme: dark)")
if(user_preferences.theme === 'dark') if(user_preferences.theme === 'dark')
link(rel="stylesheet", type="text/css", href="/css/dark.css") link(rel="stylesheet", type="text/css", href="/css/dark.css")
if(user_preferences.theme === 'sepia') if(user_preferences.theme === 'sepia')

View File

@ -3,7 +3,7 @@ html
head head
title teddit title teddit
include includes/head.pug include includes/head.pug
body(class=""+ user_preferences.theme +"") body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug include includes/topbar.pug
if json === null if json === null
h2 error h2 error

View File

@ -3,7 +3,7 @@ html
head head
title #{cleanTitle(post.title)} : #{subreddit} title #{cleanTitle(post.title)} : #{subreddit}
include includes/head.pug include includes/head.pug
body(class=""+ user_preferences.theme +"") body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug include includes/topbar.pug
if post === null if post === null
h1 Error occured h1 Error occured

View File

@ -3,7 +3,7 @@ html
head head
title preferences - teddit title preferences - teddit
include includes/head.pug include includes/head.pug
body(class=""+ user_preferences.theme +"") body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug include includes/topbar.pug
.container .container
.content .content
@ -14,17 +14,25 @@ html
label(for="theme") Theme: label(for="theme") Theme:
select(id="theme", name="theme") select(id="theme", name="theme")
if(!user_preferences.theme || user_preferences.theme == '') if(!user_preferences.theme || user_preferences.theme == '')
option(value="auto") Auto
option(value="", selected="selected") White option(value="", selected="selected") White
option(value="dark") Dark option(value="dark") Dark
option(value="sepia") Sepia option(value="sepia") Sepia
if(user_preferences.theme === 'dark') if(user_preferences.theme === 'dark')
option(value="auto") Auto
option(value="") White option(value="") White
option(value="dark", selected="selected") Dark option(value="dark", selected="selected") Dark
option(value="sepia") Sepia option(value="sepia") Sepia
if(user_preferences.theme === 'sepia') if(user_preferences.theme === 'sepia')
option(value="auto") Auto
option(value="") White option(value="") White
option(value="dark") Dark option(value="dark") Dark
option(value="sepia", selected="selected") Sepia option(value="sepia", selected="selected") Sepia
if(user_preferences.theme === 'auto')
option(value="auto", selected="selected") Auto
option(value="") White
option(value="dark") Dark
option(value="sepia") Sepia
.setting .setting
label(for="flairs") Show flairs: label(for="flairs") Show flairs:
if(!user_preferences.flairs || user_preferences.flairs == 'true') if(!user_preferences.flairs || user_preferences.flairs == 'true')

View File

@ -3,7 +3,7 @@ html
head head
title privacy policy - teddit title privacy policy - teddit
include includes/head.pug include includes/head.pug
body(class=""+ user_preferences.theme +"") body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug include includes/topbar.pug
.container .container
.content .content

View File

@ -6,7 +6,7 @@ html
else else
title search results for #{q} title search results for #{q}
include includes/head.pug include includes/head.pug
body(class=""+ user_preferences.theme +"") body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug include includes/topbar.pug
#search.sr.search-page #search.sr.search-page
form(action="/r/" + subreddit + "/search", method="GET") form(action="/r/" + subreddit + "/search", method="GET")

View File

@ -3,7 +3,7 @@ html
head head
title /r/#{subreddit} title /r/#{subreddit}
include includes/head.pug include includes/head.pug
body(class=""+ user_preferences.theme +"") body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug include includes/topbar.pug
- -
let show_nsfw_warning = false; let show_nsfw_warning = false;

View File

@ -3,7 +3,7 @@ html
head head
title subreddits - explore title subreddits - explore
include includes/head.pug include includes/head.pug
body(class=""+ user_preferences.theme +"") body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug include includes/topbar.pug
if json === null if json === null
h1 Error occured h1 Error occured

View File

@ -3,7 +3,7 @@ html
head head
title overview for #{data.username} title overview for #{data.username}
include includes/head.pug include includes/head.pug
body(class=""+ user_preferences.theme +"") body(class=""+ (user_preferences.theme === 'auto' ? 'dark' : user_preferences.theme) + "")
include includes/topbar.pug include includes/topbar.pug
if user === null if user === null
h1 Error occured h1 Error occured