104 lines
4.5 KiB
Rust
104 lines
4.5 KiB
Rust
use pagetop::prelude::*;
|
|
|
|
include_locales!(LOC from "examples/locale");
|
|
|
|
struct SuperMenu;
|
|
|
|
#[async_trait]
|
|
impl Extension for SuperMenu {
|
|
fn dependencies(&self) -> Vec<ExtensionRef> {
|
|
vec![
|
|
&pagetop_aliner::Aliner,
|
|
&pagetop_bootsier::Bootsier,
|
|
&pagetop::base::extension::Welcome,
|
|
]
|
|
}
|
|
|
|
async fn initialize(&self) {
|
|
let navbar_menu = Navbar::brand_left(Brand::new())
|
|
.with_expand(Breakpoint::Lg)
|
|
.with_item(navbar::Item::nav(
|
|
Nav::new()
|
|
.with_item(nav::Item::link(Lc::t("menus_item_link", &LOC), "/"))
|
|
.with_item(nav::Item::link_blank(
|
|
Lc::t("menus_item_blank", &LOC),
|
|
"https://docs.rs/pagetop",
|
|
))
|
|
.with_item(nav::Item::dropdown(
|
|
Dropdown::new()
|
|
.with_title(Lc::t("menus_test_title", &LOC))
|
|
.with_item(dropdown::Item::header(Lc::t("menus_dev_header", &LOC)))
|
|
.with_item(dropdown::Item::link(
|
|
Lc::t("menus_dev_getting_started", &LOC),
|
|
"/dev/getting-started",
|
|
))
|
|
.with_item(dropdown::Item::link(
|
|
Lc::t("menus_dev_guides", &LOC),
|
|
"/dev/guides",
|
|
))
|
|
.with_item(dropdown::Item::link_blank(
|
|
Lc::t("menus_dev_forum", &LOC),
|
|
"https://forum.example.dev",
|
|
))
|
|
.with_item(dropdown::Item::divider())
|
|
.with_item(dropdown::Item::header(Lc::t("menus_sdk_header", &LOC)))
|
|
.with_item(dropdown::Item::link(
|
|
Lc::t("menus_sdk_rust", &LOC),
|
|
"/dev/sdks/rust",
|
|
))
|
|
.with_item(dropdown::Item::link(
|
|
Lc::t("menus_sdk_js", &LOC),
|
|
"/dev/sdks/js",
|
|
))
|
|
.with_item(dropdown::Item::link(
|
|
Lc::t("menus_sdk_python", &LOC),
|
|
"/dev/sdks/python",
|
|
))
|
|
.with_item(dropdown::Item::divider())
|
|
.with_item(dropdown::Item::header(Lc::t("menus_plugin_header", &LOC)))
|
|
.with_item(dropdown::Item::link(
|
|
Lc::t("menus_plugin_auth", &LOC),
|
|
"/dev/sdks/rust/plugins/auth",
|
|
))
|
|
.with_item(dropdown::Item::link(
|
|
Lc::t("menus_plugin_cache", &LOC),
|
|
"/dev/sdks/rust/plugins/cache",
|
|
))
|
|
.with_item(dropdown::Item::divider())
|
|
.with_item(dropdown::Item::label(Lc::t("menus_item_label", &LOC)))
|
|
.with_item(dropdown::Item::link_disabled(
|
|
Lc::t("menus_item_disabled", &LOC),
|
|
"#",
|
|
)),
|
|
))
|
|
.with_item(nav::Item::link_disabled(
|
|
Lc::t("menus_item_disabled", &LOC),
|
|
"#",
|
|
)),
|
|
))
|
|
.with_item(navbar::Item::nav(
|
|
Nav::new()
|
|
// Empuja este menú (y lo que le siga) al extremo final de la barra.
|
|
.with_prop(FlexItem::push_end())
|
|
.with_item(nav::Item::link(
|
|
Lc::t("menus_item_sign_up", &LOC),
|
|
"/auth/sign-up",
|
|
))
|
|
.with_item(nav::Item::link(
|
|
Lc::t("menus_item_login", &LOC),
|
|
"/auth/login",
|
|
)),
|
|
));
|
|
|
|
InRegion::Global(&CoreRegions::Header).add(
|
|
Container::new()
|
|
.with_width(container::Width::FluidMax(UnitValue::RelRem(75.0)))
|
|
.with_child(navbar_menu),
|
|
);
|
|
}
|
|
}
|
|
|
|
#[pagetop::main]
|
|
async fn main() -> std::io::Result<()> {
|
|
Application::prepare(&SuperMenu).await.run().await
|
|
}
|