diff --git a/src/examples.rs b/src/examples.rs index 0e85165..ee3647f 100644 --- a/src/examples.rs +++ b/src/examples.rs @@ -1,10 +1,10 @@ use crate::prelude::*; pub fn todo_app() -> Element { - let todo = vec!["Foo", "Bar"]; + let todo = vec!["Todo", "Hovering", "Completed", "Foo", "Bar"]; rsx! { - text { class: "title", "Todo list app made with OSUI" } + text { class: "title", static "Todo list app made with OSUI" } text { class: "title", "{}", "-".repeat(crossterm::terminal::size().unwrap().0 as usize) } for (t in todo) { ersx!( button{ class: "todo", on_click: fn(btn: &mut Button, _, _) { @@ -26,7 +26,7 @@ pub fn todo_styling() -> Css { color: Red, } "todo": "hover" { - color: Blue + color: Blue, } "complete" { x: 0 px, diff --git a/src/lib.rs b/src/lib.rs index 3d624ce..088098b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,17 +104,6 @@ pub enum Children { Children(Vec, usize), } -impl std::fmt::Debug for Children { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(&match self { - Self::None => String::new(), - Self::Children(a, b) => format!("({b}, {a:?})"), - Self::Text(a) => format!("{:?}", a()), - Self::StaticText(a) => format!("{a:?}"), - }) - } -} - ////////////////////////////////////////////////////////////////////////////////////////////////// /// Implementations ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -209,6 +198,17 @@ impl Default for Children { } } +impl std::fmt::Debug for Children { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(&match self { + Self::None => String::new(), + Self::Children(a, b) => format!("({b}, {a:?})"), + Self::Text(a) => format!("{:?}", a()), + Self::StaticText(a) => format!("static({a:?})"), + }) + } +} + impl Children { pub fn is_none(&self) -> bool { match self { diff --git a/src/rsx.rs b/src/rsx.rs index 0f6fd80..3247413 100644 --- a/src/rsx.rs +++ b/src/rsx.rs @@ -12,6 +12,14 @@ macro_rules! check_expr { } #[macro_export] macro_rules! parse_rsx_param { + ($elem:expr, static $text:expr) => { + $elem.children.set_static_force(format!($text)) + }; + + ($elem:expr, static $text:expr, $($inner:tt)*) => { + $elem.children.set_static_force(format!($text, $($inner)*)) + }; + ($elem:expr, for ($($for:tt)*) $code:block $($rest:tt)*) => { if $elem.children.is_none() {$elem.children = $crate::Children::Children(Vec::new(), 0)} if let $crate::Children::Children(children, _) = &mut $elem.children {