Conversation
|
Just needs a |
e567281 to
ee41b5c
Compare
mnmaita
left a comment
There was a problem hiding this comment.
Took a second look at this and found a few more nits 🙏🏻 thanks!
| Hovered::default() | ||
| {checkbox_identifier.is_some().then(|| | ||
| { bsn! { template_value(checkbox_identifier.unwrap()) } | ||
| })} |
There was a problem hiding this comment.
{checkbox_identifier.and_then(|checkbox_identifier| {
bsn! { template_value(checkbox_identifier) }
})}Would something like this work here to simplify things a bit?
There was a problem hiding this comment.
Apparently, with and_then, the compiler expects the closure to return an option, so to get it to work, you have to wrap the bsn!: Some(bsn! { .. } )
But the linter objected to that, on the grounds that that's identical to this:
{checkbox_identifier.map(|checkbox_identifier| {
bsn! { template_value(checkbox_identifier) }
})}There was a problem hiding this comment.
Oh yeah map makes more sense here, good catch.
Sorry that I was insisting on these refactors but I feel like they are great examples that we should show so people know they can optionally add components in BSN easily.
There was a problem hiding this comment.
No need to apologize; the code is better because of your suggestions! And I'm learning stuff too, I didn't know bsn could "do" conditional components, or that .and_then / then could be used like that
| top_left_scene() | ||
| Children [ | ||
| feathers_option_checkbox("ROTATE", Some(CheckboxInput::Rotation), IsChecked(false)), | ||
| feathers_option_checkbox("WIREFRAME", Some(CheckboxInput::Wireframe), IsChecked(false)), |
There was a problem hiding this comment.
It might be worthwile to also get rid of the almost identical branches here by doing something like:
{(!cfg!(target_arch = "wasm32")).then(|| {
bsn! { feathers_option_checkbox("WIREFRAME", Some(CheckboxInput::Wireframe), IsChecked(false)) }
})}
mnmaita
left a comment
There was a problem hiding this comment.
Thanks for addressing the requested changes! I just tested the example locally and it looks good. I left a small clarification on the BSN formatting comment that you could address too but I don't want to block on that.
|
Please resolve merge conflicts <3 |
|
This needs an update with the recent bsn changes |
Objective
Solution
IsCheckedto the helper. (I also updated the pending Migrate3d_shapesto feathers #25436)Testing
I tested examples that use the helper and verified that they still work as expected.