diff --git a/src/lib.rs b/src/lib.rs index 6e59dd5..92b23b6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,7 +43,7 @@ pub mod prelude { pub use crate::{self as osui, css, rsx, rsx_elem, ui::*, Handler}; pub use crate::{Element, Value}; // useful for Element making - pub use crate::{run_handler, Children, Component, ElementCore}; + pub use crate::{run_handler, Children, ElementCore, ElementWidget}; pub use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind}; pub fn sleep(ms: u64) { std::thread::sleep(std::time::Duration::from_millis(ms)); @@ -93,7 +93,7 @@ pub trait ElementCore: Send + Sync { fn set_styling(&mut self, styling: &HashMap); } -pub trait Component: ElementCore + std::fmt::Debug { +pub trait ElementWidget: ElementCore + std::fmt::Debug { fn render(&self, focused: bool) -> String { _ = focused; String::new() @@ -104,7 +104,7 @@ pub trait Component: ElementCore + std::fmt::Debug { } } -pub type Element = Box; +pub type Element = Box; ////////////////////////////////////////////////////////////////////////////////////////////////// /// Handler Struct diff --git a/src/main.rs b/src/main.rs index 3820e0a..3e7931e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ fn app() -> Element { fn styles() -> Css { css! { - .btn::click { + .btn::clicked { color: Blue } } diff --git a/src/ui/mod.rs b/src/ui/mod.rs index e47522e..981fdf8 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -28,7 +28,7 @@ use osui_element::{elem_fn, element}; #[derive(Default, Debug)] pub struct Text {} -impl Component for Text<'_> { +impl ElementWidget for Text<'_> { fn render(&self, _: bool) -> String { if let Children::Text(text) = &self.children { text.clone() @@ -65,7 +65,7 @@ pub struct Div { pub styling: Option>, } -impl Component for Div<'_> { +impl ElementWidget for Div<'_> { fn render(&self, focused: bool) -> String { let mut frame = crate::utils::create_frame(self.width.get_value(), self.height.get_value()); @@ -141,10 +141,10 @@ pub struct Button { pub state: &'a str, } -impl Component for Button<'_> { +impl ElementWidget for Button<'_> { fn render(&self, focused: bool) -> String { if self.state == "clicked" { - return self.style.write("click", &self.children.get_text()); + return self.style.write("clicked", &self.children.get_text()); } if focused { self.style.write("hover", &self.children.get_text())