This commit is contained in:
JMARyA 2025-01-20 06:09:56 +01:00
parent f7db3333c5
commit 5d4aa21edd
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 247 additions and 16 deletions

View file

@ -1,35 +1,46 @@
use crate::ui::UIWidget;
use crate::ui::{UIWidget, color::UIColor};
use maud::{Markup, Render, html};
pub struct Shadow(Box<dyn UIWidget>, String);
pub struct Shadow(Box<dyn UIWidget>, String, Option<Box<dyn UIColor>>);
impl Shadow {
pub fn medium<T: UIWidget + 'static>(inner: T) -> Self {
Self(Box::new(inner), "md".to_owned())
}
pub fn small<T: UIWidget + 'static>(inner: T) -> Self {
Self(Box::new(inner), "sm".to_owned())
Self(Box::new(inner), "sm".to_owned(), None)
}
pub fn regular<T: UIWidget + 'static>(inner: T) -> Self {
Self(Box::new(inner), String::new())
Self(Box::new(inner), String::new(), None)
}
pub fn medium<T: UIWidget + 'static>(inner: T) -> Self {
Self(Box::new(inner), "md".to_owned(), None)
}
pub fn large<T: UIWidget + 'static>(inner: T) -> Self {
Self(Box::new(inner), "lg".to_owned())
}
pub fn none<T: UIWidget + 'static>(inner: T) -> Self {
Self(Box::new(inner), "none".to_owned())
Self(Box::new(inner), "lg".to_owned(), None)
}
pub fn xl<T: UIWidget + 'static>(inner: T) -> Self {
Self(Box::new(inner), "xl".to_owned())
Self(Box::new(inner), "xl".to_owned(), None)
}
pub fn _2xl<T: UIWidget + 'static>(inner: T) -> Self {
Self(Box::new(inner), "2xl".to_owned())
Self(Box::new(inner), "2xl".to_owned(), None)
}
pub fn inner<T: UIWidget + 'static>(inner: T) -> Self {
Self(Box::new(inner), "inner".to_owned(), None)
}
pub fn none<T: UIWidget + 'static>(inner: T) -> Self {
Self(Box::new(inner), "none".to_owned(), None)
}
}
impl Shadow {
pub fn color<C: UIColor + 'static>(mut self, color: C) -> Self {
self.2 = Some(Box::new(color));
self
}
}
@ -45,11 +56,17 @@ impl UIWidget for Shadow {
}
fn base_class(&self) -> Vec<String> {
if self.1.is_empty() {
let mut ret = if self.1.is_empty() {
vec!["shadow".to_string()]
} else {
vec![format!("shadow-{}", self.1)]
};
if let Some(color) = &self.2 {
ret.push(format!("shadow-{}", color.color_class()));
}
ret
}
fn extended_class(&self) -> Vec<String> {