WIP: Añade componente para la gestión de menús #8

Draft
manuelcillero wants to merge 54 commits from add-menu-component into main
10 changed files with 267 additions and 223 deletions
Showing only changes of commit 6a4ad213d8 - Show all commits

View file

@ -4,12 +4,9 @@ mod breakpoint;
pub use breakpoint::BreakPoint; pub use breakpoint::BreakPoint;
mod color; mod color;
pub use color::Color; pub use color::{Color, Opacity};
pub use color::{BgColor, BorderColor, ButtonColor, TextColor}; pub use color::{ColorBg, ColorBorder, ColorButton, ColorText};
pub use color::{StyleBg, StyleBorder, StyleText};
mod opacity;
pub use opacity::Opacity;
pub use opacity::{BgOpacity, BorderOpacity, TextOpacity};
mod border; mod border;
pub use border::{Border, BorderSize}; pub use border::{Border, BorderSize};

View file

@ -6,7 +6,7 @@ use std::fmt;
// **< BorderSize >********************************************************************************* // **< BorderSize >*********************************************************************************
/// Tamaño (**ancho**) para los bordes ([`Border`]). /// Tamaño para el ancho de los bordes ([`Border`]).
/// ///
/// Mapea a `border`, `border-0` y `border-{1..5}`: /// Mapea a `border`, `border-0` y `border-{1..5}`:
/// ///
@ -58,7 +58,7 @@ impl fmt::Display for BorderSize {
/// - Definir un tamaño **global** para todo el borde (`size`). /// - Definir un tamaño **global** para todo el borde (`size`).
/// - Ajustar el tamaño de cada **lado lógico** (`top`, `end`, `bottom`, `start`, **en este orden**, /// - Ajustar el tamaño de cada **lado lógico** (`top`, `end`, `bottom`, `start`, **en este orden**,
/// respetando LTR/RTL). /// respetando LTR/RTL).
/// - Aplicar un **color** al borde (`BorderColor`). /// - Aplicar un **color** al borde (`ColorBorder`).
/// - Aplicar un nivel de **opacidad** (`BorderOpacity`). /// - Aplicar un nivel de **opacidad** (`BorderOpacity`).
/// ///
/// # Comportamiento aditivo / sustractivo /// # Comportamiento aditivo / sustractivo
@ -107,8 +107,7 @@ impl fmt::Display for BorderSize {
/// let b = Border::with(BorderSize::Default) // Borde global por defecto. /// let b = Border::with(BorderSize::Default) // Borde global por defecto.
/// .with_top(BorderSize::Zero) // Quita borde superior. /// .with_top(BorderSize::Zero) // Quita borde superior.
/// .with_end(BorderSize::Scale3) // Ancho 3 para el lado lógico final. /// .with_end(BorderSize::Scale3) // Ancho 3 para el lado lógico final.
/// .with_color(BorderColor::Theme(Color::Primary)) /// .with_style(StyleBorder::Both(ColorBorder::Theme(Color::Primary), Opacity::Half));
/// .with_opacity(BorderOpacity::Theme(Opacity::Half));
/// ///
/// assert_eq!(b.to_string(), "border border-top-0 border-end-3 border-primary border-opacity-50"); /// assert_eq!(b.to_string(), "border border-top-0 border-end-3 border-primary border-opacity-50");
/// ``` /// ```
@ -120,8 +119,7 @@ pub struct Border {
end : BorderSize, end : BorderSize,
bottom: BorderSize, bottom: BorderSize,
start : BorderSize, start : BorderSize,
color : BorderColor, style : StyleBorder,
opacity: BorderOpacity,
} }
impl Border { impl Border {
@ -167,22 +165,16 @@ impl Border {
self self
} }
/// Establece el **color** del borde. /// Establece el estilo de color/opacidad del borde.
pub fn with_color(mut self, color: BorderColor) -> Self { pub fn with_style(mut self, style: StyleBorder) -> Self {
self.color = color; self.style = style;
self
}
/// Establece la **opacidad** del borde.
pub fn with_opacity(mut self, opacity: BorderOpacity) -> Self {
self.opacity = opacity;
self self
} }
} }
impl fmt::Display for Border { impl fmt::Display for Border {
/// Concatena cada definición en el orden: *global*, `top`, `end`, `bottom`, `start`, *color* y /// Concatena cada definición en el orden: *global*, `top`, `end`, `bottom`, `start` y
/// *opacidad*; respetando LTR/RTL y omitiendo las definiciones vacías. /// *color*/*opacidad*; respetando LTR/RTL y omitiendo las definiciones vacías.
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!( write!(
f, f,
@ -193,8 +185,7 @@ impl fmt::Display for Border {
self.end.to_class("border-end"), self.end.to_class("border-end"),
self.bottom.to_class("border-bottom"), self.bottom.to_class("border-bottom"),
self.start.to_class("border-start"), self.start.to_class("border-start"),
self.color.to_string(), self.style.to_string(),
self.opacity.to_string(),
]; " ") ]; " ")
.unwrap_or_default() .unwrap_or_default()
) )

View file

@ -4,11 +4,11 @@ use std::fmt;
// **< Color >************************************************************************************** // **< Color >**************************************************************************************
/// Paleta de colores **temáticos**. /// Paleta de colores temáticos.
/// ///
/// Equivalente a los nombres estándar de Bootstrap (`primary`, `secondary`, `success`, etc.). Sirve /// Equivalen a los nombres estándar definidos por Bootstrap (`primary`, `secondary`, `success`,
/// como base para componer clases de fondo ([`BgColor`]), borde ([`BorderColor`]) y texto /// etc.). Este tipo enumerado sirve de base para componer clases de color para el fondo
/// ([`TextColor`]). /// ([`ColorBg`]), bordes ([`ColorBorder`]) y texto ([`ColorText`]).
#[derive(AutoDefault)] #[derive(AutoDefault)]
pub enum Color { pub enum Color {
#[default] #[default]
@ -38,32 +38,34 @@ impl fmt::Display for Color {
} }
} }
// **< BgColor >************************************************************************************ // **< ColorBg >************************************************************************************
/// Colores de fondo (`bg-*`). /// Colores `bg-*` para el fondo.
///
/// - `Default` no añade clase (devuelve `""` para facilitar la composición de clases).
/// - `Body*` usa fondos predefinidos del tema (`bg-body`, `bg-body-secondary`, `bg-body-tertiary`).
/// - `Theme(Color)` genera `bg-{color}` (p. ej., `bg-primary`).
/// - `Subtle(Color)` genera `bg-{color}-subtle` (tono suave).
/// - `Black` y `White` son colores explícitos.
/// - `Transparent` no aplica color de fondo (`bg-transparent`).
#[derive(AutoDefault)] #[derive(AutoDefault)]
pub enum BgColor { pub enum ColorBg {
/// No define ninguna clase (devuelve `""` para facilitar la composición de clases).
#[default] #[default]
Default, Default,
/// Fondo predefinido del tema (`bg-body`).
Body, Body,
/// Fondo predefinido del tema (`bg-body-secondary`).
BodySecondary, BodySecondary,
/// Fondo predefinido del tema (`bg-body-tertiary`).
BodyTertiary, BodyTertiary,
/// Genera internamente clases `bg-{color}` (p. ej., `bg-primary`).
Theme(Color), Theme(Color),
/// Genera internamente clases `bg-{color}-subtle` (un tono suavizado del color).
Subtle(Color), Subtle(Color),
/// Color negro.
Black, Black,
/// Color blanco.
White, White,
/// No aplica ningún color de fondo (`bg-transparent`).
Transparent, Transparent,
} }
#[rustfmt::skip] #[rustfmt::skip]
impl fmt::Display for BgColor { impl fmt::Display for ColorBg {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Default => Ok(()), Self::Default => Ok(()),
@ -79,26 +81,26 @@ impl fmt::Display for BgColor {
} }
} }
// **< BorderColor >******************************************************************************** // **< ColorBorder >********************************************************************************
/// Colores (`border-*`) para los bordes ([`Border`](crate::theme::aux::Border)). /// Colores `border-*` para los bordes ([`Border`](crate::theme::aux::Border)).
///
/// - `Default` no añade clase (devuelve `""` para facilitar la composición de clases).
/// - `Theme(Color)` genera `border-{color}`.
/// - `Subtle(Color)` genera `border-{color}-subtle` (versión suavizada).
/// - `Black` y `White` son colores explícitos.
#[derive(AutoDefault)] #[derive(AutoDefault)]
pub enum BorderColor { pub enum ColorBorder {
/// No define ninguna clase (devuelve `""` para facilitar la composición de clases).
#[default] #[default]
Default, Default,
/// Genera internamente clases `border-{color}`.
Theme(Color), Theme(Color),
/// Genera internamente clases `border-{color}-subtle` (un tono suavizado del color).
Subtle(Color), Subtle(Color),
/// Color negro.
Black, Black,
/// Color blanco.
White, White,
} }
#[rustfmt::skip] #[rustfmt::skip]
impl fmt::Display for BorderColor { impl fmt::Display for ColorBorder {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Default => Ok(()), Self::Default => Ok(()),
@ -110,25 +112,24 @@ impl fmt::Display for BorderColor {
} }
} }
// **< ButtonColor >******************************************************************************** // **< ColorButton >********************************************************************************
/// Variantes de color (`btn-*`) para **botones**. /// Variantes de color `btn-*` para botones.
///
/// - `Default` no añade clase (devuelve `""` para facilitar la composición de clases).
/// - `Background(Color)` genera `btn-{color}` (botón relleno).
/// - `Outline(Color)` genera `btn-outline-{color}` (contorno: texto y borde, fondo transparente).
/// - `Link` aplica estilo de enlace (`btn-link`), sin caja ni fondo, heredando el color de texto.
#[derive(AutoDefault)] #[derive(AutoDefault)]
pub enum ButtonColor { pub enum ColorButton {
/// No define ninguna clase (devuelve `""` para facilitar la composición de clases).
#[default] #[default]
Default, Default,
/// Genera internamente clases `btn-{color}` (botón relleno).
Background(Color), Background(Color),
/// Genera `btn-outline-{color}` (fondo transparente y contorno con borde).
Outline(Color), Outline(Color),
/// Aplica estilo de los enlaces (`btn-link`), sin caja ni fondo, heredando el color de texto.
Link, Link,
} }
#[rustfmt::skip] #[rustfmt::skip]
impl fmt::Display for ButtonColor { impl fmt::Display for ColorButton {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Default => Ok(()), Self::Default => Ok(()),
@ -139,34 +140,34 @@ impl fmt::Display for ButtonColor {
} }
} }
// **< TextColor >********************************************************************************** // **< ColorText >**********************************************************************************
/// Colores de texto y fondos de texto (`text-*`). /// Colores `text-*` para el texto.
///
/// - `Default` no añade clase (devuelve `""` para facilitar la composición de clases).
/// - `Body*` aplica colores predefinidos del tema (`text-body`, `text-body-emphasis`,
/// `text-body-secondary`, `text-body-tertiary`).
/// - `Theme(Color)` genera `text-{color}`.
/// - `Emphasis(Color)` genera `text-{color}-emphasis` (contraste mayor acorde al tema).
/// - `Background(Color)` genera `text-bg-{color}` (para color de fondo del texto).
/// - `Black` y `White` son colores explícitos.
#[derive(AutoDefault)] #[derive(AutoDefault)]
pub enum TextColor { pub enum ColorText {
/// No define ninguna clase (devuelve `""` para facilitar la composición de clases).
#[default] #[default]
Default, Default,
/// Color predefinido del tema (`text-body`).
Body, Body,
/// Color predefinido del tema (`text-body-emphasis`).
BodyEmphasis, BodyEmphasis,
/// Color predefinido del tema (`text-body-secondary`).
BodySecondary, BodySecondary,
/// Color predefinido del tema (`text-body-tertiary`).
BodyTertiary, BodyTertiary,
/// Genera internamente clases `text-{color}`.
Theme(Color), Theme(Color),
/// Genera internamente clases `text-{color}-emphasis` (mayor contraste acorde al tema).
Emphasis(Color), Emphasis(Color),
Background(Color), /// Color negro.
Black, Black,
/// Color blanco.
White, White,
} }
#[rustfmt::skip] #[rustfmt::skip]
impl fmt::Display for TextColor { impl fmt::Display for ColorText {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Default => Ok(()), Self::Default => Ok(()),
@ -176,9 +177,140 @@ impl fmt::Display for TextColor {
Self::BodyTertiary => f.write_str("text-body-tertiary"), Self::BodyTertiary => f.write_str("text-body-tertiary"),
Self::Theme(c) => write!(f, "text-{c}"), Self::Theme(c) => write!(f, "text-{c}"),
Self::Emphasis(c) => write!(f, "text-{c}-emphasis"), Self::Emphasis(c) => write!(f, "text-{c}-emphasis"),
Self::Background(c) => write!(f, "text-bg-{c}"),
Self::Black => f.write_str("text-black"), Self::Black => f.write_str("text-black"),
Self::White => f.write_str("text-white"), Self::White => f.write_str("text-white"),
} }
} }
} }
// **< Opacity >************************************************************************************
/// Niveles de opacidad (`opacity-*`).
///
/// Se usa normalmente para graduar la transparencia del color de fondo `bg-opacity-*`
/// ([`StyleBg`]), de los bordes `border-opacity-*` ([`StyleBorder`]) o del texto `text-opacity-*`
/// ([`StyleText`]).
#[rustfmt::skip]
#[derive(AutoDefault)]
pub enum Opacity {
/// Genera internamente clases `opacity-100` (100% de opacidad).
#[default]
Opaque,
/// Genera internamente clases `opacity-75` (75%).
SemiOpaque,
/// Genera internamente clases `opacity-50` (50%).
Half,
/// Genera internamente clases `opacity-25` (25%).
SemiTransparent,
/// Genera internamente clases `opacity-10` (10%).
AlmostTransparent,
/// Genera internamente clases `opacity-0` (0%, totalmente transparente).
Transparent,
}
#[rustfmt::skip]
impl fmt::Display for Opacity {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Opaque => f.write_str("opacity-100"),
Self::SemiOpaque => f.write_str("opacity-75"),
Self::Half => f.write_str("opacity-50"),
Self::SemiTransparent => f.write_str("opacity-25"),
Self::AlmostTransparent => f.write_str("opacity-10"),
Self::Transparent => f.write_str("opacity-0"),
}
}
}
// **< StyleBg >***********************************************************************************
/// Estilos de color/opacidad para el fondo.
#[derive(AutoDefault)]
pub enum StyleBg {
/// No define ninguna clase (devuelve `""` para facilitar la composición de clases).
#[default]
Default,
/// Genera internamente clases `bg-*`.
Color(ColorBg),
/// Genera internamente clases `bg-opacity-*`.
Opacity(Opacity),
/// Genera internamente clases `bg-* bg-opacity-*`.
Both(ColorBg, Opacity),
}
#[rustfmt::skip]
impl fmt::Display for StyleBg {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Default => Ok(()),
Self::Color(c) => write!(f, "{c}"),
Self::Opacity(o) => write!(f, "bg-{o}"),
Self::Both(c, o) => write!(f, "{c} bg-{o}"),
}
}
}
// **< StyleBorder >*******************************************************************************
/// Estilos de color/opacidad para los bordes ([`Border`](crate::theme::aux::Border)).
#[derive(AutoDefault)]
pub enum StyleBorder {
/// No define ninguna clase (devuelve `""` para facilitar la composición de clases).
#[default]
Default,
/// Genera internamente clases `border-*`.
Color(ColorBorder),
/// Genera internamente clases `border-opacity-*`.
Opacity(Opacity),
/// Genera internamente clases `border-* border-opacity-*`.
Both(ColorBorder, Opacity),
}
#[rustfmt::skip]
impl fmt::Display for StyleBorder {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Default => Ok(()),
Self::Color(c) => write!(f, "{c}"),
Self::Opacity(o) => write!(f, "border-{o}"),
Self::Both(c, o) => write!(f, "{c} border-{o}"),
}
}
}
// **< StyleText >*********************************************************************************
/// Estilos de color/opacidad para texto y fondo del texto.
#[derive(AutoDefault)]
pub enum StyleText {
/// No define ninguna clase (devuelve `""` para facilitar la composición de clases).
#[default]
Default,
/// Genera internamente clases `text-*`.
Color(ColorText),
/// Genera internamente clases `text-opacity-*`.
Opacity(Opacity),
/// Genera internamente clases `text-* text-opacity-*`.
Both(ColorText, Opacity),
/// Genera internamente clases `text-bg-*` (para el color de fondo del texto).
Bg(Color),
/// Genera internamente clases `text-bg-* text-*`.
BgAndColor(Color, ColorText),
/// Genera internamente clases `text-bg-* text-* text-opacity-*`.
All(Color, ColorText, Opacity),
}
#[rustfmt::skip]
impl fmt::Display for StyleText {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Default => Ok(()),
Self::Color(c) => write!(f, "{c}"),
Self::Opacity(o) => write!(f, "text-{o}"),
Self::Both(c, o) => write!(f, "{c} text-{o}"),
Self::Bg(bg) => write!(f, "text-bg-{bg}"),
Self::BgAndColor(bg, c) => write!(f, "text-bg-{bg} {c}"),
Self::All(bg, c, o) => write!(f, "text-bg-{bg} {c} text-{o}"),
}
}
}

