users::page, users::created_at, nav gating, icons, misc
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
pub mod marquee;
|
||||
pub mod nav;
|
||||
pub mod user_miniprofile;
|
||||
|
||||
@@ -2,30 +2,33 @@ use maud::{Markup, PreEscaped, html};
|
||||
|
||||
use crate::{users::User, web::icons};
|
||||
|
||||
const LINKS: &[(&str, &str, &str)] = &[
|
||||
("Dashboard", "/dashboard", icons::LAYOUT_DASHBOARD),
|
||||
("Quotes", "#quotes", icons::SCROLL_TEXT),
|
||||
("Photos", "#photos", icons::FILE_IMAGE),
|
||||
("Persons", "#persons", icons::CONTACT),
|
||||
("Tags", "#tags", icons::TAG),
|
||||
("Users", "#users", icons::USERS),
|
||||
("Logs", "#logs", icons::CLIPBOARD_CLOCK),
|
||||
// (SHOWTEXT, LINK, ICON, REQUIRES_LOG_IN)
|
||||
const LINKS: &[(&str, &str, &str, bool)] = &[
|
||||
("Dashboard", "/dashboard", icons::LAYOUT_DASHBOARD, false),
|
||||
("Quotes", "#quotes", icons::SCROLL_TEXT, false),
|
||||
("Photos", "#photos", icons::FILE_IMAGE, false),
|
||||
("Persons", "#persons", icons::CONTACT, false),
|
||||
("Tags", "#tags", icons::TAG, false),
|
||||
("Users", "/users", icons::USERS, true),
|
||||
("Logs", "#logs", icons::CLIPBOARD_CLOCK, true),
|
||||
];
|
||||
|
||||
pub fn nav(user: Option<User>, uri: &str) -> Markup {
|
||||
pub fn nav(user: Option<&User>, uri: &str) -> Markup {
|
||||
html!(
|
||||
div class="flex items-center text-sm gap-4 border-b border-neutral-200/25 bg-neutral-200/5 px-4 py-2" {
|
||||
a href="/dashboard" class="font-lora font-semibold hidden xs:block md:text-xl sm:mr-2" {"Mnemosyne"}
|
||||
div class="w-px h-5 bg-neutral-200/15 hidden sm:block" {}
|
||||
div class="flex flex-row" {
|
||||
@for link in LINKS {
|
||||
a href={(link.1)} class="flex flex-row px-2 py-1 rounded items-center gap-2 hover:bg-neutral-200/5 border border-transparent hover:border-neutral-200/25" {
|
||||
@if uri.starts_with(link.1) {
|
||||
div class="scale-[.75] text-neutral-300" {(PreEscaped(link.2))}
|
||||
span class="text-neutral-200 font-light hidden lg:block" { (link.0) }
|
||||
} @else {
|
||||
div class="scale-[.75] text-neutral-500" {(PreEscaped(link.2))}
|
||||
span class="text-neutral-400 font-light hidden lg:block" { (link.0) }
|
||||
@if !link.3 || user.is_some() {
|
||||
a href={(link.1)} class="flex flex-row px-2 py-1 rounded items-center gap-2 hover:bg-neutral-200/5 border border-transparent hover:border-neutral-200/25" {
|
||||
@if uri.starts_with(link.1) {
|
||||
div class="scale-[.75] text-neutral-300" {(PreEscaped(link.2))}
|
||||
span class="text-neutral-200 font-light hidden lg:block" { (link.0) }
|
||||
} @else {
|
||||
div class="scale-[.75] text-neutral-500" {(PreEscaped(link.2))}
|
||||
span class="text-neutral-400 font-light hidden lg:block" { (link.0) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
33
src/web/components/user_miniprofile.rs
Normal file
33
src/web/components/user_miniprofile.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use maud::{Markup, PreEscaped, html};
|
||||
|
||||
use crate::{users::User, web::icons};
|
||||
|
||||
pub fn user_miniprofile(u: &User) -> Markup {
|
||||
let show_shield = u.is_infradmin() || u.is_systemuser();
|
||||
html!(
|
||||
a href=(format!("/users/{}", u.id))
|
||||
class="w-70 border border-neutral-200/25 hover:border-neutral-200/50 bg-neutral-200/5 hover:bg-neutral-200/10 transition-colors rounded flex" {
|
||||
div class="bg-neutral-200/10 text-neutral-300 font-semibold aspect-square flex items-center justify-center" {
|
||||
(u.handle.as_str().chars().next().unwrap_or('?').to_uppercase())
|
||||
}
|
||||
div class="p-3" {
|
||||
p class="text-semibold flex" {
|
||||
(u.handle)
|
||||
@if show_shield {
|
||||
span class="scale-[.75] text-neutral-500"
|
||||
title="This is a special internal user." {(PreEscaped(icons::SHIELD_USER))}
|
||||
}
|
||||
}
|
||||
p class="text-xs text-neutral-500 flex items-center mt-1" {
|
||||
@if show_shield {
|
||||
span class="scale-[.5] -ml-1" {(PreEscaped(icons::SERVER))}
|
||||
"System account"
|
||||
} @else {
|
||||
span class="scale-[.5] -ml-1" {(PreEscaped(icons::CALENDAR_1))}
|
||||
(u.created_at().map_or("Unknown".into(), |d| d.to_string()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user