Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Dec 1, 2023
1 parent b4395a1 commit f783049
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions examples/gallery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ fn AppSidebar(cx: Scope) -> Element {
to: Route::ScrollViewDemo,
"ScrollView"
}
SidebarItem::<Route> {
to: Route::DropdownDemo,
"Dropdown"
}
),
rect {
width: "100%",
Expand Down Expand Up @@ -113,7 +117,7 @@ fn ScrollViewDemo(cx: Scope) -> Element {
height: "200",
width: "250",
show_scrollbar: *show_scrollbar.get(),

rect {
direction: "horizontal",
rect {
Expand Down Expand Up @@ -180,13 +184,30 @@ fn ScrollViewDemo(cx: Scope) -> Element {

#[allow(non_snake_case)]
fn DropdownDemo(cx: Scope) -> Element {
let values = cx.use_hook(|| vec!["A".to_string(), "B".to_string(), "C".to_string()]);
let selected_dropdown = use_state(cx, || "A".to_string());

render!(
DemoTitle {
"Dropdown"
}
SectionTitle {
"Example"
}
DemoBlock {
Dropdown {
value: selected_dropdown.get().clone(),
values.iter().map(|ch| {
rsx!(
DropdownItem {
value: ch.to_string(),
onclick: move |_| selected_dropdown.set(ch.to_string()),
label { "{ch}" }
}
)
})
}
}
)
}

Expand All @@ -201,7 +222,6 @@ fn DemoTitle<'a>(cx: Scope<'a>, children: Element<'a>) -> Element {
})
}


#[allow(non_snake_case)]
#[inline_props]
fn SectionTitle<'a>(cx: Scope<'a>, children: Element<'a>) -> Element {
Expand Down

0 comments on commit f783049

Please sign in to comment.