📝 Repasa doc de Dropdown, Nav y Offcanvas
This commit is contained in:
parent
b26c221f0d
commit
2721fce85b
8 changed files with 124 additions and 108 deletions
|
|
@ -8,25 +8,8 @@ use crate::prelude::*;
|
|||
/// como *pestañas* (`Tabs`), *botones* (`Pills`) o *subrayado* (`Underline`). También permite
|
||||
/// controlar su distribución y orientación ([`nav::Layout`](crate::theme::nav::Layout)).
|
||||
///
|
||||
/// # Ejemplo
|
||||
///
|
||||
/// ```rust
|
||||
/// # use pagetop::prelude::*;
|
||||
/// # use pagetop_bootsier::prelude::*;
|
||||
/// let nav = Nav::tabs()
|
||||
/// .with_layout(nav::Layout::End)
|
||||
/// .add_item(nav::Item::link(L10n::n("Home"), |_| "/"))
|
||||
/// .add_item(nav::Item::link_blank(L10n::n("External"), |_| "https://www.google.es"))
|
||||
/// .add_item(nav::Item::dropdown(
|
||||
/// Dropdown::new()
|
||||
/// .with_title(L10n::n("Options"))
|
||||
/// .with_items(TypedOp::AddMany(vec![
|
||||
/// Typed::with(dropdown::Item::link(L10n::n("Action"), |_| "/action")),
|
||||
/// Typed::with(dropdown::Item::link(L10n::n("Another action"), |_| "/another")),
|
||||
/// ])),
|
||||
/// ))
|
||||
/// .add_item(nav::Item::link_disabled(L10n::n("Disabled"), |_| "#"));
|
||||
/// ```
|
||||
/// Ver ejemplo en el módulo [`nav`].
|
||||
/// Si no contiene elementos, el componente **no se renderiza**.
|
||||
#[rustfmt::skip]
|
||||
#[derive(AutoDefault)]
|
||||
pub struct Nav {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ impl Component for Item {
|
|||
|
||||
ItemKind::Label(label) => PrepareMarkup::With(html! {
|
||||
li id=[self.id()] class=[self.classes().get()] {
|
||||
span {
|
||||
span class="nav-link disabled" aria-disabled="true" {
|
||||
(label.using(cx))
|
||||
}
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ impl Component for Item {
|
|||
} => {
|
||||
let path = path(cx);
|
||||
let current_path = cx.request().map(|request| request.path());
|
||||
let is_current = !*disabled && current_path.map_or(false, |p| p == path);
|
||||
let is_current = !*disabled && (current_path == Some(path));
|
||||
|
||||
let mut classes = "nav-link".to_string();
|
||||
if is_current {
|
||||
|
|
@ -250,7 +250,7 @@ impl Item {
|
|||
&self.classes
|
||||
}
|
||||
|
||||
/// Devuelve el tipo de elemento representado por este elemento.
|
||||
/// Devuelve el tipo de elemento representado.
|
||||
pub fn item_kind(&self) -> &ItemKind {
|
||||
&self.item_kind
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue