WIP: Añade componente para la gestión de menús #8
10 changed files with 267 additions and 223 deletions
|
|
@ -4,12 +4,9 @@ mod breakpoint;
|
|||
pub use breakpoint::BreakPoint;
|
||||
|
||||
mod color;
|
||||
pub use color::Color;
|
||||
pub use color::{BgColor, BorderColor, ButtonColor, TextColor};
|
||||
|
||||
mod opacity;
|
||||
pub use opacity::Opacity;
|
||||
pub use opacity::{BgOpacity, BorderOpacity, TextOpacity};
|
||||
pub use color::{Color, Opacity};
|
||||
pub use color::{ColorBg, ColorBorder, ColorButton, ColorText};
|
||||
pub use color::{StyleBg, StyleBorder, StyleText};
|
||||
|
||||
mod border;
|
||||
pub use border::{Border, BorderSize};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::fmt;
|
|||
|
||||
// **< 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}`:
|
||||
///
|
||||
|
|
@ -58,7 +58,7 @@ impl fmt::Display for BorderSize {
|
|||
/// - 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**,
|
||||
/// respetando LTR/RTL).
|
||||
/// - Aplicar un **color** al borde (`BorderColor`).
|
||||
/// - Aplicar un **color** al borde (`ColorBorder`).
|
||||
/// - Aplicar un nivel de **opacidad** (`BorderOpacity`).
|
||||
///
|
||||
/// # Comportamiento aditivo / sustractivo
|
||||
|
|
@ -107,21 +107,19 @@ impl fmt::Display for BorderSize {
|
|||
/// let b = Border::with(BorderSize::Default) // Borde global por defecto.
|
||||
/// .with_top(BorderSize::Zero) // Quita borde superior.
|
||||
/// .with_end(BorderSize::Scale3) // Ancho 3 para el lado lógico final.
|
||||
/// .with_color(BorderColor::Theme(Color::Primary))
|
||||
/// .with_opacity(BorderOpacity::Theme(Opacity::Half));
|
||||
/// .with_style(StyleBorder::Both(ColorBorder::Theme(Color::Primary), Opacity::Half));
|
||||
///
|
||||
/// assert_eq!(b.to_string(), "border border-top-0 border-end-3 border-primary border-opacity-50");
|
||||
/// ```
|
||||
#[rustfmt::skip]
|
||||
#[derive(AutoDefault)]
|
||||
pub struct Border {
|
||||
size : BorderSize,
|
||||
top : BorderSize,
|
||||
end : BorderSize,
|
||||
bottom : BorderSize,
|
||||
start : BorderSize,
|
||||
color : BorderColor,
|
||||
opacity: BorderOpacity,
|
||||
size : BorderSize,
|
||||
top : BorderSize,
|
||||
end : BorderSize,
|
||||
bottom: BorderSize,
|
||||
start : BorderSize,
|
||||
style : StyleBorder,
|
||||
}
|
||||
|
||||
impl Border {
|
||||
|
|
@ -167,22 +165,16 @@ impl Border {
|
|||
self
|
||||
}
|
||||
|
||||
/// Establece el **color** del borde.
|
||||
pub fn with_color(mut self, color: BorderColor) -> Self {
|
||||
self.color = color;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la **opacidad** del borde.
|
||||
pub fn with_opacity(mut self, opacity: BorderOpacity) -> Self {
|
||||
self.opacity = opacity;
|
||||
/// Establece el estilo de color/opacidad del borde.
|
||||
pub fn with_style(mut self, style: StyleBorder) -> Self {
|
||||
self.style = style;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Border {
|
||||
/// Concatena cada definición en el orden: *global*, `top`, `end`, `bottom`, `start`, *color* y
|
||||
/// *opacidad*; respetando LTR/RTL y omitiendo las definiciones vacías.
|
||||
/// Concatena cada definición en el orden: *global*, `top`, `end`, `bottom`, `start` y
|
||||
/// *color*/*opacidad*; respetando LTR/RTL y omitiendo las definiciones vacías.
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
|
|
@ -193,8 +185,7 @@ impl fmt::Display for Border {
|
|||
self.end.to_class("border-end"),
|
||||
self.bottom.to_class("border-bottom"),
|
||||
self.start.to_class("border-start"),
|
||||
self.color.to_string(),
|
||||
self.opacity.to_string(),
|
||||
self.style.to_string(),
|
||||
]; " ")
|
||||
.unwrap_or_default()
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ use std::fmt;
|
|||
|
||||
// **< Color >**************************************************************************************
|
||||
|
||||
/// Paleta de colores **temáticos**.
|
||||
/// Paleta de colores temáticos.
|
||||
///
|
||||
/// Equivalente a los nombres estándar de Bootstrap (`primary`, `secondary`, `success`, etc.). Sirve
|
||||
/// como base para componer clases de fondo ([`BgColor`]), borde ([`BorderColor`]) y texto
|
||||
/// ([`TextColor`]).
|
||||
/// Equivalen a los nombres estándar definidos por Bootstrap (`primary`, `secondary`, `success`,
|
||||
/// etc.). Este tipo enumerado sirve de base para componer clases de color para el fondo
|
||||
/// ([`ColorBg`]), bordes ([`ColorBorder`]) y texto ([`ColorText`]).
|
||||
#[derive(AutoDefault)]
|
||||
pub enum Color {
|
||||
#[default]
|
||||
|
|
@ -38,32 +38,34 @@ impl fmt::Display for Color {
|
|||
}
|
||||
}
|
||||
|
||||
// **< BgColor >************************************************************************************
|
||||
// **< ColorBg >************************************************************************************
|
||||
|
||||
/// Colores de fondo (`bg-*`).
|
||||
///
|
||||
/// - `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`).
|
||||
/// Colores `bg-*` para el fondo.
|
||||
#[derive(AutoDefault)]
|
||||
pub enum BgColor {
|
||||
pub enum ColorBg {
|
||||
/// No define ninguna clase (devuelve `""` para facilitar la composición de clases).
|
||||
#[default]
|
||||
Default,
|
||||
/// Fondo predefinido del tema (`bg-body`).
|
||||
Body,
|
||||
/// Fondo predefinido del tema (`bg-body-secondary`).
|
||||
BodySecondary,
|
||||
/// Fondo predefinido del tema (`bg-body-tertiary`).
|
||||
BodyTertiary,
|
||||
/// Genera internamente clases `bg-{color}` (p. ej., `bg-primary`).
|
||||
Theme(Color),
|
||||
/// Genera internamente clases `bg-{color}-subtle` (un tono suavizado del color).
|
||||
Subtle(Color),
|
||||
/// Color negro.
|
||||
Black,
|
||||
/// Color blanco.
|
||||
White,
|
||||
/// No aplica ningún color de fondo (`bg-transparent`).
|
||||
Transparent,
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
impl fmt::Display for BgColor {
|
||||
impl fmt::Display for ColorBg {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Default => Ok(()),
|
||||
|
|
@ -79,26 +81,26 @@ impl fmt::Display for BgColor {
|
|||
}
|
||||
}
|
||||
|
||||
// **< BorderColor >********************************************************************************
|
||||
// **< ColorBorder >********************************************************************************
|
||||
|
||||
/// 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.
|
||||
/// Colores `border-*` para los bordes ([`Border`](crate::theme::aux::Border)).
|
||||
#[derive(AutoDefault)]
|
||||
pub enum BorderColor {
|
||||
pub enum ColorBorder {
|
||||
/// No define ninguna clase (devuelve `""` para facilitar la composición de clases).
|
||||
#[default]
|
||||
Default,
|
||||
/// Genera internamente clases `border-{color}`.
|
||||
Theme(Color),
|
||||
/// Genera internamente clases `border-{color}-subtle` (un tono suavizado del color).
|
||||
Subtle(Color),
|
||||
/// Color negro.
|
||||
Black,
|
||||
/// Color blanco.
|
||||
White,
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
impl fmt::Display for BorderColor {
|
||||
impl fmt::Display for ColorBorder {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Default => Ok(()),
|
||||
|
|
@ -110,25 +112,24 @@ impl fmt::Display for BorderColor {
|
|||
}
|
||||
}
|
||||
|
||||
// **< ButtonColor >********************************************************************************
|
||||
// **< ColorButton >********************************************************************************
|
||||
|
||||
/// 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.
|
||||
/// Variantes de color `btn-*` para botones.
|
||||
#[derive(AutoDefault)]
|
||||
pub enum ButtonColor {
|
||||
pub enum ColorButton {
|
||||
/// No define ninguna clase (devuelve `""` para facilitar la composición de clases).
|
||||
#[default]
|
||||
Default,
|
||||
/// Genera internamente clases `btn-{color}` (botón relleno).
|
||||
Background(Color),
|
||||
/// Genera `btn-outline-{color}` (fondo transparente y contorno con borde).
|
||||
Outline(Color),
|
||||
/// Aplica estilo de los enlaces (`btn-link`), sin caja ni fondo, heredando el color de texto.
|
||||
Link,
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
impl fmt::Display for ButtonColor {
|
||||
impl fmt::Display for ColorButton {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Default => Ok(()),
|
||||
|
|
@ -139,34 +140,34 @@ impl fmt::Display for ButtonColor {
|
|||
}
|
||||
}
|
||||
|
||||
// **< TextColor >**********************************************************************************
|
||||
// **< ColorText >**********************************************************************************
|
||||
|
||||
/// Colores de texto y fondos de texto (`text-*`).
|
||||
///
|
||||
/// - `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.
|
||||
/// Colores `text-*` para el texto.
|
||||
#[derive(AutoDefault)]
|
||||
pub enum TextColor {
|
||||
pub enum ColorText {
|
||||
/// No define ninguna clase (devuelve `""` para facilitar la composición de clases).
|
||||
#[default]
|
||||
Default,
|
||||
/// Color predefinido del tema (`text-body`).
|
||||
Body,
|
||||
/// Color predefinido del tema (`text-body-emphasis`).
|
||||
BodyEmphasis,
|
||||
/// Color predefinido del tema (`text-body-secondary`).
|
||||
BodySecondary,
|
||||
/// Color predefinido del tema (`text-body-tertiary`).
|
||||
BodyTertiary,
|
||||
/// Genera internamente clases `text-{color}`.
|
||||
Theme(Color),
|
||||
/// Genera internamente clases `text-{color}-emphasis` (mayor contraste acorde al tema).
|
||||
Emphasis(Color),
|
||||
Background(Color),
|
||||
/// Color negro.
|
||||
Black,
|
||||
/// Color blanco.
|
||||
White,
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
impl fmt::Display for TextColor {
|
||||
impl fmt::Display for ColorText {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Default => Ok(()),
|
||||
|
|
@ -176,9 +177,140 @@ impl fmt::Display for TextColor {
|
|||
Self::BodyTertiary => f.write_str("text-body-tertiary"),
|
||||
Self::Theme(c) => write!(f, "text-{c}"),
|
||||
Self::Emphasis(c) => write!(f, "text-{c}-emphasis"),
|
||||
Self::Background(c) => write!(f, "text-bg-{c}"),
|
||||
Self::Black => f.write_str("text-black"),
|
||||
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}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ use std::fmt;
|
|||
|
||||
// **< 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`.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -5,17 +5,14 @@ use std::fmt;
|
|||
// **< ButtonSize >*********************************************************************************
|
||||
|
||||
/// 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)]
|
||||
pub enum ButtonSize {
|
||||
/// Tamaño por defecto del tema (no añade clase).
|
||||
#[default]
|
||||
Default,
|
||||
/// Botón compacto.
|
||||
Small,
|
||||
/// Botón destacado/grande.
|
||||
Large,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ pub struct Container {
|
|||
classes : AttrClasses,
|
||||
container_type : ContainerType,
|
||||
container_width: ContainerWidth,
|
||||
bg_color : BgColor,
|
||||
text_color : TextColor,
|
||||
style_bg : StyleBg,
|
||||
style_text : StyleText,
|
||||
border : Border,
|
||||
rounded : Rounded,
|
||||
children : Children,
|
||||
|
|
@ -86,8 +86,8 @@ impl Component for Container {
|
|||
ContainerWidth::FluidMax(_) => "fluid".to_string(),
|
||||
}
|
||||
),
|
||||
self.bg_color().to_string(),
|
||||
self.text_color().to_string(),
|
||||
self.style_bg().to_string(),
|
||||
self.style_text().to_string(),
|
||||
self.border().to_string(),
|
||||
self.rounded().to_string(),
|
||||
]
|
||||
|
|
@ -205,25 +205,25 @@ impl Container {
|
|||
self
|
||||
}
|
||||
|
||||
/// Establece el color de fondo ([`BgColor`]).
|
||||
/// Establece el estilo del fondo ([`StyleBg`]).
|
||||
#[builder_fn]
|
||||
pub fn with_bg_color(mut self, color: BgColor) -> Self {
|
||||
self.bg_color = color;
|
||||
pub fn with_style_bg(mut self, style: StyleBg) -> Self {
|
||||
self.style_bg = style;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el color del texto ([`TextColor`]).
|
||||
/// Establece el estilo del texto ([`StyleText`]).
|
||||
#[builder_fn]
|
||||
pub fn with_text_color(mut self, color: TextColor) -> Self {
|
||||
self.text_color = color;
|
||||
pub fn with_style_text(mut self, style: StyleText) -> Self {
|
||||
self.style_text = style;
|
||||
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]
|
||||
pub fn with_colors(mut self, bg_color: BgColor, text_color: TextColor) -> Self {
|
||||
self.bg_color = bg_color;
|
||||
self.text_color = text_color;
|
||||
pub fn with_styles(mut self, style_bg: StyleBg, style_text: StyleText) -> Self {
|
||||
self.style_bg = style_bg;
|
||||
self.style_text = style_text;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -272,14 +272,14 @@ impl Container {
|
|||
&self.container_width
|
||||
}
|
||||
|
||||
/// Devuelve el color de fondo del contenedor.
|
||||
pub fn bg_color(&self) -> &BgColor {
|
||||
&self.bg_color
|
||||
/// Devuelve el estilo del fondo del contenedor.
|
||||
pub fn style_bg(&self) -> &StyleBg {
|
||||
&self.style_bg
|
||||
}
|
||||
|
||||
/// Devuelve el color del texto del contenedor.
|
||||
pub fn text_color(&self) -> &TextColor {
|
||||
&self.text_color
|
||||
/// Devuelve el estilo del texto del contenedor.
|
||||
pub fn style_text(&self) -> &StyleText {
|
||||
&self.style_text
|
||||
}
|
||||
|
||||
/// Devuelve el borde configurado del contenedor.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
//! # use pagetop_bootsier::prelude::*;
|
||||
//! let dd = Dropdown::new()
|
||||
//! .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_direction(dropdown::Direction::Dropend)
|
||||
//! .add_item(dropdown::Item::link(L10n::n("Home"), |_| "/"))
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ pub struct Dropdown {
|
|||
classes : AttrClasses,
|
||||
title : L10n,
|
||||
button_size : ButtonSize,
|
||||
button_color : ButtonColor,
|
||||
button_color : ColorButton,
|
||||
button_split : bool,
|
||||
button_grouped: bool,
|
||||
auto_close : dropdown::AutoClose,
|
||||
|
|
@ -212,7 +212,7 @@ impl Dropdown {
|
|||
|
||||
/// Define el color/estilo del botón.
|
||||
#[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
|
||||
}
|
||||
|
|
@ -291,7 +291,7 @@ impl Dropdown {
|
|||
}
|
||||
|
||||
/// Devuelve el color/estilo configurado del botón.
|
||||
pub fn button_color(&self) -> &ButtonColor {
|
||||
pub fn button_color(&self) -> &ColorButton {
|
||||
&self.button_color
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,12 +17,14 @@ const TOGGLE_OFFCANVAS: &str = "offcanvas";
|
|||
#[rustfmt::skip]
|
||||
#[derive(AutoDefault)]
|
||||
pub struct Navbar {
|
||||
id : AttrId,
|
||||
classes : AttrClasses,
|
||||
expand : BreakPoint,
|
||||
layout : navbar::Layout,
|
||||
position: navbar::Position,
|
||||
items : Children,
|
||||
id : AttrId,
|
||||
classes : AttrClasses,
|
||||
expand : BreakPoint,
|
||||
layout : navbar::Layout,
|
||||
position : navbar::Position,
|
||||
style_bg : StyleBg,
|
||||
style_text: StyleText,
|
||||
items : Children,
|
||||
}
|
||||
|
||||
impl Component for Navbar {
|
||||
|
|
@ -48,6 +50,8 @@ impl Component for Navbar {
|
|||
navbar::Position::StickyBottom => "sticky-bottom",
|
||||
}
|
||||
.to_string(),
|
||||
self.style_bg().to_string(),
|
||||
self.style_text().to_string(),
|
||||
]
|
||||
.join(" "),
|
||||
);
|
||||
|
|
@ -255,6 +259,28 @@ impl Navbar {
|
|||
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.
|
||||
#[inline]
|
||||
pub fn add_item(mut self, item: navbar::Item) -> Self {
|
||||
|
|
@ -291,6 +317,16 @@ impl Navbar {
|
|||
&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`).
|
||||
pub fn items(&self) -> &Children {
|
||||
&self.items
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue