✨ (base): Añade componentes Nav y Navbar
Dropdown incorpora tamaño y estilo de botón configurables (`button::Size`/`Style`), reutilizados también por Navbar. El tema Basic sirve `basic.min.css` y añade el JS de inicialización de Navbar.
This commit is contained in:
parent
da959183f6
commit
35ae5bb6a8
22 changed files with 1695 additions and 280 deletions
46
examples/basic-nav.rs
Normal file
46
examples/basic-nav.rs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
struct NavDemo;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for NavDemo {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![&pagetop::base::extension::Welcome]
|
||||
}
|
||||
|
||||
async fn initialize(&self) {
|
||||
let main_nav = Nav::new()
|
||||
.with_item(nav::Item::link(Lc::n("Home"), "/"))
|
||||
.with_item(nav::Item::link_blank(
|
||||
Lc::n("Docs"),
|
||||
"https://docs.rs/pagetop",
|
||||
))
|
||||
.with_item(nav::Item::dropdown(
|
||||
Dropdown::new()
|
||||
.with_title(Lc::n("Tools"))
|
||||
.with_item(dropdown::Item::link(Lc::n("Generator"), "/tools/gen"))
|
||||
.with_item(dropdown::Item::link(Lc::n("Reports"), "/tools/reports"))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::header(Lc::n("Danger zone")))
|
||||
.with_item(dropdown::Item::button(Lc::n("Reset settings"))),
|
||||
))
|
||||
.with_item(nav::Item::link_disabled(Lc::n("Disabled"), "#"));
|
||||
|
||||
let user_menu = Dropdown::new()
|
||||
.with_title(Lc::n("Account"))
|
||||
.with_item(dropdown::Item::label(Lc::n("Signed in as demo")))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::link(Lc::n("Profile"), "/profile"))
|
||||
.with_item(dropdown::Item::link(Lc::n("Settings"), "/settings"))
|
||||
.with_item(dropdown::Item::divider())
|
||||
.with_item(dropdown::Item::button(Lc::n("Sign out")));
|
||||
|
||||
InRegion::Global(&CoreRegions::Header).add(main_nav);
|
||||
InRegion::Global(&CoreRegions::Aside).add(user_menu);
|
||||
}
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&NavDemo).await.run().await
|
||||
}
|
||||
55
examples/basic-navbar.rs
Normal file
55
examples/basic-navbar.rs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
include_locales!(LOC from "examples/locale");
|
||||
|
||||
struct NavbarDemo;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for NavbarDemo {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![
|
||||
&pagetop_bootsier::Bootsier,
|
||||
&pagetop::base::extension::Welcome,
|
||||
]
|
||||
}
|
||||
|
||||
async fn initialize(&self) {
|
||||
let brand = Brand::new()
|
||||
.with_image(image::Source::logo(PageTopSvg::Color))
|
||||
.with_title(Lc::n("PageTop"))
|
||||
.with_route(Route::from("/"));
|
||||
|
||||
let main_nav = Nav::new()
|
||||
.with_item(nav::Item::link(Lc::t("navbar_home", &LOC), "/"))
|
||||
.with_item(nav::Item::link_blank(
|
||||
Lc::t("navbar_docs", &LOC),
|
||||
"https://docs.rs/pagetop",
|
||||
))
|
||||
.with_item(nav::Item::dropdown(
|
||||
Dropdown::new()
|
||||
.with_title(Lc::t("navbar_tools", &LOC))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("navbar_generator", &LOC),
|
||||
"/tools/gen",
|
||||
))
|
||||
.with_item(dropdown::Item::link(
|
||||
Lc::t("navbar_reports", &LOC),
|
||||
"/tools/reports",
|
||||
)),
|
||||
))
|
||||
.with_item(nav::Item::link(Lc::t("navbar_active", &LOC), "/active").with_active(true))
|
||||
.with_item(nav::Item::link_disabled(
|
||||
Lc::t("navbar_disabled", &LOC),
|
||||
"#",
|
||||
));
|
||||
|
||||
let navbar = Navbar::brand_left(brand).with_item(navbar::Item::nav(main_nav));
|
||||
|
||||
InRegion::Global(&CoreRegions::Header).add(navbar);
|
||||
}
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&NavbarDemo).await.run().await
|
||||
}
|
||||
7
examples/locale/en-US/basic-navbar.ftl
Normal file
7
examples/locale/en-US/basic-navbar.ftl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
navbar_home = Home
|
||||
navbar_docs = Docs
|
||||
navbar_tools = Tools
|
||||
navbar_generator = Generator
|
||||
navbar_reports = Reports
|
||||
navbar_active = Active page
|
||||
navbar_disabled = Disabled
|
||||
7
examples/locale/es-ES/basic-navbar.ftl
Normal file
7
examples/locale/es-ES/basic-navbar.ftl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
navbar_home = Inicio
|
||||
navbar_docs = Documentación
|
||||
navbar_tools = Herramientas
|
||||
navbar_generator = Generador
|
||||
navbar_reports = Informes
|
||||
navbar_active = Página activa
|
||||
navbar_disabled = Deshabilitado
|
||||
Loading…
Add table
Add a link
Reference in a new issue