Skip to main content

Breadcrumb

Struct Breadcrumb 

Source
pub struct Breadcrumb<S> { /* private fields */ }
Expand description

A trail of links to the pages above the current one, ending at it.

It is a <nav> named by its label, holding an ordered list. The current page ends the trail as text with aria-current="page", and Breadcrumb::current is the only way to finish one, so a trail always names the page it is on and nothing follows it. The separators are hidden from assistive technology.

use hypersig::{Page, Route, Signals};
use hypersig_ui::Breadcrumb;
use serde::{Deserialize, Serialize};

#[derive(Signals, Serialize, Deserialize)]
struct Issue {}

hypersig::routes! {
    fn pages(Router<()>);
    const HOME: Route = "/" => page;
    const ISSUES: Route = "/issues" => page;
}

let trail = Breadcrumb::<Issue>::new("Breadcrumb")
    .link("Home", HOME.link())
    .link("Issues", ISSUES.link())
    .current("Login is slow");
let html = trail.render();
assert!(html.contains(r#"<nav aria-label="Breadcrumb""#));
assert!(html.contains(r#"aria-current="page""#));

Implementations§

Source§

impl<S> Breadcrumb<S>

Source

pub fn new(label: impl Into<String>) -> Self

An empty trail whose <nav> is named label, such as “Breadcrumb”.

Adds a link to a page above the current one, after the links before it.

Source

pub fn current(self, text: impl Into<String>) -> El<S>

The trail, ending at the current page text.

Trait Implementations§

Source§

impl<S: Debug> Debug for Breadcrumb<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Breadcrumb<S>

§

impl<S> RefUnwindSafe for Breadcrumb<S>

§

impl<S> Send for Breadcrumb<S>

§

impl<S> Sync for Breadcrumb<S>

§

impl<S> Unpin for Breadcrumb<S>

§

impl<S> UnsafeUnpin for Breadcrumb<S>

§

impl<S> UnwindSafe for Breadcrumb<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.