pub struct Avatar<S> { /* private fields */ }Expand description
A round picture of the person name, or initials where there is none.
The avatar is a role="img" named name, so a screen reader reads the
name once and nothing inside it. Without Avatar::picture it shows
initials. With one, it shows the picture, and where the picture fails
to load, the ::after of the broken <img> draws initials over it.
Chrome draws that ::after. A browser that draws no ::after on a
broken image shows its own marker for one there instead.
use hypersig::{SafeUrl, Signals};
use hypersig_ui::Avatar;
use serde::{Deserialize, Serialize};
#[derive(Signals, Serialize, Deserialize)]
struct Team {}
const ADA: SafeUrl = SafeUrl::new("https://example.com/ada.png");
let ada = Avatar::<Team>::new("Ada Lovelace", "AL").picture(ADA);
let html = ada.render().render();
assert!(html.contains(r#"aria-label="Ada Lovelace""#));
assert!(html.contains(r#"alt="AL""#));Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for Avatar<S>
impl<S> RefUnwindSafe for Avatar<S>
impl<S> Send for Avatar<S>
impl<S> Sync for Avatar<S>
impl<S> Unpin for Avatar<S>
impl<S> UnsafeUnpin for Avatar<S>
impl<S> UnwindSafe for Avatar<S>
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