diff --git a/src/ui/color.rs b/src/ui/color.rs index 13ba7cb..c42e898 100644 --- a/src/ui/color.rs +++ b/src/ui/color.rs @@ -12,6 +12,8 @@ pub trait ColorCircle { fn next(&self) -> Self; } +// todo : specific colors rgb + macro_rules! color_map { ($name:ident, $id:literal) => { #[derive(Debug, Clone)] diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 0f5427a..acf089f 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1,5 +1,6 @@ use components::Shell; use maud::{Markup, PreEscaped, Render}; +use prelude::Text; // UI @@ -133,6 +134,42 @@ impl UIWidget for PreEscaped { } } +impl UIWidget for String { + fn can_inherit(&self) -> bool { + Text(&self).can_inherit() + } + + fn base_class(&self) -> Vec { + Text(&self).base_class() + } + + fn extended_class(&self) -> Vec { + Text(&self).extended_class() + } + + fn render_with_class(&self, class: &str) -> Markup { + Text(&self).render_with_class(class) + } +} + +impl UIWidget for &str { + fn can_inherit(&self) -> bool { + Text(&self).can_inherit() + } + + fn base_class(&self) -> Vec { + Text(&self).base_class() + } + + fn extended_class(&self) -> Vec { + Text(&self).extended_class() + } + + fn render_with_class(&self, class: &str) -> Markup { + Text(&self).render_with_class(class) + } +} + /// Trait for an element which can add new `attrs` pub trait AttrExtendable { #[must_use] diff --git a/src/ui/primitives/div.rs b/src/ui/primitives/div.rs index 3175d57..0d1c8d6 100644 --- a/src/ui/primitives/div.rs +++ b/src/ui/primitives/div.rs @@ -116,11 +116,7 @@ impl UIWidget for DivWidget { } fn extended_class(&self) -> Vec { - if self.1 { - self.extended_class_() - } else { - vec![] - } + vec![] } fn render_with_class(&self, class: &str) -> Markup { diff --git a/src/ui/primitives/text.rs b/src/ui/primitives/text.rs index 82d9b4f..5230a1f 100644 --- a/src/ui/primitives/text.rs +++ b/src/ui/primitives/text.rs @@ -348,7 +348,7 @@ impl TextWidget { #[must_use] pub fn title(mut self, title: &str) -> Self { - self.title = Some(title.to_string()); + self.title = Some(title.replace('\'', "\\'")); self }