View file

@ -1,109 +0,0 @@
use pagetop::prelude::*;
use std::fmt;
// **< Opacity >************************************************************************************
/// Niveles de **opacidad** (`opacity-*`).
///
/// Se usa para modular la transparencia del color de fondo `bg-opacity-*` ([`BgOpacity`]), borde
/// `border-opacity-*` ([`BorderOpacity`]) o texto `text-opacity-*` ([`TextOpacity`]), según las
/// siguientes equivalencias:
///
/// - `Opaque` => `opacity-100` (100% de opacidad).
/// - `SemiOpaque` => `opacity-75` (75%).
/// - `Half` => `opacity-50` (50%).
/// - `SemiTransparent` => `opacity-25` (25%).
/// - `AlmostTransparent` => `opacity-10` (10%).
/// - `Transparent` => `opacity-0` (0%, totalmente transparente).
#[rustfmt::skip]
#[derive(AutoDefault)]
pub enum Opacity {
#[default]
Opaque, // 100%
SemiOpaque, // 75%
Half, // 50%
SemiTransparent, // 25%
AlmostTransparent, // 10%
Transparent, // 0%
}
#[rustfmt::skip]
impl fmt::Display for Opacity {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Opaque => f.write_str("opacity-100"),
Self::SemiOpaque => f.write_str("opacity-75"),
Self::Half => f.write_str("opacity-50"),
Self::SemiTransparent => f.write_str("opacity-25"),
Self::AlmostTransparent => f.write_str("opacity-10"),
Self::Transparent => f.write_str("opacity-0"),
}
}
}
// **< BgOpacity >**********************************************************************************
/// Opacidad para el fondo (`bg-opacity-*`).
///
/// - `Default` no añade clase (devuelve `""` para facilitar la composición de clases).
/// - `Theme(Opacity)` genera `bg-{opacity}` (p. ej., `bg-opacity-50`).
#[derive(AutoDefault)]
pub enum BgOpacity {
#[default]
Default,
Theme(Opacity),
}
impl fmt::Display for BgOpacity {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Default => Ok(()),
Self::Theme(o) => write!(f, "bg-{o}"),
}
}
}
// **< BorderOpacity >******************************************************************************
/// Opacidad (`border-opacity-*`) para los bordes ([`Border`](crate::theme::aux::Border)).
///
/// - `Default` no añade clase (devuelve `""` para facilitar la composición de clases).
/// - `Theme(Opacity)` genera `border-{opacity}` (p. ej., `border-opacity-25`).
#[derive(AutoDefault)]
pub enum BorderOpacity {
#[default]
Default,
Theme(Opacity),
}
impl fmt::Display for BorderOpacity {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Default => Ok(()),
Self::Theme(o) => write!(f, "border-{o}"),
}
}
}
// **< TextOpacity >********************************************************************************
/// Opacidad para el texto (`text-opacity-*`).
///
/// - `Default` no añade clase (devuelve `""` para facilitar la composición de clases).
/// - `Theme(Opacity)` genera `text-{opacity}` (p. ej., `text-opacity-100`).
#[derive(AutoDefault)]
pub enum TextOpacity {
#[default]
Default,
Theme(Opacity),
}
impl fmt::Display for TextOpacity {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Default => Ok(()),
Self::Theme(o) => write!(f, "text-{o}"),
}
}
}

View file

@ -4,7 +4,7 @@ use std::fmt;
// **< RoundedRadius >****************************************************************************** // **< RoundedRadius >******************************************************************************
/// Radio (**redondeo**) para las esquinas ([`Rounded`]). /// Radio para el redondeo de esquinas ([`Rounded`]).
/// ///
/// Mapea a `rounded`, `rounded-0`, `rounded-{1..5}`, `rounded-circle` y `rounded-pill`. /// Mapea a `rounded`, `rounded-0`, `rounded-{1..5}`, `rounded-circle` y `rounded-pill`.
/// ///

View file

@ -5,17 +5,14 @@ use std::fmt;
// **< ButtonSize >********************************************************************************* // **< ButtonSize >*********************************************************************************
/// Tamaño visual de un botón. /// Tamaño visual de un botón.
///
/// Controla la escala del botón según el diseño del tema:
///
/// - `Default`, tamaño por defecto del tema (no añade clase).
/// - `Small`, botón compacto.
/// - `Large`, botón destacado/grande.
#[derive(AutoDefault)] #[derive(AutoDefault)]
pub enum ButtonSize { pub enum ButtonSize {
/// Tamaño por defecto del tema (no añade clase).
#[default] #[default]
Default, Default,
/// Botón compacto.
Small, Small,
/// Botón destacado/grande.
Large, Large,
} }

View file

@ -56,8 +56,8 @@ pub struct Container {
classes : AttrClasses, classes : AttrClasses,
container_type : ContainerType, container_type : ContainerType,
container_width: ContainerWidth, container_width: ContainerWidth,
bg_color : BgColor, style_bg : StyleBg,
text_color : TextColor, style_text : StyleText,
border : Border, border : Border,
rounded : Rounded, rounded : Rounded,
children : Children, children : Children,
@ -86,8 +86,8 @@ impl Component for Container {
ContainerWidth::FluidMax(_) => "fluid".to_string(), ContainerWidth::FluidMax(_) => "fluid".to_string(),
} }
), ),
self.bg_color().to_string(), self.style_bg().to_string(),
self.text_color().to_string(), self.style_text().to_string(),
self.border().to_string(), self.border().to_string(),
self.rounded().to_string(), self.rounded().to_string(),
] ]
@ -205,25 +205,25 @@ impl Container {
self self
} }
/// Establece el color de fondo ([`BgColor`]). /// Establece el estilo del fondo ([`StyleBg`]).
#[builder_fn] #[builder_fn]
pub fn with_bg_color(mut self, color: BgColor) -> Self { pub fn with_style_bg(mut self, style: StyleBg) -> Self {
self.bg_color = color; self.style_bg = style;
self self
} }
/// Establece el color del texto ([`TextColor`]). /// Establece el estilo del texto ([`StyleText`]).
#[builder_fn] #[builder_fn]
pub fn with_text_color(mut self, color: TextColor) -> Self { pub fn with_style_text(mut self, style: StyleText) -> Self {
self.text_color = color; self.style_text = style;
self self
} }
/// Atajo para definir los colores de fondo y texto a la vez. /// Atajo para definir los estilos de fondo y texto a la vez.
#[builder_fn] #[builder_fn]
pub fn with_colors(mut self, bg_color: BgColor, text_color: TextColor) -> Self { pub fn with_styles(mut self, style_bg: StyleBg, style_text: StyleText) -> Self {
self.bg_color = bg_color; self.style_bg = style_bg;
self.text_color = text_color; self.style_text = style_text;
self self
} }
@ -272,14 +272,14 @@ impl Container {
&self.container_width &self.container_width
} }
/// Devuelve el color de fondo del contenedor. /// Devuelve el estilo del fondo del contenedor.
pub fn bg_color(&self) -> &BgColor { pub fn style_bg(&self) -> &StyleBg {
&self.bg_color &self.style_bg
} }
/// Devuelve el color del texto del contenedor. /// Devuelve el estilo del texto del contenedor.
pub fn text_color(&self) -> &TextColor { pub fn style_text(&self) -> &StyleText {
&self.text_color &self.style_text
} }
/// Devuelve el borde configurado del contenedor. /// Devuelve el borde configurado del contenedor.

View file

@ -14,7 +14,7 @@
//! # use pagetop_bootsier::prelude::*; //! # use pagetop_bootsier::prelude::*;
//! let dd = Dropdown::new() //! let dd = Dropdown::new()
//! .with_title(L10n::n("Menu")) //! .with_title(L10n::n("Menu"))
//! .with_button_color(ButtonColor::Background(Color::Secondary)) //! .with_button_color(ColorButton::Background(Color::Secondary))
//! .with_auto_close(dropdown::AutoClose::ClickableInside) //! .with_auto_close(dropdown::AutoClose::ClickableInside)
//! .with_direction(dropdown::Direction::Dropend) //! .with_direction(dropdown::Direction::Dropend)
//! .add_item(dropdown::Item::link(L10n::n("Home"), |_| "/")) //! .add_item(dropdown::Item::link(L10n::n("Home"), |_| "/"))

View file

@ -26,7 +26,7 @@ pub struct Dropdown {
classes : AttrClasses, classes : AttrClasses,
title : L10n, title : L10n,
button_size : ButtonSize, button_size : ButtonSize,
button_color : ButtonColor, button_color : ColorButton,
button_split : bool, button_split : bool,
button_grouped: bool, button_grouped: bool,
auto_close : dropdown::AutoClose, auto_close : dropdown::AutoClose,
@ -212,7 +212,7 @@ impl Dropdown {
/// Define el color/estilo del botón. /// Define el color/estilo del botón.
#[builder_fn] #[builder_fn]
pub fn with_button_color(mut self, color: ButtonColor) -> Self { pub fn with_button_color(mut self, color: ColorButton) -> Self {
self.button_color = color; self.button_color = color;
self self
} }
@ -291,7 +291,7 @@ impl Dropdown {
} }
/// Devuelve el color/estilo configurado del botón. /// Devuelve el color/estilo configurado del botón.
pub fn button_color(&self) -> &ButtonColor { pub fn button_color(&self) -> &ColorButton {
&self.button_color &self.button_color
} }

View file

@ -22,6 +22,8 @@ pub struct Navbar {
expand : BreakPoint, expand : BreakPoint,
layout : navbar::Layout, layout : navbar::Layout,
position : navbar::Position, position : navbar::Position,
style_bg : StyleBg,
style_text: StyleText,
items : Children, items : Children,
} }
@ -48,6 +50,8 @@ impl Component for Navbar {
navbar::Position::StickyBottom => "sticky-bottom", navbar::Position::StickyBottom => "sticky-bottom",
} }
.to_string(), .to_string(),
self.style_bg().to_string(),
self.style_text().to_string(),
] ]
.join(" "), .join(" "),
); );
@ -255,6 +259,28 @@ impl Navbar {
self self
} }
/// Establece el estilo del fondo ([`StyleBg`]).
#[builder_fn]
pub fn with_style_bg(mut self, style: StyleBg) -> Self {
self.style_bg = style;
self
}
/// Establece el estilo del texto ([`StyleText`]).
#[builder_fn]
pub fn with_style_text(mut self, style: StyleText) -> Self {
self.style_text = style;
self
}
/// Atajo para definir los estilos de fondo y texto a la vez.
#[builder_fn]
pub fn with_styles(mut self, style_bg: StyleBg, style_text: StyleText) -> Self {
self.style_bg = style_bg;
self.style_text = style_text;
self
}
/// Añade un nuevo contenido hijo. /// Añade un nuevo contenido hijo.
#[inline] #[inline]
pub fn add_item(mut self, item: navbar::Item) -> Self { pub fn add_item(mut self, item: navbar::Item) -> Self {
@ -291,6 +317,16 @@ impl Navbar {
&self.position &self.position
} }
/// Devuelve el estilo del fondo del contenedor.
pub fn style_bg(&self) -> &StyleBg {
&self.style_bg
}
/// Devuelve el estilo del texto del contenedor.
pub fn style_text(&self) -> &StyleText {
&self.style_text
}
/// Devuelve la lista de contenidos (`children`). /// Devuelve la lista de contenidos (`children`).
pub fn items(&self) -> &Children { pub fn items(&self) -> &Children {
&self.items &self.items