Skip to content

Commit

Permalink
Change tabs preview to use json
Browse files Browse the repository at this point in the history
  • Loading branch information
matthunz committed Oct 25, 2023
1 parent 79fb78b commit a00fbd6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
9 changes: 6 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 12 additions & 20 deletions lookbook/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,19 @@ fn TabRowPreview<'a>(
cx: Scope<'a>,

/// Label for tab A.
#[lookbook(default = "Tab A")]
label_a: &'a str,

/// Label for tab B.
#[lookbook(default = "Tab B")]
label_b: &'a str,

/// Label for tab C.
#[lookbook(default = "Tab C")]
label_c: &'a str,
#[lookbook(default = vec![String::from("Tab A")])]
tabs: lookbook::Json<Vec<String>>,
) -> Element<'a> {
render!(div {width: "500px", TabRow {
onselect: |_| {},
tabs: cx
.bump()
.alloc([
render!(Tab { label_a }),
render!(Tab {label_b }),
render!(Tab { label_c }),
])
}})
render!(
div { width: "500px",
TabRow {
onselect: |_| {},
tabs: cx
.bump()
.alloc(tabs.0.iter().map(|label| render!(Tab { "{label}" })).collect::<Vec<_>>())
}
}
)
}

/// Buttons let people take action and make choices with one tap.
Expand Down

0 comments on commit a00fbd6

Please sign in to comment.