✨ (pagetop): Mejora API y doc. de Children
- `From<T: Component> for ChildOp: with_child()` acepta componentes directamente sin envolverlos en `Child::with(...)`. - `From<Child> for ChildOp` para completar las conversiones implícitas. - Actualiza ejemplos y tests con la nueva API en bootsier y aliner.
This commit is contained in:
parent
f087c457cc
commit
b118b43408
27 changed files with 346 additions and 313 deletions
|
|
@ -73,17 +73,11 @@ impl Block {
|
|||
self
|
||||
}
|
||||
|
||||
/// Añade un nuevo componente hijo al bloque.
|
||||
#[inline]
|
||||
pub fn add_child(mut self, component: impl Component) -> Self {
|
||||
self.children.add(Child::with(component));
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica la lista de componentes (`children`) aplicando una operación [`ChildOp`].
|
||||
/// Añade un nuevo componente al bloque o modifica la lista de componentes (`children`) con una
|
||||
/// operación [`ChildOp`].
|
||||
#[builder_fn]
|
||||
pub fn with_child(mut self, op: ChildOp) -> Self {
|
||||
self.children.alter_child(op);
|
||||
pub fn with_child(mut self, op: impl Into<ChildOp>) -> Self {
|
||||
self.children.alter_child(op.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,10 +65,10 @@ pub enum IntroOpening {
|
|||
/// ```rust
|
||||
/// # use pagetop::prelude::*;
|
||||
/// let intro = Intro::default()
|
||||
/// .add_child(
|
||||
/// .with_child(
|
||||
/// Block::new()
|
||||
/// .with_title(L10n::l("intro_custom_block_title"))
|
||||
/// .add_child(Html::with(move |cx| {
|
||||
/// .with_child(Html::with(move |cx| {
|
||||
/// html! {
|
||||
/// p { (L10n::l("intro_custom_paragraph_1").using(cx)) }
|
||||
/// p { (L10n::l("intro_custom_paragraph_2").using(cx)) }
|
||||
|
|
@ -277,19 +277,13 @@ impl Intro {
|
|||
self
|
||||
}
|
||||
|
||||
/// Añade un nuevo componente hijo a la intro.
|
||||
/// Añade un nuevo componente a la intro o modifica la lista de componentes (`children`) con una
|
||||
/// operación [`ChildOp`].
|
||||
///
|
||||
/// Si es un bloque ([`Block`]) aplica estilos específicos para destacarlo.
|
||||
#[inline]
|
||||
pub fn add_child(mut self, component: impl Component) -> Self {
|
||||
self.children.add(Child::with(component));
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica la lista de componentes (`children`) aplicando una operación [`ChildOp`].
|
||||
/// Si se añade un bloque ([`Block`]) se aplicarán estilos específicos para destacarlo.
|
||||
#[builder_fn]
|
||||
pub fn with_child(mut self, op: ChildOp) -> Self {
|
||||
self.children.alter_child(op);
|
||||
pub fn with_child(mut self, op: impl Into<ChildOp>) -> Self {
|
||||
self.children.alter_child(op.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,22 +30,22 @@ async fn home(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
|||
|
||||
Page::new(request)
|
||||
.with_title(L10n::l("welcome_title"))
|
||||
.add_child(
|
||||
.with_child(
|
||||
Intro::new()
|
||||
.add_child(
|
||||
.with_child(
|
||||
Block::new()
|
||||
.with_title(L10n::l("welcome_status_title"))
|
||||
.add_child(Html::with(move |cx| {
|
||||
.with_child(Html::with(move |cx| {
|
||||
html! {
|
||||
p { (L10n::l("welcome_status_1").using(cx)) }
|
||||
p { (L10n::l("welcome_status_2").using(cx)) }
|
||||
}
|
||||
})),
|
||||
)
|
||||
.add_child(
|
||||
.with_child(
|
||||
Block::new()
|
||||
.with_title(L10n::l("welcome_support_title"))
|
||||
.add_child(Html::with(move |cx| {
|
||||
.with_child(Html::with(move |cx| {
|
||||
html! {
|
||||
p { (L10n::l("welcome_support_1").using(cx)) }
|
||||
p { (L10n::l("welcome_support_2").with_arg("app", app).using(cx)) }
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ impl Theme for Basic {
|
|||
))
|
||||
.alter_child_in(
|
||||
&DefaultRegion::Footer,
|
||||
ChildOp::AddIfEmpty(Child::with(PoweredBy::new())),
|
||||
ChildOp::AddIfEmpty(PoweredBy::new().into()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue