🏷️ Simplifica nombres de traits esenciales
Los traits `ExtensionTrait`, `ThemeTrait` y `ComponentTrait` pasan a ser `Extension`, `Theme`y `Component`, respectivamente,
This commit is contained in:
parent
ac0889cb8c
commit
bf3ea43b53
23 changed files with 78 additions and 79 deletions
|
@ -3,7 +3,7 @@ use crate::prelude::*;
|
|||
use crate::base::action::FnActionWithComponent;
|
||||
|
||||
/// Ejecuta [`FnActionWithComponent`] después de renderizar un componente.
|
||||
pub struct AfterRender<C: ComponentTrait> {
|
||||
pub struct AfterRender<C: Component> {
|
||||
f: FnActionWithComponent<C>,
|
||||
referer_type_id: Option<UniqueId>,
|
||||
referer_id: OptionId,
|
||||
|
@ -11,7 +11,7 @@ pub struct AfterRender<C: ComponentTrait> {
|
|||
}
|
||||
|
||||
/// Filtro para despachar [`FnActionWithComponent`] después de renderizar un componente `C`.
|
||||
impl<C: ComponentTrait> ActionDispatcher for AfterRender<C> {
|
||||
impl<C: Component> ActionDispatcher for AfterRender<C> {
|
||||
/// Devuelve el identificador de tipo ([`UniqueId`]) del componente `C`.
|
||||
fn referer_type_id(&self) -> Option<UniqueId> {
|
||||
self.referer_type_id
|
||||
|
@ -28,8 +28,8 @@ impl<C: ComponentTrait> ActionDispatcher for AfterRender<C> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<C: ComponentTrait> AfterRender<C> {
|
||||
/// Permite [registrar](ExtensionTrait::actions) una nueva acción [`FnActionWithComponent`].
|
||||
impl<C: Component> AfterRender<C> {
|
||||
/// Permite [registrar](Extension::actions) una nueva acción [`FnActionWithComponent`].
|
||||
pub fn new(f: FnActionWithComponent<C>) -> Self {
|
||||
AfterRender {
|
||||
f,
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::prelude::*;
|
|||
use crate::base::action::FnActionWithComponent;
|
||||
|
||||
/// Ejecuta [`FnActionWithComponent`] antes de renderizar el componente.
|
||||
pub struct BeforeRender<C: ComponentTrait> {
|
||||
pub struct BeforeRender<C: Component> {
|
||||
f: FnActionWithComponent<C>,
|
||||
referer_type_id: Option<UniqueId>,
|
||||
referer_id: OptionId,
|
||||
|
@ -11,7 +11,7 @@ pub struct BeforeRender<C: ComponentTrait> {
|
|||
}
|
||||
|
||||
/// Filtro para despachar [`FnActionWithComponent`] antes de renderizar un componente `C`.
|
||||
impl<C: ComponentTrait> ActionDispatcher for BeforeRender<C> {
|
||||
impl<C: Component> ActionDispatcher for BeforeRender<C> {
|
||||
/// Devuelve el identificador de tipo ([`UniqueId`]) del componente `C`.
|
||||
fn referer_type_id(&self) -> Option<UniqueId> {
|
||||
self.referer_type_id
|
||||
|
@ -28,8 +28,8 @@ impl<C: ComponentTrait> ActionDispatcher for BeforeRender<C> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<C: ComponentTrait> BeforeRender<C> {
|
||||
/// Permite [registrar](ExtensionTrait::actions) una nueva acción [`FnActionWithComponent`].
|
||||
impl<C: Component> BeforeRender<C> {
|
||||
/// Permite [registrar](Extension::actions) una nueva acción [`FnActionWithComponent`].
|
||||
pub fn new(f: FnActionWithComponent<C>) -> Self {
|
||||
BeforeRender {
|
||||
f,
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::prelude::*;
|
|||
pub type FnIsRenderable<C> = fn(component: &C, cx: &Context) -> bool;
|
||||
|
||||
/// Con la función [`FnIsRenderable`] se puede decidir si se renderiza o no un componente.
|
||||
pub struct IsRenderable<C: ComponentTrait> {
|
||||
pub struct IsRenderable<C: Component> {
|
||||
f: FnIsRenderable<C>,
|
||||
referer_type_id: Option<UniqueId>,
|
||||
referer_id: OptionId,
|
||||
|
@ -16,7 +16,7 @@ pub struct IsRenderable<C: ComponentTrait> {
|
|||
}
|
||||
|
||||
/// Filtro para despachar [`FnIsRenderable`] para decidir si se renderiza o no un componente `C`.
|
||||
impl<C: ComponentTrait> ActionDispatcher for IsRenderable<C> {
|
||||
impl<C: Component> ActionDispatcher for IsRenderable<C> {
|
||||
/// Devuelve el identificador de tipo ([`UniqueId`]) del componente `C`.
|
||||
fn referer_type_id(&self) -> Option<UniqueId> {
|
||||
self.referer_type_id
|
||||
|
@ -33,8 +33,8 @@ impl<C: ComponentTrait> ActionDispatcher for IsRenderable<C> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<C: ComponentTrait> IsRenderable<C> {
|
||||
/// Permite [registrar](ExtensionTrait::actions) una nueva acción [`FnIsRenderable`].
|
||||
impl<C: Component> IsRenderable<C> {
|
||||
/// Permite [registrar](Extension::actions) una nueva acción [`FnIsRenderable`].
|
||||
pub fn new(f: FnIsRenderable<C>) -> Self {
|
||||
IsRenderable {
|
||||
f,
|
||||
|
|
|
@ -22,7 +22,7 @@ impl ActionDispatcher for AfterRenderBody {
|
|||
}
|
||||
|
||||
impl AfterRenderBody {
|
||||
/// Permite [registrar](ExtensionTrait::actions) una nueva acción
|
||||
/// Permite [registrar](Extension::actions) una nueva acción
|
||||
/// [`FnActionWithPage`](crate::base::action::page::FnActionWithPage).
|
||||
pub fn new(f: FnActionWithPage) -> Self {
|
||||
AfterRenderBody { f, weight: 0 }
|
||||
|
|
|
@ -22,7 +22,7 @@ impl ActionDispatcher for BeforeRenderBody {
|
|||
}
|
||||
|
||||
impl BeforeRenderBody {
|
||||
/// Permite [registrar](ExtensionTrait::actions) una nueva acción
|
||||
/// Permite [registrar](Extension::actions) una nueva acción
|
||||
/// [`FnActionWithPage`](crate::base::action::page::FnActionWithPage).
|
||||
pub fn new(f: FnActionWithPage) -> Self {
|
||||
BeforeRenderBody { f, weight: 0 }
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::prelude::*;
|
|||
use crate::base::action::FnActionWithComponent;
|
||||
|
||||
/// Ejecuta [`FnActionWithComponent`] después de que un tema renderice el componente.
|
||||
pub struct AfterRender<C: ComponentTrait> {
|
||||
pub struct AfterRender<C: Component> {
|
||||
f: FnActionWithComponent<C>,
|
||||
theme_type_id: Option<UniqueId>,
|
||||
referer_type_id: Option<UniqueId>,
|
||||
|
@ -11,7 +11,7 @@ pub struct AfterRender<C: ComponentTrait> {
|
|||
|
||||
/// Filtro para despachar [`FnActionWithComponent`] después de que un tema renderice el componente
|
||||
/// `C`.
|
||||
impl<C: ComponentTrait> ActionDispatcher for AfterRender<C> {
|
||||
impl<C: Component> ActionDispatcher for AfterRender<C> {
|
||||
/// Devuelve el identificador de tipo ([`UniqueId`]) del tema.
|
||||
fn theme_type_id(&self) -> Option<UniqueId> {
|
||||
self.theme_type_id
|
||||
|
@ -23,9 +23,9 @@ impl<C: ComponentTrait> ActionDispatcher for AfterRender<C> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<C: ComponentTrait> AfterRender<C> {
|
||||
/// Permite [registrar](ExtensionTrait::actions) una nueva acción [`FnActionWithComponent`] para
|
||||
/// un tema dado.
|
||||
impl<C: Component> AfterRender<C> {
|
||||
/// Permite [registrar](Extension::actions) una nueva acción [`FnActionWithComponent`] para un
|
||||
/// tema dado.
|
||||
pub fn new(theme: ThemeRef, f: FnActionWithComponent<C>) -> Self {
|
||||
AfterRender {
|
||||
f,
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::prelude::*;
|
|||
use crate::base::action::FnActionWithComponent;
|
||||
|
||||
/// Ejecuta [`FnActionWithComponent`] antes de que un tema renderice el componente.
|
||||
pub struct BeforeRender<C: ComponentTrait> {
|
||||
pub struct BeforeRender<C: Component> {
|
||||
f: FnActionWithComponent<C>,
|
||||
theme_type_id: Option<UniqueId>,
|
||||
referer_type_id: Option<UniqueId>,
|
||||
|
@ -11,7 +11,7 @@ pub struct BeforeRender<C: ComponentTrait> {
|
|||
|
||||
/// Filtro para despachar [`FnActionWithComponent`] antes de que un tema renderice el componente
|
||||
/// `C`.
|
||||
impl<C: ComponentTrait> ActionDispatcher for BeforeRender<C> {
|
||||
impl<C: Component> ActionDispatcher for BeforeRender<C> {
|
||||
/// Devuelve el identificador de tipo ([`UniqueId`]) del tema.
|
||||
fn theme_type_id(&self) -> Option<UniqueId> {
|
||||
self.theme_type_id
|
||||
|
@ -23,9 +23,9 @@ impl<C: ComponentTrait> ActionDispatcher for BeforeRender<C> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<C: ComponentTrait> BeforeRender<C> {
|
||||
/// Permite [registrar](ExtensionTrait::actions) una nueva acción [`FnActionWithComponent`] para
|
||||
/// un tema dado.
|
||||
impl<C: Component> BeforeRender<C> {
|
||||
/// Permite [registrar](Extension::actions) una nueva acción [`FnActionWithComponent`] para un
|
||||
/// tema dado.
|
||||
pub fn new(theme: ThemeRef, f: FnActionWithComponent<C>) -> Self {
|
||||
BeforeRender {
|
||||
f,
|
||||
|
|
|
@ -11,14 +11,14 @@ pub type FnPrepareRender<C> = fn(component: &C, cx: &mut Context) -> PrepareMark
|
|||
/// Ejecuta [`FnPrepareRender`] para preparar el renderizado de un componente.
|
||||
///
|
||||
/// Permite a un tema hacer una implementación nueva del renderizado de un componente.
|
||||
pub struct PrepareRender<C: ComponentTrait> {
|
||||
pub struct PrepareRender<C: Component> {
|
||||
f: FnPrepareRender<C>,
|
||||
theme_type_id: Option<UniqueId>,
|
||||
referer_type_id: Option<UniqueId>,
|
||||
}
|
||||
|
||||
/// Filtro para despachar [`FnPrepareRender`] que modifica el renderizado de un componente `C`.
|
||||
impl<C: ComponentTrait> ActionDispatcher for PrepareRender<C> {
|
||||
impl<C: Component> ActionDispatcher for PrepareRender<C> {
|
||||
/// Devuelve el identificador de tipo ([`UniqueId`]) del tema.
|
||||
fn theme_type_id(&self) -> Option<UniqueId> {
|
||||
self.theme_type_id
|
||||
|
@ -30,9 +30,9 @@ impl<C: ComponentTrait> ActionDispatcher for PrepareRender<C> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<C: ComponentTrait> PrepareRender<C> {
|
||||
/// Permite [registrar](ExtensionTrait::actions) una nueva acción [`FnPrepareRender`] para un
|
||||
/// tema dado.
|
||||
impl<C: Component> PrepareRender<C> {
|
||||
/// Permite [registrar](Extension::actions) una nueva acción [`FnPrepareRender`] para un tema
|
||||
/// dado.
|
||||
pub fn new(theme: ThemeRef, f: FnPrepareRender<C>) -> Self {
|
||||
PrepareRender {
|
||||
f,
|
||||
|
|
|
@ -38,7 +38,7 @@ impl Default for Html {
|
|||
Html::with(|_| html! {})
|
||||
}
|
||||
}
|
||||
impl ComponentTrait for Html {
|
||||
impl Component for Html {
|
||||
fn new() -> Self {
|
||||
Html::default()
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::prelude::*;
|
|||
/// funcionando correctamente.
|
||||
pub struct Welcome;
|
||||
|
||||
impl ExtensionTrait for Welcome {
|
||||
impl Extension for Welcome {
|
||||
fn name(&self) -> L10n {
|
||||
L10n::l("welcome_extension_name")
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ use crate::prelude::*;
|
|||
/// Tema básico por defecto.
|
||||
pub struct Basic;
|
||||
|
||||
impl ExtensionTrait for Basic {
|
||||
impl Extension for Basic {
|
||||
fn theme(&self) -> Option<ThemeRef> {
|
||||
Some(&Self)
|
||||
}
|
||||
}
|
||||
|
||||
impl ThemeTrait for Basic {
|
||||
impl Theme for Basic {
|
||||
fn after_render_page_body(&self, page: &mut Page) {
|
||||
page.alter_assets(AssetsOp::AddStyleSheet(
|
||||
StyleSheet::from("/css/normalize.css")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue