static text
This commit is contained in:
+3
-3
@@ -1,10 +1,10 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub fn todo_app() -> Element {
|
pub fn todo_app() -> Element {
|
||||||
let todo = vec!["Foo", "Bar"];
|
let todo = vec!["Todo", "Hovering", "Completed", "Foo", "Bar"];
|
||||||
|
|
||||||
rsx! {
|
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) }
|
text { class: "title", "{}", "-".repeat(crossterm::terminal::size().unwrap().0 as usize) }
|
||||||
for (t in todo) {
|
for (t in todo) {
|
||||||
ersx!( button{ class: "todo", on_click: fn(btn: &mut Button, _, _) {
|
ersx!( button{ class: "todo", on_click: fn(btn: &mut Button, _, _) {
|
||||||
@@ -26,7 +26,7 @@ pub fn todo_styling() -> Css {
|
|||||||
color: Red,
|
color: Red,
|
||||||
}
|
}
|
||||||
"todo": "hover" {
|
"todo": "hover" {
|
||||||
color: Blue
|
color: Blue,
|
||||||
}
|
}
|
||||||
"complete" {
|
"complete" {
|
||||||
x: 0 px,
|
x: 0 px,
|
||||||
|
|||||||
+11
-11
@@ -104,17 +104,6 @@ pub enum Children {
|
|||||||
Children(Vec<Element>, usize),
|
Children(Vec<Element>, 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
|
/// 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 {
|
impl Children {
|
||||||
pub fn is_none(&self) -> bool {
|
pub fn is_none(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
|
|||||||
@@ -12,6 +12,14 @@ macro_rules! check_expr {
|
|||||||
}
|
}
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! parse_rsx_param {
|
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)*) => {
|
($elem:expr, for ($($for:tt)*) $code:block $($rest:tt)*) => {
|
||||||
if $elem.children.is_none() {$elem.children = $crate::Children::Children(Vec::new(), 0)}
|
if $elem.children.is_none() {$elem.children = $crate::Children::Children(Vec::new(), 0)}
|
||||||
if let $crate::Children::Children(children, _) = &mut $elem.children {
|
if let $crate::Children::Children(children, _) = &mut $elem.children {
|
||||||
|
|||||||
Reference in New Issue
Block a user