euv_ui/component/avatar/view/struct.rs
1use super::*;
2
3/// The square edge length of the `euv_avatar` component.
4///
5/// The sizes mirror the `c_euv_logo_nav` (32px) square convention used by the
6/// brand logo: `Small` for dense list rows, `Medium` as the default inline
7/// size, and `Large` for profile headers.
8#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
9pub enum EuvAvatarSize {
10 /// A 24×24 avatar for dense rows such as comment lists.
11 Small,
12 /// A 32×32 avatar, the default size matching the navigation logo square.
13 #[default]
14 Medium,
15 /// A 40×40 avatar for profile headers and user cards.
16 Large,
17}
18
19impl EuvAvatarSize {
20 /// Returns the square edge length in pixels for this size.
21 ///
22 /// # Returns
23 ///
24 /// - `i32` - The edge length in pixels: 24 for `Small`, 32 for `Medium`,
25 /// 40 for `Large`.
26 pub fn px(&self) -> i32 {
27 match self {
28 EuvAvatarSize::Small => 24,
29 EuvAvatarSize::Medium => 32,
30 EuvAvatarSize::Large => 40,
31 }
32 }
33}
34
35/// Props for the `euv_avatar` component.
36///
37/// Defines the strongly-typed interface for a user or entity avatar that
38/// renders either an image or a text fallback.
39#[derive(Clone, CustomDebug, Default)]
40pub struct EuvAvatarProps {
41 /// The image source URL. When empty the `initials` text is rendered instead.
42 pub src: &'static str,
43 /// The alternative text describing the avatar image.
44 pub alt: &'static str,
45 /// The initials rendered as the text fallback when `src` is empty.
46 pub initials: &'static str,
47 /// The square size of the avatar.
48 pub size: EuvAvatarSize,
49 /// Whether to render the avatar as a sharp square instead of a circle.
50 pub square: Signal<bool>,
51}