Skip to content

Commit

Permalink
Add example to root docs
Browse files Browse the repository at this point in the history
  • Loading branch information
matthunz committed Nov 18, 2024
1 parent a309a37 commit cfef238
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
//! # Actuate
//! Actuate is a native, declarative, and friendly user-interface (UI) framework.
//!
//! ```no_run
//! use actuate::prelude::*;
//!
//! #[derive(Data)]
//! struct Counter {
//! start: i32,
//! }
//!
//! impl Compose for Counter {
//! fn compose(cx: Scope<Self>) -> impl Compose {
//! let count = use_mut(&cx, || cx.me().start);
//!
//! Window::new((
//! Text::new(format!("High five count: {}", *count))
//! .font(GenericFamily::Cursive)
//! .font_size(60.),
//! Text::new("Up high")
//! .on_click(move || count.update(|x| *x += 1))
//! .background_color(Color::BLUE),
//! Text::new("Down low")
//! .on_click(move || count.update(|x| *x -= 1))
//! .background_color(Color::RED),
//! if *count == 0 {
//! Some(Text::new("Gimme five!"))
//! } else {
//! None
//! },
//! ))
//! .font_size(40.)
//! }
//! }
//!
//! actuate::run(Counter { start: 0 })
//! ```
//!
//! ## Hooks
//! Functions that begin with `use_` are called `hooks` in Actuate.
//! Hooks are used to manage state and side effects in composables.
Expand Down

0 comments on commit cfef238

Please sign in to comment.