-
-
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
Nested Components #128
Comments
Hi, @nixpulvis! Sorry for the delay, I have a crazy work schedule )
I've found there are two issues about the impl Renderable<Context, Self> for Navigation {
fn view(&self) -> Html<Context, Self> {
let render = |link: &Link| html! {
<li>{ link.view() }</li>
};
html! {
<ul>
{ for self.links.iter().map(render) }
</ul>
}
}
}
impl<T> Renderable<Context, T> for Link
where
T: Component<Context>,
{
fn view(&self) -> Html<Context, T> {
html!{
<a href=self.path.to_owned(),>{ &self.title }</a>
}
}
} Why it's important. Because you could want to have a component which renders in different ways when it laid inside different type parents. Example: impl Renderable<Context, VerticalNavigation> for Link
{
fn view(&self) -> Html<Context, T> { ... }
}
impl Renderable<Context, HorizontalNavigation> for Link
{
fn view(&self) -> Html<Context, T> { ... }
} Or you could want to use link for both: impl Renderable<Context, Navigation> for Link
{
fn view(&self) -> Html<Context, Navigation> {
html!{
<li>
<a href=self.path.to_owned(),>{ &self.title }</a>
</li>
}
}
}
impl Renderable<Context, Model> for Link
{
fn view(&self) -> Html<Context, Model> {
html!{
<a href=self.path.to_owned(),>{ &self.title }</a>
}
}
} Link doesn't even have to be a
I continue to improve the framework and I planned to support children of components in templates. It will help to resolve this issue simpler. |
As in the game of life example, I try to implement a impl Renderable<Model> for Cellule {
fn view(&self) -> Html<Model> {
let life_status = if self.alive() { "cellule-live" } else { "cellule-dead" };
html! {
<div class=("game-cellule", life_status),
onclick=|_| CellMsg::Toggle,> </div>
}
}
} In this example where
And I think when we implement a view of an component for other component, it should allow us to use its |
Components have been nestable for awhile now |
Pardon this issue if this is possible, and I just don't know what I'm doing.
I'm trying to setup the following set of components.
I've been playing around with various modifications to this basic outline, and I can't seem to find anything that makes sense and works. Two main issues seem to crop up.
create
constructor to actually get an instance of theLink
, since it requires anEnv
specific to it.Sorry if this isn't super clear, I'm happy to provide more information as to my use case.
The text was updated successfully, but these errors were encountered: