This commit is contained in:
JMARyA 2025-01-20 03:20:44 +01:00
parent 79f08fd202
commit 11e1bd975f
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
4 changed files with 41 additions and 6 deletions

View file

@ -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)]

View file

@ -1,5 +1,6 @@
use components::Shell;
use maud::{Markup, PreEscaped, Render};
use prelude::Text;
// UI
@ -133,6 +134,42 @@ impl UIWidget for PreEscaped<String> {
}
}
impl UIWidget for String {
fn can_inherit(&self) -> bool {
Text(&self).can_inherit()
}
fn base_class(&self) -> Vec<String> {
Text(&self).base_class()
}
fn extended_class(&self) -> Vec<String> {
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<String> {
Text(&self).base_class()
}
fn extended_class(&self) -> Vec<String> {
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]

View file

@ -116,11 +116,7 @@ impl UIWidget for DivWidget {
}
fn extended_class(&self) -> Vec<String> {
if self.1 {
self.extended_class_()
} else {
vec![]
}
vec![]
}
fn render_with_class(&self, class: &str) -> Markup {

View file

@ -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
}