Crates.io | lookbook |
lib.rs | lookbook |
version | 0.2.0-alpha.1 |
source | src |
created_at | 2023-10-21 19:54:24.908384 |
updated_at | 2024-09-08 16:00:38.146472 |
description | Component preview framework for Dioxus |
homepage | |
repository | |
max_upload_size | |
id | 1010215 |
size | 105,301 |
/// To-Do Task.
#[preview]
pub fn TaskPreview(
/// Label of the task.
#[lookbook(default = "Ice skating")]
label: String,
/// Content of the task.
#[lookbook(default = "Central Park")]
content: String,
/// List of tags.
#[lookbook(default = vec![String::from("A")])]
tags: Json<Vec<String>>,
) -> Element {
rsx!(
div {
h4 { "{label}" }
p { "{content}" }
div { { tags.0.iter().map(|tag| rsx!(li { "{tag}" })) } }
}
)
}
#[component]
fn app() -> Element {
rsx!(LookBook {
home: |()| rsx!("Home"),
previews: [TaskPreview]
})
}
fn main() {
dioxus::launch(app)
}
First add Lookbook as a dependency to your project.
cargo add lookbook --git https://github.com/matthunz/lookbook
Then create a preview like the one above and add it to a lookbook.
fn app() -> Element {
rsx!(LookBook {
home: |()| rsx!("Home"),
previews: [TaskPreview]
})
}
fn main() {
dioxus_web::launch(app)
}
Run with dx serve
!
Run the examples with dx serve --example {name}
.