-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow components to accept children elements #589
Conversation
That's very important change! Thank you! 👍 |
1993a99
to
a6c88a1
Compare
2609c95
to
0e78f7a
Compare
@hgzimmerman could you please review this when you have time? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have extensive experience in writing (or reading for that matter) macros in Rust, which makes up the majority of the delicate parts of this PR. Given my limited understanding, I didn't see anything suspect.
I thought that the code involving Variants
in the nested_list example is really clever and cool, but exceptionally non-obvious to someone who hasn't seen that pattern before. I didn't think you could have different child components before seeing this. When a guide/book is written, some special attention will need to be given towards this feature.
Thanks for implementing this feature!
@hgzimmerman yes, totally agreed about the complexity with the |
It would be great if Example: impl MenuItem {
fn render_caret(&self) -> Html<Self> {
if self.props.children.is_empty() {
html! {}
} else {
html! {
<b class="caret"></b>
}
}
}
} |
@gtors done! |
bors r+ |
589: Allow components to accept children elements r=jstarry a=jstarry Fixes: #537 #### Terminology - (B) Base component that renders components nested inside each other - (P) Parent component that has a `children` property and can render those children - (C) Child component that is nested inside parent and included inside the Parent's `children` #### Todo - [x] Add example for nested components - [x] Support arbitrary html nested inside component tags - [x] Support nested components inside component tags - [x] Allow modifying & accessing (C) props when rendering (P) - [x] Allow filtering (C) components when rendering (P) - [x] Children prop be required or optional - [x] Clean up nested component example - [x] Fix parser for generic component type - [x] Write tests - [x] Update documentation and README - [x] ~~Investigate passing required properties from (P) -> (C)~~ - [x] ~~Allow sending messages from (C) -> (B)~~ Co-authored-by: Justin Starry <[email protected]>
Build succeeded
|
Fixes: #537
Terminology
children
property and can render those childrenchildren
Todo
Investigate passing required properties from (P) -> (C)Allow sending messages from (C) -> (B)