This commit is contained in:
2025-07-12 17:34:21 +02:00
parent 205bcabf5a
commit 5711f84172
5 changed files with 192 additions and 36 deletions
+94
View File
@@ -0,0 +1,94 @@
body {
background-color: var(--bg);
margin: 0;
color: var(--fg);
}
.sidebar-container {
margin-top: 20px;
display: flex;
gap: 20px;
height: calc(100vh - 20px);
}
.settings-container {
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: 20px;
flex: 1;
width: 100%;
padding-right: 25px;
overflow-y: auto;
height: 100%;
padding-bottom: 20px;
}
.settings-container {
background-color: var(--card-bg);
width: 100%;
height: 100%;
border-radius: 20px;
box-sizing: border-box;
padding: 25px;
}
.dropdown-none {
display: none !important;
}
.dropdown-button {
display: flex;
text-align: center;
align-items: center;
justify-content: center;
padding: 10px;
gap: 10px;
border-radius: 10px;
border: 0;
outline: 0;
text-transform: capitalize;
background-color: var(--bg);
color: var(--fg);
}
.dropdown-chevron {
height: max-content;
width: max-content;
margin-top: auto;
margin-bottom: auto;
}
.dropdown {
display: flex;
flex-direction: column;
width: max-content;
background-color: transparent;
margin-top: 10px;
margin-left: auto;
margin-right: auto;
background-color: var(--bg);
color: var(--fg);
}
.dropdown button {
padding: 10px;
padding-left: 20px;
padding-right: 20px;
border: 0;
outline: 0;
background-color: transparent;
color: var(--fg);
}
.dropdown button:hover {
background-color: var(--card-bg);
}
.dropdown-button:hover {
background-color: var(--card-bg);
}
.dropdown-wrapper {
width: max-content;
}
+24 -22
View File
@@ -72,34 +72,36 @@
.black { .black {
/* States */ /* States */
--online: rgb(0, 255, 128); /* neon green */ --online: rgb(0, 255, 128); /* neon green */
--offline: rgb(255, 77, 77); /* soft red */ --offline: rgb(255, 77, 77); /* soft red */
--warning: rgb(255, 193, 7); /* bright yellow */ --warning: rgb(255, 193, 7); /* bright yellow */
--maintenance: rgb(100, 181, 246); /* light blue */ --maintenance: rgb(100, 181, 246); /* light blue */
/* States bg (dark, translucent overlays) */ /* States bg (dark, translucent overlays) */
--online-bg: rgba(0, 128, 64, 0.3); /* deep green */ --online-bg: rgba(0, 128, 64, 0.3); /* deep green */
--offline-bg: rgba(139, 0, 0, 0.3); /* dark red */ --offline-bg: rgba(139, 0, 0, 0.3); /* dark red */
--warning-bg: rgba(153, 102, 0, 0.3); /* golden brown */ --warning-bg: rgba(153, 102, 0, 0.3); /* golden brown */
--maintenance-bg: rgba(25, 118, 210, 0.3);/* muted blue */ --maintenance-bg: rgba(25, 118, 210, 0.3); /* muted blue */
/* Overview data */ /* Overview data */
--online-ov: #00ff80; /* neon green */ --online-ov: #00ff80; /* neon green */
--issue: rgb(255, 85, 0); /* warning orange */ --issue: rgb(255, 85, 0); /* warning orange */
--cpu: rgb(66, 165, 245); /* light blue */ --cpu: rgb(66, 165, 245); /* light blue */
--memory: rgb(200, 39, 228); /* purple */ --memory: rgb(200, 39, 228); /* purple */
--storage: rgb(255, 111, 0); /* orange */ --storage: rgb(255, 111, 0); /* orange */
--network: rgb(0, 200, 83); /* green */ --network: rgb(0, 200, 83); /* green */
/* Usage levels */ /* Usage levels */
--low: rgb(11, 226, 86); /* neon green */ --low: rgb(11, 226, 86); /* neon green */
--medium: rgb(231, 215, 72); /* bright yellow */ --medium: rgb(231, 215, 72); /* bright yellow */
--high: rgb(211, 56, 48); /* red */ --high: rgb(211, 56, 48); /* red */
/* Misc */ /* Misc */
--bg: #000000; /* pure black */ --bg: #000000; /* pure black */
--fg: #ffffff; /* pure white */ --fg: #ffffff; /* pure white */
--card-bg: #0e0e0e; /* almost black card */ --card-bg: #0e0e0e; /* almost black card */
--progress-bg: #1a1a1a; /* very dark grey */ --progress-bg: #1a1a1a; /* very dark grey */
--server-icon-bg: #111111; /* dark grey */ --server-icon-bg: #111111; /* dark grey */
--fg-selected: #f8fafc;
--bg-selected: #1a1a1a;
} }
+1 -1
View File
@@ -19,7 +19,7 @@ const SIDEBAR_ITEMS: &[SideBarItem] = &[
SideBarItem { SideBarItem {
name: "Settings", name: "Settings",
icon: || rsx!(lucide_dioxus::Settings { size: 35 }), icon: || rsx!(lucide_dioxus::Settings { size: 35 }),
route: Route::Dashboard {}, route: Route::Settings {},
}, },
]; ];
+5 -13
View File
@@ -3,12 +3,14 @@ mod components;
mod cookie; mod cookie;
mod dashboard; mod dashboard;
mod login; mod login;
mod settings;
use dioxus::prelude::*; use dioxus::prelude::*;
use web_sys::window; use web_sys::window;
use dashboard::Dashboard; use dashboard::Dashboard;
use login::Login; use login::Login;
use settings::Settings;
#[derive(Debug, Clone, Routable, PartialEq)] #[derive(Debug, Clone, Routable, PartialEq)]
#[rustfmt::skip] #[rustfmt::skip]
@@ -17,6 +19,8 @@ enum Route {
Login {}, Login {},
#[route("/dashboard")] #[route("/dashboard")]
Dashboard {}, Dashboard {},
#[route("/settings")]
Settings {},
} }
const FAVICON: Asset = asset!("/assets/favicon.ico"); const FAVICON: Asset = asset!("/assets/favicon.ico");
@@ -29,7 +33,7 @@ fn main() {
#[component] #[component]
fn App() -> Element { fn App() -> Element {
let mut theme = use_signal(|| String::from("light")); let theme = use_signal(|| String::from("light"));
use_effect({ use_effect({
let mut theme = theme.clone(); let mut theme = theme.clone();
@@ -53,18 +57,6 @@ fn App() -> Element {
document::Link { rel: "icon", href: FAVICON } document::Link { rel: "icon", href: FAVICON }
document::Link { rel: "stylesheet", href: FONT_CSS } document::Link { rel: "stylesheet", href: FONT_CSS }
document::Link { rel: "stylesheet", href: THEME_CSS } document::Link { rel: "stylesheet", href: THEME_CSS }
button {
onclick: move |_| {
let d = match theme.read().as_str() {
"dark" => String::from("black"),
"black" => String::from("light"),
_ => String::from("dark")
};
cookie::set_cookie("theme", &d);
theme.set(d);
},
"Click"
}
Router::<Route> { } Router::<Route> { }
} }
} }
+68
View File
@@ -0,0 +1,68 @@
use dioxus::prelude::*;
use crate::{components::sidebar::SideBar, cookie};
pub enum Property {
Dropdown(&'static [&'static str]),
}
const SETTINGS_CSS: Asset = asset!("/assets/styles/settings.css");
const OPTIONS: &[(&str, Property, bool)] = &[(
"theme",
Property::Dropdown(&["light", "dark", "black"]),
true,
)];
#[component]
pub fn Settings() -> Element {
rsx! {
document::Link { rel: "stylesheet", href: SETTINGS_CSS }
div { class: "sidebar-container",
SideBar { selected: 1 }
div { class: "settings-container",
div {
for (name, prop, needs_refresh) in OPTIONS {
match prop {
Property::Dropdown(opts) => {
rsx!{
div { class: "dropdown-wrapper",
button { class: "dropdown-button", onclick: |_| {
let Some(document) = web_sys::window().and_then(|w| w.document()) else {
return;
};
let e = document.get_element_by_id(name).unwrap();
if e.class_name() == "dropdown" {
e.set_class_name("dropdown dropdown-none");
} else {
e.set_class_name("dropdown");
}
},
"{name}"
lucide_dioxus::ChevronDown { size: 16, class: "chevron", color: "currentColor" }
}
div {
id: "{name}",
class: "dropdown",
for o in opts {
button { onclick: move |_| {
cookie::set_cookie(name, &o);
if *needs_refresh {
if let Some(win) = web_sys::window() {
win.location().reload().unwrap();
}
}
}, "{o}" }
}
}
}
}
}
}
}
}
}
}
}
}