Skip to main content

Avatar

Struct Avatar 

Source
pub struct Avatar { /* private fields */ }
Expand description

A round picture of a person or a team, or their initials when there is no picture. The name is required: it is the image’s alternative text and the source of the initials. When the name is written right next to the avatar, call .decorative() so screen readers do not hear it twice.

The picture follows the super::Image rules: a path of the app or an https address on a host of the app’s img-src; any other picture is left out and the initials are shown.

use zeyn::ui::{Avatar, AvatarSize};
let ada = Avatar::new("Ada Lovelace").image("/img/people/ada.jpg").size(AvatarSize::Large);
let team = Avatar::new("Support team");
let beside_name = Avatar::new("Alan Turing").size(AvatarSize::Small).decorative();

Implementations§

Source§

impl Avatar

Source

pub fn new(name: impl Into<Text>) -> Self

Source

pub fn image(self, src: impl Into<String>) -> Self

The picture. Without one, or when it is not allowed, the initials are shown.

Source

pub fn size(self, size: AvatarSize) -> Self

Source

pub fn decorative(self) -> Self

Hides the avatar from screen readers, for when the name is written next to it.

Trait Implementations§

Source§

impl Component for Avatar

Source§

fn render(&self, out: &mut String, r: &Render<'_>)

Source§

fn schema(&self) -> Json

Schema used by MCP tools and test generation. Include a "type" key.
Source§

fn grid(&self) -> Option<&dyn GridSource>

Source§

fn form(&self) -> Option<&dyn FormSource>

Source§

fn reveal(&self, _field: &str) -> Option<Revealed>

The raw value of a masked field this component shows, for an audited reveal. The server checks the unmask permission before sending it.
Source§

fn import(&self) -> Option<&dyn ImportSource>

CSV import, for components that import rows (see crate::Import).
Source§

fn children(&self) -> &[Node]

Nodes held by a container. Child i of the node at path p has the path p.i.
Source§

fn eager_children(&self) -> &[Node]

Children rendered with the page. Others, such as closed lazy tabs, load when first shown.
Source§

fn source(&self, _key: &str) -> Option<&dyn DataSource>

Data the component fetches through an action, by key (a field name for lookups).
Source§

fn shortcuts(&self) -> Vec<&str>

Keyboard shortcuts of the component’s own links, as declared, for the clash checks of App::check and App::check_page.
Source§

impl From<Avatar> for Node

Source§

fn from(c: Avatar) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more