🚚 Renombra add_component por add_child
This commit is contained in:
parent
180cb9c2f6
commit
769eb384e4
12 changed files with 31 additions and 32 deletions
|
|
@ -25,7 +25,7 @@ internos pueden omitirse si no afectan al uso del proyecto.
|
||||||
- [context] Generaliza los parámetros de contexto
|
- [context] Generaliza los parámetros de contexto
|
||||||
- [context] Define un `trait` común de contexto
|
- [context] Define un `trait` común de contexto
|
||||||
- Modifica tipos para atributos HTML a minúsculas
|
- Modifica tipos para atributos HTML a minúsculas
|
||||||
- Renombra `with_component` por `add_component`
|
- Renombra `with_component` por `add_child`
|
||||||
|
|
||||||
### Corregido
|
### Corregido
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ impl Extension for HelloWorld {
|
||||||
|
|
||||||
async fn hello_world(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
async fn hello_world(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
.add_component(Html::with(move |_| html! { h1 { "Hello World!" } }))
|
.add_child(Html::with(|_| html! { h1 { "Hello World!" } }))
|
||||||
.render()
|
.render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ async fn hello_name(
|
||||||
) -> ResultPage<Markup, ErrorPage> {
|
) -> ResultPage<Markup, ErrorPage> {
|
||||||
let name = path.into_inner();
|
let name = path.into_inner();
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
.add_component(Html::with(move |_| html! { h1 { "Hello " (name) "!" } }))
|
.add_child(Html::with(move |_| html! { h1 { "Hello " (name) "!" } }))
|
||||||
.render()
|
.render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ impl Extension for HelloWorld {
|
||||||
|
|
||||||
async fn hello_world(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
async fn hello_world(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
.add_component(Html::with(move |_| html! { h1 { "Hello World!" } }))
|
.add_child(Html::with(|_| html! { h1 { "Hello World!" } }))
|
||||||
.render()
|
.render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,10 +67,10 @@ use pagetop::prelude::*;
|
||||||
async fn homepage(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
async fn homepage(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
.with_theme("Aliner")
|
.with_theme("Aliner")
|
||||||
.add_component(
|
.add_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::l("sample_title"))
|
.with_title(L10n::l("sample_title"))
|
||||||
.add_component(Html::with(|cx| html! {
|
.add_child(Html::with(|cx| html! {
|
||||||
p { (L10n::l("sample_content").using(cx)) }
|
p { (L10n::l("sample_content").using(cx)) }
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,10 @@ use pagetop::prelude::*;
|
||||||
async fn homepage(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
async fn homepage(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
.with_theme("Aliner")
|
.with_theme("Aliner")
|
||||||
.add_component(
|
.add_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::l("sample_title"))
|
.with_title(L10n::l("sample_title"))
|
||||||
.add_component(Html::with(|cx| html! {
|
.add_child(Html::with(|cx| html! {
|
||||||
p { (L10n::l("sample_content").using(cx)) }
|
p { (L10n::l("sample_content").using(cx)) }
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ impl Block {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Añade un nuevo componente hijo al bloque.
|
/// Añade un nuevo componente hijo al bloque.
|
||||||
pub fn add_component(mut self, component: impl Component) -> Self {
|
pub fn add_child(mut self, component: impl Component) -> Self {
|
||||||
self.children
|
self.children
|
||||||
.alter_child(ChildOp::Add(Child::with(component)));
|
.alter_child(ChildOp::Add(Child::with(component)));
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -65,10 +65,10 @@ pub enum IntroOpening {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use pagetop::prelude::*;
|
/// # use pagetop::prelude::*;
|
||||||
/// let intro = Intro::default()
|
/// let intro = Intro::default()
|
||||||
/// .add_component(
|
/// .add_child(
|
||||||
/// Block::new()
|
/// Block::new()
|
||||||
/// .with_title(L10n::l("intro_custom_block_title"))
|
/// .with_title(L10n::l("intro_custom_block_title"))
|
||||||
/// .add_component(Html::with(move |cx| {
|
/// .add_child(Html::with(move |cx| {
|
||||||
/// html! {
|
/// html! {
|
||||||
/// p { (L10n::l("intro_custom_paragraph_1").using(cx)) }
|
/// p { (L10n::l("intro_custom_paragraph_1").using(cx)) }
|
||||||
/// p { (L10n::l("intro_custom_paragraph_2").using(cx)) }
|
/// p { (L10n::l("intro_custom_paragraph_2").using(cx)) }
|
||||||
|
|
@ -301,7 +301,7 @@ impl Intro {
|
||||||
/// Añade un nuevo componente hijo a la intro.
|
/// Añade un nuevo componente hijo a la intro.
|
||||||
///
|
///
|
||||||
/// Si es un bloque ([`Block`]) aplica estilos específicos para destacarlo.
|
/// Si es un bloque ([`Block`]) aplica estilos específicos para destacarlo.
|
||||||
pub fn add_component(mut self, component: impl Component) -> Self {
|
pub fn add_child(mut self, component: impl Component) -> Self {
|
||||||
self.children
|
self.children
|
||||||
.alter_child(ChildOp::Add(Child::with(component)));
|
.alter_child(ChildOp::Add(Child::with(component)));
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -26,22 +26,22 @@ async fn homepage(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
||||||
|
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
.with_title(L10n::l("welcome_title"))
|
.with_title(L10n::l("welcome_title"))
|
||||||
.add_component(
|
.add_child(
|
||||||
Intro::new()
|
Intro::new()
|
||||||
.add_component(
|
.add_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::l("welcome_status_title"))
|
.with_title(L10n::l("welcome_status_title"))
|
||||||
.add_component(Html::with(move |cx| {
|
.add_child(Html::with(move |cx| {
|
||||||
html! {
|
html! {
|
||||||
p { (L10n::l("welcome_status_1").using(cx)) }
|
p { (L10n::l("welcome_status_1").using(cx)) }
|
||||||
p { (L10n::l("welcome_status_2").using(cx)) }
|
p { (L10n::l("welcome_status_2").using(cx)) }
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.add_component(
|
.add_child(
|
||||||
Block::new()
|
Block::new()
|
||||||
.with_title(L10n::l("welcome_support_title"))
|
.with_title(L10n::l("welcome_support_title"))
|
||||||
.add_component(Html::with(move |cx| {
|
.add_child(Html::with(move |cx| {
|
||||||
html! {
|
html! {
|
||||||
p { (L10n::l("welcome_support_1").using(cx)) }
|
p { (L10n::l("welcome_support_1").using(cx)) }
|
||||||
p { (L10n::l("welcome_support_2").with_arg("app", app).using(cx)) }
|
p { (L10n::l("welcome_support_2").with_arg("app", app).using(cx)) }
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ impl Extension for HelloWorld {
|
||||||
|
|
||||||
async fn hello_world(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
async fn hello_world(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
.add_component(Html::with(move |_| html! { h1 { "Hello World!" } }))
|
.add_child(Html::with(|_| html! { h1 { "Hello World!" } }))
|
||||||
.render()
|
.render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,29 +93,28 @@ impl Page {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// **Obsoleto desde la versión 0.4.0**: usar [`add_component()`](Self::add_component) en su
|
/// **Obsoleto desde la versión 0.4.0**: usar [`add_child()`](Self::add_child) en su lugar.
|
||||||
/// lugar.
|
#[deprecated(since = "0.4.0", note = "Use `add_child()` instead")]
|
||||||
#[deprecated(since = "0.4.0", note = "Use `add_component()` instead")]
|
|
||||||
pub fn with_component(self, component: impl Component) -> Self {
|
pub fn with_component(self, component: impl Component) -> Self {
|
||||||
self.add_component(component)
|
self.add_child(component)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// **Obsoleto desde la versión 0.4.0**: usar [`add_component_in()`](Self::add_component_in) en
|
/// **Obsoleto desde la versión 0.4.0**: usar [`add_child_in()`](Self::add_child_in) en su
|
||||||
/// su lugar.
|
/// lugar.
|
||||||
#[deprecated(since = "0.4.0", note = "Use `add_component_in()` instead")]
|
#[deprecated(since = "0.4.0", note = "Use `add_child_in()` instead")]
|
||||||
pub fn with_component_in(self, region_key: &'static str, component: impl Component) -> Self {
|
pub fn with_component_in(self, region_key: &'static str, component: impl Component) -> Self {
|
||||||
self.add_component_in(region_key, component)
|
self.add_child_in(region_key, component)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Añade un componente a la región de contenido por defecto.
|
/// Añade un componente hijo a la región de contenido por defecto.
|
||||||
pub fn add_component(mut self, component: impl Component) -> Self {
|
pub fn add_child(mut self, component: impl Component) -> Self {
|
||||||
self.context
|
self.context
|
||||||
.alter_child_in(REGION_CONTENT, ChildOp::Add(Child::with(component)));
|
.alter_child_in(REGION_CONTENT, ChildOp::Add(Child::with(component)));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Añade un componente en una región (`region_key`) de la página.
|
/// Añade un componente hijo en una región (`region_key`) de la página.
|
||||||
pub fn add_component_in(mut self, region_key: &'static str, component: impl Component) -> Self {
|
pub fn add_child_in(mut self, region_key: &'static str, component: impl Component) -> Self {
|
||||||
self.context
|
self.context
|
||||||
.alter_child_in(region_key, ChildOp::Add(Child::with(component)));
|
.alter_child_in(region_key, ChildOp::Add(Child::with(component)));
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ impl Display for ErrorPage {
|
||||||
if let Ok(page) = error_page
|
if let Ok(page) = error_page
|
||||||
.with_title(L10n::n("Error FORBIDDEN"))
|
.with_title(L10n::n("Error FORBIDDEN"))
|
||||||
.with_layout("error")
|
.with_layout("error")
|
||||||
.add_component(Html::with(move |_| error403.clone()))
|
.add_child(Html::with(move |_| error403.clone()))
|
||||||
.render()
|
.render()
|
||||||
{
|
{
|
||||||
write!(f, "{}", page.into_string())
|
write!(f, "{}", page.into_string())
|
||||||
|
|
@ -49,7 +49,7 @@ impl Display for ErrorPage {
|
||||||
if let Ok(page) = error_page
|
if let Ok(page) = error_page
|
||||||
.with_title(L10n::n("Error RESOURCE NOT FOUND"))
|
.with_title(L10n::n("Error RESOURCE NOT FOUND"))
|
||||||
.with_layout("error")
|
.with_layout("error")
|
||||||
.add_component(Html::with(move |_| error404.clone()))
|
.add_child(Html::with(move |_| error404.clone()))
|
||||||
.render()
|
.render()
|
||||||
{
|
{
|
||||||
write!(f, "{}", page.into_string())
|
write!(f, "{}", page.into_string())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue