♻️ (bootsier): Renombra traits de extensión
Los traits con los que Bootsier añade métodos a componentes del núcleo pasan de `<Componente>Bootsier` a `<Componente>BsExt`. SelectBootsier se confundiría con componentes como SelectLanguage.
This commit is contained in:
parent
08d673b89d
commit
144127776d
14 changed files with 43 additions and 43 deletions
|
|
@ -70,21 +70,21 @@ mod token;
|
||||||
pub use token::*;
|
pub use token::*;
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use bs::badge::BadgeBootsier;
|
pub use bs::badge::BadgeBsExt;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use bs::button::ButtonBootsier;
|
pub use bs::button::ButtonBsExt;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use bs::dropdown::DropdownBootsier;
|
pub use bs::dropdown::DropdownBsExt;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use bs::form::input::InputBootsier;
|
pub use bs::form::input::InputBsExt;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use bs::form::select::SelectBootsier;
|
pub use bs::form::select::SelectBsExt;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use bs::form::textarea::TextareaBootsier;
|
pub use bs::form::textarea::TextareaBsExt;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use bs::nav::NavBootsier;
|
pub use bs::nav::NavBsExt;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use bs::navbar::NavbarBootsier;
|
pub use bs::navbar::NavbarBsExt;
|
||||||
|
|
||||||
// Añade la clase de un punto de corte con un prefijo y un sufijo (opcional) a la cadena de clases,
|
// Añade la clase de un punto de corte con un prefijo y un sufijo (opcional) a la cadena de clases,
|
||||||
// separada con un espacio de las que ya hubiera: `prefix-name-suffix`, sin `-suffix` si no hay
|
// separada con un espacio de las que ya hubiera: `prefix-name-suffix`, sin `-suffix` si no hay
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ pub(crate) mod layout;
|
||||||
|
|
||||||
// Badge.
|
// Badge.
|
||||||
pub(crate) mod badge;
|
pub(crate) mod badge;
|
||||||
pub use badge::{Badge, BadgeBootsier};
|
pub use badge::{Badge, BadgeBsExt};
|
||||||
|
|
||||||
// Block.
|
// Block.
|
||||||
pub use pagetop::base::component::Block;
|
pub use pagetop::base::component::Block;
|
||||||
|
|
@ -20,7 +20,7 @@ pub use pagetop::base::component::breadcrumb;
|
||||||
|
|
||||||
// Button.
|
// Button.
|
||||||
pub mod button;
|
pub mod button;
|
||||||
pub use button::{Button, ButtonBootsier};
|
pub use button::{Button, ButtonBsExt};
|
||||||
|
|
||||||
// Container.
|
// Container.
|
||||||
pub mod container;
|
pub mod container;
|
||||||
|
|
@ -37,18 +37,18 @@ pub mod dropdown;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use dropdown::Dropdown;
|
pub use dropdown::Dropdown;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use dropdown::DropdownBootsier;
|
pub use dropdown::DropdownBsExt;
|
||||||
|
|
||||||
// Form.
|
// Form.
|
||||||
pub mod form;
|
pub mod form;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use form::Form;
|
pub use form::Form;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use form::input::InputBootsier;
|
pub use form::input::InputBsExt;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use form::select::SelectBootsier;
|
pub use form::select::SelectBsExt;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use form::textarea::TextareaBootsier;
|
pub use form::textarea::TextareaBsExt;
|
||||||
|
|
||||||
// Image.
|
// Image.
|
||||||
pub mod image;
|
pub mod image;
|
||||||
|
|
@ -63,14 +63,14 @@ pub mod nav;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use nav::Nav;
|
pub use nav::Nav;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use nav::NavBootsier;
|
pub use nav::NavBsExt;
|
||||||
|
|
||||||
// Navbar.
|
// Navbar.
|
||||||
pub mod navbar;
|
pub mod navbar;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use navbar::Navbar;
|
pub use navbar::Navbar;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use navbar::NavbarBootsier;
|
pub use navbar::NavbarBsExt;
|
||||||
|
|
||||||
// Offcanvas.
|
// Offcanvas.
|
||||||
pub mod offcanvas;
|
pub mod offcanvas;
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,14 @@ const EXTRA_COLOR: &str = "bootsier.badge.color";
|
||||||
/// let badge = bs::Badge::labeled(Lc::n("Beta")).with_color(BootsierColors::Dark);
|
/// let badge = bs::Badge::labeled(Lc::n("Beta")).with_color(BootsierColors::Dark);
|
||||||
/// ```
|
/// ```
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
pub trait BadgeBootsier {
|
pub trait BadgeBsExt {
|
||||||
/// Fuerza un color de la paleta de Bootsier, ignorando el que le correspondería a la `Intent`
|
/// Fuerza un color de la paleta de Bootsier, ignorando el que le correspondería a la `Intent`
|
||||||
/// del badge. `None` restablece el comportamiento por defecto (color derivado de la `Intent`).
|
/// del badge. `None` restablece el comportamiento por defecto (color derivado de la `Intent`).
|
||||||
fn with_color(self, color: impl Into<Option<BootsierColors>>) -> Self;
|
fn with_color(self, color: impl Into<Option<BootsierColors>>) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
impl BadgeBootsier for Badge {
|
impl BadgeBsExt for Badge {
|
||||||
fn with_color(mut self, color: impl Into<Option<BootsierColors>>) -> Self {
|
fn with_color(mut self, color: impl Into<Option<BootsierColors>>) -> Self {
|
||||||
match color.into() {
|
match color.into() {
|
||||||
Some(color) => self.alter_prop(PropsOp::set_extra(EXTRA_COLOR, color)),
|
Some(color) => self.alter_prop(PropsOp::set_extra(EXTRA_COLOR, color)),
|
||||||
|
|
@ -41,7 +41,7 @@ impl BadgeBootsier for Badge {
|
||||||
pub(crate) fn setup(badge: &mut Badge) {
|
pub(crate) fn setup(badge: &mut Badge) {
|
||||||
// `Badge::setup()` (core) ya ha traducido la intención con `Theme::intent_color()`. La clase
|
// `Badge::setup()` (core) ya ha traducido la intención con `Theme::intent_color()`. La clase
|
||||||
// `badge-*` que hay que localizar es siempre la derivada de la `Intent`, con independencia de
|
// `badge-*` que hay que localizar es siempre la derivada de la `Intent`, con independencia de
|
||||||
// que `BadgeBootsier::with_color()` fuerce un color distinto para el destino `text-bg-*`.
|
// que `BadgeBsExt::with_color()` fuerce un color distinto para el destino `text-bg-*`.
|
||||||
let intent_color = BootsierColors::from(badge.intent()).as_str();
|
let intent_color = BootsierColors::from(badge.intent()).as_str();
|
||||||
let color = badge
|
let color = badge
|
||||||
.props()
|
.props()
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ const EXTRA_ACTIVE: &str = "bootsier.button.active";
|
||||||
const EXTRA_FULL_WIDTH: &str = "bootsier.button.full_width";
|
const EXTRA_FULL_WIDTH: &str = "bootsier.button.full_width";
|
||||||
const EXTRA_COLOR: &str = "bootsier.button.color";
|
const EXTRA_COLOR: &str = "bootsier.button.color";
|
||||||
|
|
||||||
// **< ButtonBootsier >*****************************************************************************
|
// **< ButtonBsExt >********************************************************************************
|
||||||
|
|
||||||
/// Extensión de Bootsier para [`Button`].
|
/// Extensión de Bootsier para [`Button`].
|
||||||
///
|
///
|
||||||
|
|
@ -36,7 +36,7 @@ const EXTRA_COLOR: &str = "bootsier.button.color";
|
||||||
/// .with_color(BootsierColors::Light);
|
/// .with_color(BootsierColors::Light);
|
||||||
/// ```
|
/// ```
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
pub trait ButtonBootsier {
|
pub trait ButtonBsExt {
|
||||||
/// Marca el botón como activo (`.active`, `aria-pressed="true"`).
|
/// Marca el botón como activo (`.active`, `aria-pressed="true"`).
|
||||||
fn with_active(self, active: bool) -> Self;
|
fn with_active(self, active: bool) -> Self;
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ pub trait ButtonBootsier {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
impl ButtonBootsier for Button {
|
impl ButtonBsExt for Button {
|
||||||
fn with_active(mut self, active: bool) -> Self {
|
fn with_active(mut self, active: bool) -> Self {
|
||||||
self.alter_prop(PropsOp::set_extra(EXTRA_ACTIVE, active));
|
self.alter_prop(PropsOp::set_extra(EXTRA_ACTIVE, active));
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ const EXTRA_MENU_POSITION: &str = "bootsier.dropdown.menu_position";
|
||||||
/// .with_item(bs::dropdown::Item::button(Lc::n("Sign out")));
|
/// .with_item(bs::dropdown::Item::button(Lc::n("Sign out")));
|
||||||
/// ```
|
/// ```
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
pub trait DropdownBootsier {
|
pub trait DropdownBsExt {
|
||||||
/// Indica si el botón del menú está integrado en un grupo de botones.
|
/// Indica si el botón del menú está integrado en un grupo de botones.
|
||||||
fn with_button_grouped(self, grouped: bool) -> Self;
|
fn with_button_grouped(self, grouped: bool) -> Self;
|
||||||
|
|
||||||
|
|
@ -68,7 +68,7 @@ pub trait DropdownBootsier {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
impl DropdownBootsier for Dropdown {
|
impl DropdownBsExt for Dropdown {
|
||||||
fn with_button_grouped(mut self, grouped: bool) -> Self {
|
fn with_button_grouped(mut self, grouped: bool) -> Self {
|
||||||
self.alter_prop(PropsOp::set_extra(EXTRA_BUTTON_GROUPED, grouped));
|
self.alter_prop(PropsOp::set_extra(EXTRA_BUTTON_GROUPED, grouped));
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,16 @@ pub use pagetop::base::component::form::radio;
|
||||||
|
|
||||||
pub mod select;
|
pub mod select;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use select::SelectBootsier;
|
pub use select::SelectBsExt;
|
||||||
|
|
||||||
pub mod input;
|
pub mod input;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use input::InputBootsier;
|
pub use input::InputBsExt;
|
||||||
|
|
||||||
pub mod textarea;
|
pub mod textarea;
|
||||||
pub use textarea::Textarea;
|
pub use textarea::Textarea;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use textarea::TextareaBootsier;
|
pub use textarea::TextareaBsExt;
|
||||||
|
|
||||||
pub use pagetop::base::component::form::Number;
|
pub use pagetop::base::component::form::Number;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const EXTRA_FLOATING_LABEL: &str = "bootsier.form.input.floating_label";
|
||||||
/// .with_floating_label(true);
|
/// .with_floating_label(true);
|
||||||
/// ```
|
/// ```
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
pub trait InputBootsier {
|
pub trait InputBsExt {
|
||||||
/// Establece si la etiqueta se muestra flotante sobre el campo.
|
/// Establece si la etiqueta se muestra flotante sobre el campo.
|
||||||
///
|
///
|
||||||
/// Cuando está activo, la etiqueta se superpone al campo y asciende al enfocarlo o cuando tiene
|
/// Cuando está activo, la etiqueta se superpone al campo y asciende al enfocarlo o cuando tiene
|
||||||
|
|
@ -33,7 +33,7 @@ pub trait InputBootsier {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
impl InputBootsier for Field {
|
impl InputBsExt for Field {
|
||||||
fn with_floating_label(mut self, floating: bool) -> Self {
|
fn with_floating_label(mut self, floating: bool) -> Self {
|
||||||
self.alter_prop(PropsOp::set_extra(EXTRA_FLOATING_LABEL, floating));
|
self.alter_prop(PropsOp::set_extra(EXTRA_FLOATING_LABEL, floating));
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ const EXTRA_FLOATING_LABEL: &str = "bootsier.form.select.floating_label";
|
||||||
/// .with_item(bs::form::select::Item::new("en", Lc::n("English")));
|
/// .with_item(bs::form::select::Item::new("en", Lc::n("English")));
|
||||||
/// ```
|
/// ```
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
pub trait SelectBootsier {
|
pub trait SelectBsExt {
|
||||||
/// Establece si la etiqueta se muestra flotante sobre el campo.
|
/// Establece si la etiqueta se muestra flotante sobre el campo.
|
||||||
///
|
///
|
||||||
/// Cuando está activo, la etiqueta se superpone al control y permanece flotante siempre que
|
/// Cuando está activo, la etiqueta se superpone al control y permanece flotante siempre que
|
||||||
|
|
@ -38,7 +38,7 @@ pub trait SelectBootsier {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
impl SelectBootsier for Field {
|
impl SelectBsExt for Field {
|
||||||
fn with_floating_label(mut self, floating: bool) -> Self {
|
fn with_floating_label(mut self, floating: bool) -> Self {
|
||||||
self.alter_prop(PropsOp::set_extra(EXTRA_FLOATING_LABEL, floating));
|
self.alter_prop(PropsOp::set_extra(EXTRA_FLOATING_LABEL, floating));
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const EXTRA_FLOATING_LABEL: &str = "bootsier.form.textarea.floating_label";
|
||||||
/// .with_floating_label(true);
|
/// .with_floating_label(true);
|
||||||
/// ```
|
/// ```
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
pub trait TextareaBootsier {
|
pub trait TextareaBsExt {
|
||||||
/// Establece si la etiqueta se muestra flotante sobre el campo.
|
/// Establece si la etiqueta se muestra flotante sobre el campo.
|
||||||
///
|
///
|
||||||
/// Cuando está activo, la etiqueta se superpone al área de texto y asciende al enfocarlo o
|
/// Cuando está activo, la etiqueta se superpone al área de texto y asciende al enfocarlo o
|
||||||
|
|
@ -36,7 +36,7 @@ pub trait TextareaBootsier {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
impl TextareaBootsier for Textarea {
|
impl TextareaBsExt for Textarea {
|
||||||
fn with_floating_label(mut self, floating: bool) -> Self {
|
fn with_floating_label(mut self, floating: bool) -> Self {
|
||||||
self.alter_prop(PropsOp::set_extra(EXTRA_FLOATING_LABEL, floating));
|
self.alter_prop(PropsOp::set_extra(EXTRA_FLOATING_LABEL, floating));
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ pub use pagetop::base::component::nav::{Item, ItemKind};
|
||||||
|
|
||||||
const EXTRA_KIND: &str = "bootsier.nav.kind";
|
const EXTRA_KIND: &str = "bootsier.nav.kind";
|
||||||
|
|
||||||
// Marca interna (nunca expuesta en `NavBootsier`) que `theme::bs::navbar::item` fija sobre el clon
|
// Marca interna (nunca expuesta en `NavBsExt`) que `theme::bs::navbar::item` fija sobre el clon de
|
||||||
// de un `Nav` embebido en una `Navbar`, para que use `navbar-nav` en vez de `nav` como clase base.
|
// un `Nav` embebido en una `Navbar`, para que use `navbar-nav` en vez de `nav` como clase base.
|
||||||
pub(crate) const EXTRA_IN_NAVBAR: &str = "bootsier.nav.in_navbar";
|
pub(crate) const EXTRA_IN_NAVBAR: &str = "bootsier.nav.in_navbar";
|
||||||
|
|
||||||
/// Extensión de Bootsier para [`Nav`].
|
/// Extensión de Bootsier para [`Nav`].
|
||||||
|
|
@ -47,13 +47,13 @@ pub(crate) const EXTRA_IN_NAVBAR: &str = "bootsier.nav.in_navbar";
|
||||||
/// .with_item(bs::nav::Item::link_disabled(Lc::n("Disabled"), "#"));
|
/// .with_item(bs::nav::Item::link_disabled(Lc::n("Disabled"), "#"));
|
||||||
/// ```
|
/// ```
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
pub trait NavBootsier {
|
pub trait NavBsExt {
|
||||||
/// Cambia el estilo del menú (*Tabs*, *Pills*, *Underline* o *Default*).
|
/// Cambia el estilo del menú (*Tabs*, *Pills*, *Underline* o *Default*).
|
||||||
fn with_kind(self, kind: Kind) -> Self;
|
fn with_kind(self, kind: Kind) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
impl NavBootsier for Nav {
|
impl NavBsExt for Nav {
|
||||||
fn with_kind(mut self, kind: Kind) -> Self {
|
fn with_kind(mut self, kind: Kind) -> Self {
|
||||||
self.alter_prop(PropsOp::set_extra(EXTRA_KIND, kind));
|
self.alter_prop(PropsOp::set_extra(EXTRA_KIND, kind));
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ mod panel;
|
||||||
pub use panel::Panel;
|
pub use panel::Panel;
|
||||||
|
|
||||||
mod component;
|
mod component;
|
||||||
pub use component::NavbarBootsier;
|
pub use component::NavbarBsExt;
|
||||||
pub(crate) use component::{render, setup};
|
pub(crate) use component::{render, setup};
|
||||||
|
|
||||||
mod item;
|
mod item;
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ const EXTRA_LAYOUT: &str = "bootsier.navbar.layout";
|
||||||
/// ));
|
/// ));
|
||||||
/// ```
|
/// ```
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
pub trait NavbarBootsier {
|
pub trait NavbarBsExt {
|
||||||
/// Crea una barra de navegación cuyo contenido se muestra en un panel lateral.
|
/// Crea una barra de navegación cuyo contenido se muestra en un panel lateral.
|
||||||
fn offcanvas(panel: bs::navbar::Panel) -> Self;
|
fn offcanvas(panel: bs::navbar::Panel) -> Self;
|
||||||
|
|
||||||
|
|
@ -154,7 +154,7 @@ pub trait NavbarBootsier {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[builder_impl]
|
#[builder_impl]
|
||||||
impl NavbarBootsier for Navbar {
|
impl NavbarBsExt for Navbar {
|
||||||
fn offcanvas(panel: bs::navbar::Panel) -> Self {
|
fn offcanvas(panel: bs::navbar::Panel) -> Self {
|
||||||
let mut navbar = Self::new();
|
let mut navbar = Self::new();
|
||||||
navbar.alter_prop(PropsOp::set_extra(
|
navbar.alter_prop(PropsOp::set_extra(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Verifies `BadgeBootsier::with_color()`: it overrides the Bootstrap color that `Badge` would
|
// Verifies `BadgeBsExt::with_color()`: it overrides the Bootstrap color that `Badge` would
|
||||||
// otherwise derive from its `Intent`, without disturbing the class that `Badge::setup()` (core)
|
// otherwise derive from its `Intent`, without disturbing the class that `Badge::setup()` (core)
|
||||||
// already generated from that `Intent`.
|
// already generated from that `Intent`.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,8 @@
|
||||||
//! [`PropsOp::set_extra()`] para consumirlos en el `setup()` vía [`Theme::setup_component()`] o
|
//! [`PropsOp::set_extra()`] para consumirlos en el `setup()` vía [`Theme::setup_component()`] o
|
||||||
//! en el `render()` vía [`Theme::render_component()`]), o aportar componentes propios.
|
//! en el `render()` vía [`Theme::render_component()`]), o aportar componentes propios.
|
||||||
//! `pagetop-bootsier` combina las tres estrategias: reexporta `Form`/`Fieldset` sin cambios,
|
//! `pagetop-bootsier` combina las tres estrategias: reexporta `Form`/`Fieldset` sin cambios,
|
||||||
//! extiende `Button`/`Badge`/`Dropdown`/`Nav`/`Navbar` con sus propios traits (`ButtonBootsier`,
|
//! extiende `Button`/`Badge`/`Dropdown`/`Nav`/`Navbar` con sus propios traits (`ButtonBsExt`,
|
||||||
//! `BadgeBootsier`, etc.), y añade componentes propios como `Offcanvas`.
|
//! `BadgeBsExt`, etc.), y añade componentes propios como `Offcanvas`.
|
||||||
//!
|
//!
|
||||||
//! Para forzar una plantilla completamente distinta en una página concreta, se puede llamar
|
//! Para forzar una plantilla completamente distinta en una página concreta, se puede llamar
|
||||||
//! manualmente a [`with_template()`].
|
//! manualmente a [`with_template()`].
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue