aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes/ui/layout.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-10-24 15:08:15 +0200
committermetamuffin <metamuffin@disroot.org>2023-10-24 15:08:15 +0200
commitf4f3a16bca576c202887799066bd896863612e2b (patch)
tree8ddb9cdc47abae7bc615109f241b2cd12e141128 /server/src/routes/ui/layout.rs
parentc1afcdc0dc4e59cb2ce1e8c65b69c5647f2132f3 (diff)
downloadjellything-f4f3a16bca576c202887799066bd896863612e2b.tar
jellything-f4f3a16bca576c202887799066bd896863612e2b.tar.bz2
jellything-f4f3a16bca576c202887799066bd896863612e2b.tar.zst
partial theme implementation
Diffstat (limited to 'server/src/routes/ui/layout.rs')
-rw-r--r--server/src/routes/ui/layout.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/server/src/routes/ui/layout.rs b/server/src/routes/ui/layout.rs
index cdac09c..c4d1275 100644
--- a/server/src/routes/ui/layout.rs
+++ b/server/src/routes/ui/layout.rs
@@ -18,6 +18,7 @@ use crate::{
};
use futures::executor::block_on;
use jellybase::CONF;
+use jellycommon::user::Theme;
use markup::{DynRender, Render};
use rocket::{
http::ContentType,
@@ -27,7 +28,7 @@ use rocket::{
use std::io::Cursor;
markup::define! {
- Layout<'a, Main: Render>(title: String, main: Main, class: Option<&'a str>, session: Option<Session>) {
+ Layout<'a, Main: Render>(title: String, main: Main, class: &'a str, session: Option<Session>) {
@markup::doctype()
html {
head {
@@ -35,7 +36,7 @@ markup::define! {
link[rel="stylesheet", href="/assets/style.css"];
script[src="/assets/bundle.js"] {}
}
- body[class=class.unwrap_or("")] {
+ body[class=class] {
nav {
h1 { a[href="/"] { @CONF.brand } } " "
@if let Some(_) = session {
@@ -102,7 +103,18 @@ impl<'r, Main: Render> Responder<'r, 'static> for LayoutPage<Main> {
Layout {
main: self.content,
title: self.title,
- class: self.class.as_deref(),
+ class: &format!(
+ "{} {}",
+ self.class.as_deref().unwrap_or(""),
+ match session
+ .as_ref()
+ .map(|s| s.user.theme)
+ .unwrap_or(Theme::Dark)
+ {
+ Theme::Dark => "theme-dark",
+ Theme::Light => "theme-light",
+ }
+ ),
session,
}
.render(&mut out)