pub struct NavList<S> { /* private fields */ }Expand description
A list of links to the sections of an application, marking the one the page is in.
It is a <nav> named by its label, holding a list of links. The page
passes its own Url, which the server writes with Route::url, and
each link is compared with it by path, without the query string. A link
to the page’s path has aria-current="page". A link to a path that the
page’s path continues, such as /users on the page /users/7, has
aria-current="true", so the section stays marked on the pages under it.
use hypersig::{Page, Route, Signals};
use hypersig_ui::NavList;
use serde::{Deserialize, Serialize};
#[derive(Signals, Serialize, Deserialize)]
struct Admin {
name: String,
}
hypersig::routes! {
fn pages(Router<()>);
const HOME: Route = "/" => page;
const USERS: Route = "/users" => page;
const USER: Route<i32> = "/users/{id}" => page;
}
let sidebar = NavList::<Admin>::new("Main", USER.url(7))
.item("Dashboard", HOME, ())
.item("Users", USERS, ())
.render();
let html = sidebar.render();
assert!(html.contains(r#"href="/users" aria-current="true""#));Implementations§
Sourcepub fn new(label: impl Into<String>, current: Url) -> Self
pub fn new(label: impl Into<String>, current: Url) -> Self
An empty list whose <nav> is named label, on the page at current.
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more