✨ Completa la API de temas con setup_component!
Elimina `action::theme` fusionando sus responsabilidades en `action::component`. Renombra `AlterMarkup` a `TransformMarkup` y `FnActionAlterMarkup` a `FnActionTransformMarkup`. Simplifica `ActionKey` y mueve los tipos de función al módulo de componente.
This commit is contained in:
parent
afd98e2c03
commit
f1d3218a68
18 changed files with 178 additions and 279 deletions
|
|
@ -14,50 +14,37 @@ mod all;
|
|||
pub(crate) use all::add_action;
|
||||
pub use all::dispatch_actions;
|
||||
|
||||
// **< actions_boxed! >*****************************************************************************
|
||||
// **< actions! >***********************************************************************************
|
||||
|
||||
/// Facilita la implementación del método [`actions()`](crate::core::extension::Extension::actions).
|
||||
///
|
||||
/// Evita escribir repetidamente `Box::new(...)` para cada acción de la lista, manteniendo el código
|
||||
/// más limpio.
|
||||
///
|
||||
/// # Ejemplos
|
||||
/// # Ejemplo
|
||||
///
|
||||
/// Acciones de tema que ajustan un componente antes y después de renderizarlo:
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// impl Extension for MyTheme {
|
||||
/// fn actions(&self) -> Vec<ActionBox> {
|
||||
/// actions_boxed![
|
||||
/// action::theme::BeforeRender::<Button>::new(&Self, before_render_button),
|
||||
/// action::theme::AfterRender::<Button>::new(&Self, after_render_button),
|
||||
/// ]
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// impl Theme for MyTheme {}
|
||||
///
|
||||
/// fn before_render_button(c: &mut Button, cx: &mut Context) { todo!() }
|
||||
/// fn after_render_button(c: &mut Button, cx: &mut Context) { todo!() }
|
||||
/// ```
|
||||
///
|
||||
/// Acción de extensión que transforma el HTML final de un componente mediante edición de texto:
|
||||
/// Extensión que ajusta un botón antes de renderizarlo y transforma su HTML final:
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// impl Extension for MyExtension {
|
||||
/// fn actions(&self) -> Vec<ActionBox> {
|
||||
/// actions_boxed![
|
||||
/// action::component::AlterMarkup::<Button>::new(alter_button_markup),
|
||||
/// actions![
|
||||
/// action::component::BeforeRender::<Button>::new(before_render_button),
|
||||
/// action::component::TransformMarkup::<Button>::new(transform_button_markup),
|
||||
/// ]
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn alter_button_markup(c: &mut Button, cx: &mut Context, markup: Markup) -> Markup {
|
||||
/// fn before_render_button(c: &mut Button, cx: &mut Context) {
|
||||
/// todo!()
|
||||
/// }
|
||||
///
|
||||
/// fn transform_button_markup(c: &Button, cx: &mut Context, markup: Markup) -> Markup {
|
||||
/// todo!()
|
||||
/// }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! actions_boxed {
|
||||
macro_rules! actions {
|
||||
() => {
|
||||
Vec::<ActionBox>::new()
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue