✨ (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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue