🔧 Adapta ejemplos a la nueva estructura de bs::

This commit is contained in:
Manuel Cillero 2026-06-29 20:41:06 +02:00
parent f37db56ec5
commit ee6457acf6
2 changed files with 68 additions and 57 deletions

View file

@ -1,6 +1,4 @@
use pagetop::prelude::*; use pagetop::prelude::*;
use pagetop_bootsier::theme::form;
use pagetop_bootsier::theme::*; use pagetop_bootsier::theme::*;
include_locales!(LOC from "examples/locale"); include_locales!(LOC from "examples/locale");
@ -145,18 +143,18 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
) )
// Botones de acción. // Botones de acción.
.with_child(Button::submit(L10n::t("btn_submit", &LOC)).with_prop( .with_child(Button::submit(L10n::t("btn_submit", &LOC)).with_prop(
PropsOp::add_classes(classes::ButtonColor::solid( PropsOp::add_classes(class::ButtonColor::solid(
Color::Primary, token::Color::Primary,
)), )),
)) ))
.with_child(Button::reset(L10n::t("btn_reset", &LOC)).with_prop( .with_child(Button::reset(L10n::t("btn_reset", &LOC)).with_prop(
PropsOp::add_classes(classes::ButtonColor::outline( PropsOp::add_classes(class::ButtonColor::outline(
Color::Secondary, token::Color::Secondary,
)), )),
)) ))
.with_child( .with_child(
Button::plain(L10n::t("btn_cancel", &LOC)).with_prop( Button::plain(L10n::t("btn_cancel", &LOC)).with_prop(
PropsOp::add_classes(classes::ButtonColor::link()), PropsOp::add_classes(class::ButtonColor::link()),
), ),
), ),
), ),
@ -269,18 +267,18 @@ async fn form_controls(request: HttpRequest) -> Result<Markup, ErrorPage> {
) )
// Botones de acción. // Botones de acción.
.with_child(Button::submit(L10n::t("btn_submit", &LOC)).with_prop( .with_child(Button::submit(L10n::t("btn_submit", &LOC)).with_prop(
PropsOp::add_classes(classes::ButtonColor::solid( PropsOp::add_classes(class::ButtonColor::solid(
Color::Primary, token::Color::Primary,
)), )),
)) ))
.with_child(Button::reset(L10n::t("btn_reset", &LOC)).with_prop( .with_child(Button::reset(L10n::t("btn_reset", &LOC)).with_prop(
PropsOp::add_classes(classes::ButtonColor::outline( PropsOp::add_classes(class::ButtonColor::outline(
Color::Secondary, token::Color::Secondary,
)), )),
)) ))
.with_child( .with_child(
Button::plain(L10n::t("btn_cancel", &LOC)).with_prop( Button::plain(L10n::t("btn_cancel", &LOC)).with_prop(
PropsOp::add_classes(classes::ButtonColor::link()), PropsOp::add_classes(class::ButtonColor::link()),
), ),
), ),
), ),
@ -423,17 +421,17 @@ fn form_lists() -> Form {
// Botones de acción. // Botones de acción.
.with_child( .with_child(
Button::submit(L10n::t("btn_submit", &LOC)).with_prop(PropsOp::add_classes( Button::submit(L10n::t("btn_submit", &LOC)).with_prop(PropsOp::add_classes(
classes::ButtonColor::solid(Color::Primary), class::ButtonColor::solid(token::Color::Primary),
)), )),
) )
.with_child( .with_child(
Button::reset(L10n::t("btn_reset", &LOC)).with_prop(PropsOp::add_classes( Button::reset(L10n::t("btn_reset", &LOC)).with_prop(PropsOp::add_classes(
classes::ButtonColor::outline(Color::Secondary), class::ButtonColor::outline(token::Color::Secondary),
)), )),
) )
.with_child( .with_child(
Button::plain(L10n::t("btn_cancel", &LOC)) Button::plain(L10n::t("btn_cancel", &LOC))
.with_prop(PropsOp::add_classes(classes::ButtonColor::link())), .with_prop(PropsOp::add_classes(class::ButtonColor::link())),
) )
} }

View file

@ -1,5 +1,4 @@
use pagetop::prelude::*; use pagetop::prelude::*;
use pagetop_bootsier::theme::*; use pagetop_bootsier::theme::*;
include_locales!(LOC from "examples/locale"); include_locales!(LOC from "examples/locale");
@ -16,84 +15,98 @@ impl Extension for SuperMenu {
} }
fn initialize(&self) { fn initialize(&self) {
let navbar_menu = Navbar::brand_left(navbar::Brand::new()) let navbar_menu = bs::Navbar::brand_left(bs::navbar::Brand::new())
.with_expand(BreakPoint::LG) .with_expand(token::BreakPoint::LG)
.with_item(navbar::Item::nav( .with_item(bs::navbar::Item::nav(
Nav::new() bs::Nav::new()
.with_item(nav::Item::link(L10n::t("menus_item_link", &LOC), |cx| { .with_item(bs::nav::Item::link(
cx.route("/") L10n::t("menus_item_link", &LOC),
})) |cx| cx.route("/"),
.with_item(nav::Item::link_blank( ))
.with_item(bs::nav::Item::link_blank(
L10n::t("menus_item_blank", &LOC), L10n::t("menus_item_blank", &LOC),
|_| "https://docs.rs/pagetop".into(), |_| "https://docs.rs/pagetop".into(),
)) ))
.with_item(nav::Item::dropdown( .with_item(bs::nav::Item::dropdown(
Dropdown::new() bs::Dropdown::new()
.with_title(L10n::t("menus_test_title", &LOC)) .with_title(L10n::t("menus_test_title", &LOC))
.with_item(dropdown::Item::header(L10n::t("menus_dev_header", &LOC))) .with_item(bs::dropdown::Item::header(L10n::t(
.with_item(dropdown::Item::link( "menus_dev_header",
&LOC,
)))
.with_item(bs::dropdown::Item::link(
L10n::t("menus_dev_getting_started", &LOC), L10n::t("menus_dev_getting_started", &LOC),
|cx| cx.route("/dev/getting-started"), |cx| cx.route("/dev/getting-started"),
)) ))
.with_item(dropdown::Item::link( .with_item(bs::dropdown::Item::link(
L10n::t("menus_dev_guides", &LOC), L10n::t("menus_dev_guides", &LOC),
|cx| cx.route("/dev/guides"), |cx| cx.route("/dev/guides"),
)) ))
.with_item(dropdown::Item::link_blank( .with_item(bs::dropdown::Item::link_blank(
L10n::t("menus_dev_forum", &LOC), L10n::t("menus_dev_forum", &LOC),
|_| "https://forum.example.dev".into(), |_| "https://forum.example.dev".into(),
)) ))
.with_item(dropdown::Item::divider()) .with_item(bs::dropdown::Item::divider())
.with_item(dropdown::Item::header(L10n::t("menus_sdk_header", &LOC))) .with_item(bs::dropdown::Item::header(L10n::t(
.with_item(dropdown::Item::link( "menus_sdk_header",
&LOC,
)))
.with_item(bs::dropdown::Item::link(
L10n::t("menus_sdk_rust", &LOC), L10n::t("menus_sdk_rust", &LOC),
|cx| cx.route("/dev/sdks/rust"), |cx| cx.route("/dev/sdks/rust"),
)) ))
.with_item(dropdown::Item::link(L10n::t("menus_sdk_js", &LOC), |cx| { .with_item(bs::dropdown::Item::link(
cx.route("/dev/sdks/js") L10n::t("menus_sdk_js", &LOC),
})) |cx| cx.route("/dev/sdks/js"),
.with_item(dropdown::Item::link( ))
.with_item(bs::dropdown::Item::link(
L10n::t("menus_sdk_python", &LOC), L10n::t("menus_sdk_python", &LOC),
|cx| cx.route("/dev/sdks/python"), |cx| cx.route("/dev/sdks/python"),
)) ))
.with_item(dropdown::Item::divider()) .with_item(bs::dropdown::Item::divider())
.with_item(dropdown::Item::header(L10n::t("menus_plugin_header", &LOC))) .with_item(bs::dropdown::Item::header(L10n::t(
.with_item(dropdown::Item::link( "menus_plugin_header",
&LOC,
)))
.with_item(bs::dropdown::Item::link(
L10n::t("menus_plugin_auth", &LOC), L10n::t("menus_plugin_auth", &LOC),
|cx| cx.route("/dev/sdks/rust/plugins/auth"), |cx| cx.route("/dev/sdks/rust/plugins/auth"),
)) ))
.with_item(dropdown::Item::link( .with_item(bs::dropdown::Item::link(
L10n::t("menus_plugin_cache", &LOC), L10n::t("menus_plugin_cache", &LOC),
|cx| cx.route("/dev/sdks/rust/plugins/cache"), |cx| cx.route("/dev/sdks/rust/plugins/cache"),
)) ))
.with_item(dropdown::Item::divider()) .with_item(bs::dropdown::Item::divider())
.with_item(dropdown::Item::label(L10n::t("menus_item_label", &LOC))) .with_item(bs::dropdown::Item::label(L10n::t("menus_item_label", &LOC)))
.with_item(dropdown::Item::link_disabled( .with_item(bs::dropdown::Item::link_disabled(
L10n::t("menus_item_disabled", &LOC), L10n::t("menus_item_disabled", &LOC),
|cx| cx.route("#"), |cx| cx.route("#"),
)), )),
)) ))
.with_item(nav::Item::link_disabled( .with_item(bs::nav::Item::link_disabled(
L10n::t("menus_item_disabled", &LOC), L10n::t("menus_item_disabled", &LOC),
|cx| cx.route("#"), |cx| cx.route("#"),
)), )),
)) ))
.with_item(navbar::Item::nav( .with_item(bs::navbar::Item::nav(
Nav::new() bs::Nav::new()
.with_prop(PropsOp::add_classes( .with_prop(PropsOp::add_classes(class::Margin::with(
classes::Margin::with(Side::Start, ScaleSize::Auto).to_class(), token::Side::Start,
token::ScaleSize::Auto,
)))
.with_item(bs::nav::Item::link(
L10n::t("menus_item_sign_up", &LOC),
|cx| cx.route("/auth/sign-up"),
)) ))
.with_item(nav::Item::link(L10n::t("menus_item_sign_up", &LOC), |cx| { .with_item(bs::nav::Item::link(
cx.route("/auth/sign-up") L10n::t("menus_item_login", &LOC),
})) |cx| cx.route("/auth/login"),
.with_item(nav::Item::link(L10n::t("menus_item_login", &LOC), |cx| { )),
cx.route("/auth/login")
})),
)); ));
InRegion::Global(&DefaultRegion::Header).add( InRegion::Global(&DefaultRegion::Header).add(
Container::new() bs::Container::new()
.with_width(container::Width::FluidMax(UnitValue::RelRem(75.0))) .with_width(bs::container::Width::FluidMax(UnitValue::RelRem(75.0)))
.with_child(navbar_menu), .with_child(navbar_menu),
); );
} }