✨ Implementa Debug en comp./tipos principales
This commit is contained in:
parent
c3feff9efd
commit
a0b14aec36
21 changed files with 61 additions and 32 deletions
|
|
@ -6,7 +6,7 @@ use crate::prelude::*;
|
||||||
///
|
///
|
||||||
/// Envuelve un contenido con la etiqueta HTML indicada por [`container::Kind`]. Sólo se renderiza
|
/// Envuelve un contenido con la etiqueta HTML indicada por [`container::Kind`]. Sólo se renderiza
|
||||||
/// si existen componentes hijos (*children*).
|
/// si existen componentes hijos (*children*).
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Container {
|
pub struct Container {
|
||||||
#[getters(skip)]
|
#[getters(skip)]
|
||||||
id: AttrId,
|
id: AttrId,
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use crate::LOCALES_BOOTSIER;
|
||||||
///
|
///
|
||||||
/// Ver ejemplo en el módulo [`dropdown`].
|
/// Ver ejemplo en el módulo [`dropdown`].
|
||||||
/// Si no contiene elementos, el componente **no se renderiza**.
|
/// Si no contiene elementos, el componente **no se renderiza**.
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Dropdown {
|
pub struct Dropdown {
|
||||||
#[getters(skip)]
|
#[getters(skip)]
|
||||||
id: AttrId,
|
id: AttrId,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use pagetop::prelude::*;
|
||||||
///
|
///
|
||||||
/// Define internamente la naturaleza del elemento y su comportamiento al mostrarse o interactuar
|
/// Define internamente la naturaleza del elemento y su comportamiento al mostrarse o interactuar
|
||||||
/// con él.
|
/// con él.
|
||||||
#[derive(AutoDefault)]
|
#[derive(AutoDefault, Debug)]
|
||||||
pub enum ItemKind {
|
pub enum ItemKind {
|
||||||
/// Elemento vacío, no produce salida.
|
/// Elemento vacío, no produce salida.
|
||||||
#[default]
|
#[default]
|
||||||
|
|
@ -43,7 +43,7 @@ pub enum ItemKind {
|
||||||
///
|
///
|
||||||
/// Permite definir el identificador, las clases de estilo adicionales y el tipo de interacción
|
/// Permite definir el identificador, las clases de estilo adicionales y el tipo de interacción
|
||||||
/// asociada, manteniendo una interfaz común para renderizar todos los elementos del menú.
|
/// asociada, manteniendo una interfaz común para renderizar todos los elementos del menú.
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Item {
|
pub struct Item {
|
||||||
#[getters(skip)]
|
#[getters(skip)]
|
||||||
id: AttrId,
|
id: AttrId,
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ use crate::theme::form;
|
||||||
/// .with_classes(ClassesOp::Add, "mb-3")
|
/// .with_classes(ClassesOp::Add, "mb-3")
|
||||||
/// .add_child(Input::new().with_name("q"));
|
/// .add_child(Input::new().with_name("q"));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Form {
|
pub struct Form {
|
||||||
#[getters(skip)]
|
#[getters(skip)]
|
||||||
id: AttrId,
|
id: AttrId,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use pagetop::prelude::*;
|
||||||
/// Agrupa controles relacionados de un formulario (`<fieldset>`).
|
/// Agrupa controles relacionados de un formulario (`<fieldset>`).
|
||||||
///
|
///
|
||||||
/// Se usa para mejorar la accesibilidad cuando se acompaña de una leyenda que encabeza el grupo.
|
/// Se usa para mejorar la accesibilidad cuando se acompaña de una leyenda que encabeza el grupo.
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Fieldset {
|
pub struct Fieldset {
|
||||||
#[getters(skip)]
|
#[getters(skip)]
|
||||||
id: AttrId,
|
id: AttrId,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use pagetop::prelude::*;
|
||||||
use crate::theme::form;
|
use crate::theme::form;
|
||||||
use crate::LOCALES_BOOTSIER;
|
use crate::LOCALES_BOOTSIER;
|
||||||
|
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Input {
|
pub struct Input {
|
||||||
classes: Classes,
|
classes: Classes,
|
||||||
input_type: form::InputType,
|
input_type: form::InputType,
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ pub enum IconKind {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Icon {
|
pub struct Icon {
|
||||||
/// Devuelve las clases CSS asociadas al icono.
|
/// Devuelve las clases CSS asociadas al icono.
|
||||||
classes: Classes,
|
classes: Classes,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use crate::prelude::*;
|
||||||
/// ([`classes::Border`](crate::theme::classes::Border)) y **redondeo de esquinas**
|
/// ([`classes::Border`](crate::theme::classes::Border)) y **redondeo de esquinas**
|
||||||
/// ([`classes::Rounded`](crate::theme::classes::Rounded)).
|
/// ([`classes::Rounded`](crate::theme::classes::Rounded)).
|
||||||
/// - Resuelve el texto alternativo `alt` con **localización** mediante [`L10n`].
|
/// - Resuelve el texto alternativo `alt` con **localización** mediante [`L10n`].
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Image {
|
pub struct Image {
|
||||||
#[getters(skip)]
|
#[getters(skip)]
|
||||||
id: AttrId,
|
id: AttrId,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use crate::prelude::*;
|
||||||
///
|
///
|
||||||
/// Ver ejemplo en el módulo [`nav`].
|
/// Ver ejemplo en el módulo [`nav`].
|
||||||
/// Si no contiene elementos, el componente **no se renderiza**.
|
/// Si no contiene elementos, el componente **no se renderiza**.
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Nav {
|
pub struct Nav {
|
||||||
#[getters(skip)]
|
#[getters(skip)]
|
||||||
id: AttrId,
|
id: AttrId,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use crate::LOCALES_BOOTSIER;
|
||||||
///
|
///
|
||||||
/// Define internamente la naturaleza del elemento y su comportamiento al mostrarse o interactuar
|
/// Define internamente la naturaleza del elemento y su comportamiento al mostrarse o interactuar
|
||||||
/// con él.
|
/// con él.
|
||||||
#[derive(AutoDefault)]
|
#[derive(AutoDefault, Debug)]
|
||||||
pub enum ItemKind {
|
pub enum ItemKind {
|
||||||
/// Elemento vacío, no produce salida.
|
/// Elemento vacío, no produce salida.
|
||||||
#[default]
|
#[default]
|
||||||
|
|
@ -76,7 +76,7 @@ impl ItemKind {
|
||||||
///
|
///
|
||||||
/// Permite definir el identificador, las clases de estilo adicionales y el tipo de interacción
|
/// Permite definir el identificador, las clases de estilo adicionales y el tipo de interacción
|
||||||
/// asociada, manteniendo una interfaz común para renderizar todos los elementos del menú.
|
/// asociada, manteniendo una interfaz común para renderizar todos los elementos del menú.
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Item {
|
pub struct Item {
|
||||||
#[getters(skip)]
|
#[getters(skip)]
|
||||||
id: AttrId,
|
id: AttrId,
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use crate::prelude::*;
|
||||||
/// - Si no hay imagen ([`with_image()`](Self::with_image)) ni título
|
/// - Si no hay imagen ([`with_image()`](Self::with_image)) ni título
|
||||||
/// ([`with_title()`](Self::with_title)), la marca de identidad no se renderiza.
|
/// ([`with_title()`](Self::with_title)), la marca de identidad no se renderiza.
|
||||||
/// - El eslogan ([`with_slogan()`](Self::with_slogan)) es opcional; por defecto no tiene contenido.
|
/// - El eslogan ([`with_slogan()`](Self::with_slogan)) es opcional; por defecto no tiene contenido.
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Brand {
|
pub struct Brand {
|
||||||
#[getters(skip)]
|
#[getters(skip)]
|
||||||
id: AttrId,
|
id: AttrId,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ const TOGGLE_OFFCANVAS: &str = "offcanvas";
|
||||||
///
|
///
|
||||||
/// Ver ejemplos en el módulo [`navbar`].
|
/// Ver ejemplos en el módulo [`navbar`].
|
||||||
/// Si no contiene elementos, el componente **no se renderiza**.
|
/// Si no contiene elementos, el componente **no se renderiza**.
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Navbar {
|
pub struct Navbar {
|
||||||
#[getters(skip)]
|
#[getters(skip)]
|
||||||
id: AttrId,
|
id: AttrId,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use crate::prelude::*;
|
||||||
/// Cada variante determina qué se renderiza y cómo. Estos elementos se colocan **dentro del
|
/// Cada variante determina qué se renderiza y cómo. Estos elementos se colocan **dentro del
|
||||||
/// contenido** de la barra (la parte colapsable, el *offcanvas* o el bloque simple), por lo que son
|
/// contenido** de la barra (la parte colapsable, el *offcanvas* o el bloque simple), por lo que son
|
||||||
/// independientes de la marca o del botón que ya pueda definir el propio [`navbar::Layout`].
|
/// independientes de la marca o del botón que ya pueda definir el propio [`navbar::Layout`].
|
||||||
#[derive(AutoDefault)]
|
#[derive(AutoDefault, Debug)]
|
||||||
pub enum Item {
|
pub enum Item {
|
||||||
/// Sin contenido, no produce salida.
|
/// Sin contenido, no produce salida.
|
||||||
#[default]
|
#[default]
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::prelude::*;
|
||||||
// **< Layout >*************************************************************************************
|
// **< Layout >*************************************************************************************
|
||||||
|
|
||||||
/// Representa los diferentes tipos de presentación de una barra de navegación [`Navbar`].
|
/// Representa los diferentes tipos de presentación de una barra de navegación [`Navbar`].
|
||||||
#[derive(AutoDefault)]
|
#[derive(AutoDefault, Debug)]
|
||||||
pub enum Layout {
|
pub enum Layout {
|
||||||
/// Barra simple, sin marca de identidad y sin botón de despliegue.
|
/// Barra simple, sin marca de identidad y sin botón de despliegue.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ use crate::LOCALES_BOOTSIER;
|
||||||
///
|
///
|
||||||
/// Ver ejemplo en el módulo [`offcanvas`].
|
/// Ver ejemplo en el módulo [`offcanvas`].
|
||||||
/// Si no contiene elementos, el componente **no se renderiza**.
|
/// Si no contiene elementos, el componente **no se renderiza**.
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Offcanvas {
|
pub struct Offcanvas {
|
||||||
#[getters(skip)]
|
#[getters(skip)]
|
||||||
id: AttrId,
|
id: AttrId,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::prelude::*;
|
||||||
///
|
///
|
||||||
/// Los bloques se utilizan como contenedores de otros componentes o contenidos, con un título
|
/// Los bloques se utilizan como contenedores de otros componentes o contenidos, con un título
|
||||||
/// opcional y un cuerpo que sólo se renderiza si existen componentes hijos (*children*).
|
/// opcional y un cuerpo que sólo se renderiza si existen componentes hijos (*children*).
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct Block {
|
pub struct Block {
|
||||||
#[getters(skip)]
|
#[getters(skip)]
|
||||||
id: AttrId,
|
id: AttrId,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
/// Componente básico que renderiza dinámicamente código HTML según el contexto.
|
/// Componente básico que renderiza dinámicamente código HTML según el contexto.
|
||||||
///
|
///
|
||||||
/// Este componente permite generar contenido HTML arbitrario, usando la macro `html!` y accediendo
|
/// Este componente permite generar contenido HTML arbitrario, usando la macro `html!` y accediendo
|
||||||
|
|
@ -31,6 +33,14 @@ use crate::prelude::*;
|
||||||
/// ```
|
/// ```
|
||||||
pub struct Html(Box<dyn Fn(&mut Context) -> Markup + Send + Sync>);
|
pub struct Html(Box<dyn Fn(&mut Context) -> Markup + Send + Sync>);
|
||||||
|
|
||||||
|
impl fmt::Debug for Html {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_tuple("Html")
|
||||||
|
.field(&"Fn(&mut Context) -> Markup")
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for Html {
|
impl Default for Html {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::with(|_| html! {})
|
Self::with(|_| html! {})
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ pub enum IntroOpening {
|
||||||
/// })),
|
/// })),
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Getters)]
|
#[derive(Debug, Getters)]
|
||||||
pub struct Intro {
|
pub struct Intro {
|
||||||
/// Devuelve el título de entrada.
|
/// Devuelve el título de entrada.
|
||||||
title: L10n,
|
title: L10n,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ const LINK: &str = "<a href=\"https://pagetop.cillero.es\" rel=\"noopener norefe
|
||||||
/// Por defecto, usando [`default()`](Self::default) sólo se muestra un reconocimiento a PageTop.
|
/// Por defecto, usando [`default()`](Self::default) sólo se muestra un reconocimiento a PageTop.
|
||||||
/// Sin embargo, se puede usar [`new()`](Self::new) para crear una instancia con un texto de
|
/// Sin embargo, se puede usar [`new()`](Self::new) para crear una instancia con un texto de
|
||||||
/// copyright predeterminado.
|
/// copyright predeterminado.
|
||||||
#[derive(AutoDefault, Getters)]
|
#[derive(AutoDefault, Debug, Getters)]
|
||||||
pub struct PoweredBy {
|
pub struct PoweredBy {
|
||||||
/// Devuelve el texto de copyright actual, si existe.
|
/// Devuelve el texto de copyright actual, si existe.
|
||||||
copyright: Option<String>,
|
copyright: Option<String>,
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ use parking_lot::RwLock;
|
||||||
pub use parking_lot::RwLockReadGuard as ComponentReadGuard;
|
pub use parking_lot::RwLockReadGuard as ComponentReadGuard;
|
||||||
pub use parking_lot::RwLockWriteGuard as ComponentWriteGuard;
|
pub use parking_lot::RwLockWriteGuard as ComponentWriteGuard;
|
||||||
|
|
||||||
|
use std::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::vec::IntoIter;
|
use std::vec::IntoIter;
|
||||||
|
|
||||||
|
|
@ -17,6 +18,15 @@ use std::vec::IntoIter;
|
||||||
#[derive(AutoDefault, Clone)]
|
#[derive(AutoDefault, Clone)]
|
||||||
pub struct Child(Option<Arc<RwLock<dyn Component>>>);
|
pub struct Child(Option<Arc<RwLock<dyn Component>>>);
|
||||||
|
|
||||||
|
impl fmt::Debug for Child {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match &self.0 {
|
||||||
|
None => write!(f, "Child(None)"),
|
||||||
|
Some(c) => write!(f, "Child({})", c.read().name()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Child {
|
impl Child {
|
||||||
/// Crea un nuevo `Child` a partir de un componente.
|
/// Crea un nuevo `Child` a partir de un componente.
|
||||||
pub fn with(component: impl Component) -> Self {
|
pub fn with(component: impl Component) -> Self {
|
||||||
|
|
@ -71,6 +81,15 @@ impl Child {
|
||||||
#[derive(AutoDefault, Clone)]
|
#[derive(AutoDefault, Clone)]
|
||||||
pub struct Typed<C: Component>(Option<Arc<RwLock<C>>>);
|
pub struct Typed<C: Component>(Option<Arc<RwLock<C>>>);
|
||||||
|
|
||||||
|
impl<C: Component> fmt::Debug for Typed<C> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match &self.0 {
|
||||||
|
None => write!(f, "Typed(None)"),
|
||||||
|
Some(c) => write!(f, "Typed({})", c.read().name()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<C: Component> Typed<C> {
|
impl<C: Component> Typed<C> {
|
||||||
/// Crea un nuevo `Typed` a partir de un componente.
|
/// Crea un nuevo `Typed` a partir de un componente.
|
||||||
pub fn with(component: C) -> Self {
|
pub fn with(component: C) -> Self {
|
||||||
|
|
@ -202,7 +221,7 @@ pub enum TypedOp<C: Component> {
|
||||||
/// Esta lista permite añadir, modificar, renderizar y consultar componentes hijo en orden de
|
/// Esta lista permite añadir, modificar, renderizar y consultar componentes hijo en orden de
|
||||||
/// inserción, soportando operaciones avanzadas como inserción relativa o reemplazo por
|
/// inserción, soportando operaciones avanzadas como inserción relativa o reemplazo por
|
||||||
/// identificador.
|
/// identificador.
|
||||||
#[derive(AutoDefault, Clone)]
|
#[derive(AutoDefault, Clone, Debug)]
|
||||||
pub struct Children(Vec<Child>);
|
pub struct Children(Vec<Child>);
|
||||||
|
|
||||||
impl Children {
|
impl Children {
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,17 @@ pub struct L10n {
|
||||||
args: Vec<(CowStr, CowStr)>,
|
args: Vec<(CowStr, CowStr)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for L10n {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_struct("L10n")
|
||||||
|
.field("op", &self.op)
|
||||||
|
.field("args", &self.args)
|
||||||
|
// No se puede mostrar `locales`; se representa con un texto fijo.
|
||||||
|
.field("locales", &"<StaticLoader>")
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl L10n {
|
impl L10n {
|
||||||
/// **n** = *“native”*. Crea una instancia con una cadena literal sin traducción.
|
/// **n** = *“native”*. Crea una instancia con una cadena literal sin traducción.
|
||||||
pub fn n(text: impl Into<CowStr>) -> Self {
|
pub fn n(text: impl Into<CowStr>) -> Self {
|
||||||
|
|
@ -177,14 +188,3 @@ impl L10n {
|
||||||
PreEscaped(self.lookup(language).unwrap_or_default())
|
PreEscaped(self.lookup(language).unwrap_or_default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for L10n {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
f.debug_struct("L10n")
|
|
||||||
.field("op", &self.op)
|
|
||||||
.field("args", &self.args)
|
|
||||||
// No se puede mostrar `locales`; se representa con un texto fijo.
|
|
||||||
.field("locales", &"<StaticLoader>")
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue