From 80dfeb12934e04bdb8b96d4a354d9d8bfa5ad6d3 Mon Sep 17 00:00:00 2001 From: Austin Alvarado Date: Tue, 21 Mar 2023 03:50:17 -0600 Subject: [PATCH] app: Implement dark theme and toggle --- app/index.html | 13 +++++++++++-- app/index_local.html | 12 ++++++++++-- app/src/components/app.rs | 31 ++++++++++++++++++++++++++----- app/static/libraries.txt | 3 ++- app/static/style.css | 20 ++++++++++++++++++++ 5 files changed, 69 insertions(+), 10 deletions(-) diff --git a/app/index.html b/app/index.html index cbe820c..d99c083 100644 --- a/app/index.html +++ b/app/index.html @@ -6,15 +6,19 @@ LLDAP Administration + + diff --git a/app/index_local.html b/app/index_local.html index 58e956b..59f0955 100644 --- a/app/index_local.html +++ b/app/index_local.html @@ -6,13 +6,16 @@ LLDAP Administration + + diff --git a/app/src/components/app.rs b/app/src/components/app.rs index 72a57a7..36a6308 100644 --- a/app/src/components/app.rs +++ b/app/src/components/app.rs @@ -17,6 +17,7 @@ use crate::{ }; use gloo_console::error; +use wasm_bindgen::prelude::*; use yew::{ function_component, html::Scope, @@ -29,6 +30,25 @@ use yew_router::{ BrowserRouter, Switch, }; +#[wasm_bindgen] +extern "C" { + #[wasm_bindgen(js_namespace = darkmode)] + fn toggleDarkMode(doSave: bool); + + #[wasm_bindgen] + fn inDarkMode() -> bool; +} + +#[function_component(DarkModeToggle)] +pub fn dark_mode_toggle() -> Html { + html! { +
+ + +
+ } +} + #[function_component(AppContainer)] pub fn app_container() -> Html { html! { @@ -242,7 +262,7 @@ impl App {
- +

{"LLDAP"}

@@ -251,7 +271,7 @@ impl App { <>
  • {"Users"} @@ -259,7 +279,7 @@ impl App {
  • {"Groups"} @@ -269,6 +289,7 @@ impl App { } } else { html!{} } } { self.view_user_menu(ctx) } +
  • @@ -281,7 +302,7 @@ impl App { html! {