update
This commit is contained in:
parent
f3a85de02e
commit
86f61ff3f6
15 changed files with 918 additions and 41 deletions
|
@ -31,10 +31,6 @@ impl Shadow {
|
|||
pub fn _2xl<T: UIWidget + 'static>(inner: T) -> Self {
|
||||
Self(Box::new(inner), "2xl".to_owned())
|
||||
}
|
||||
|
||||
pub fn inner<T: UIWidget + 'static>(inner: T) -> Self {
|
||||
Self(Box::new(inner), "inner".to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for Shadow {
|
||||
|
@ -76,3 +72,75 @@ impl UIWidget for Shadow {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DropShadow(Box<dyn UIWidget>, String);
|
||||
|
||||
impl DropShadow {
|
||||
pub fn small<T: UIWidget + 'static>(inner: T) -> Self {
|
||||
Self(Box::new(inner), "sm".to_owned())
|
||||
}
|
||||
|
||||
pub fn regular<T: UIWidget + 'static>(inner: T) -> Self {
|
||||
Self(Box::new(inner), String::new())
|
||||
}
|
||||
|
||||
pub fn medium<T: UIWidget + 'static>(inner: T) -> Self {
|
||||
Self(Box::new(inner), "md".to_owned())
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
pub fn xl<T: UIWidget + 'static>(inner: T) -> Self {
|
||||
Self(Box::new(inner), "xl".to_owned())
|
||||
}
|
||||
|
||||
pub fn _2xl<T: UIWidget + 'static>(inner: T) -> Self {
|
||||
Self(Box::new(inner), "2xl".to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for DropShadow {
|
||||
fn render(&self) -> Markup {
|
||||
self.render_with_class("")
|
||||
}
|
||||
}
|
||||
|
||||
impl UIWidget for DropShadow {
|
||||
fn can_inherit(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn base_class(&self) -> Vec<String> {
|
||||
if self.1.is_empty() {
|
||||
vec!["drop-shadow".to_string()]
|
||||
} else {
|
||||
vec![format!("drop-shadow-{}", self.1)]
|
||||
}
|
||||
}
|
||||
|
||||
fn extended_class(&self) -> Vec<String> {
|
||||
let mut c = self.base_class();
|
||||
c.extend_from_slice(&self.0.extended_class());
|
||||
c
|
||||
}
|
||||
|
||||
fn render_with_class(&self, class: &str) -> Markup {
|
||||
if self.0.as_ref().can_inherit() {
|
||||
self.0
|
||||
.as_ref()
|
||||
.render_with_class(&format!("{} {class}", self.base_class().join(" ")))
|
||||
} else {
|
||||
html! {
|
||||
div class=(format!("{} {class}", self.base_class().join(" "))) {
|
||||
(self.0.as_ref())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue