use super::*;
pub(crate) fn mount_display_identity_card(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
let avatar_specs: [(&str, f32); 3] = [("EU", 28.0), ("RS", 36.0), ("UI", 44.0)];
let avatars: Vec<NodeId> = avatar_specs
.iter()
.map(|(init, sz): &(&str, f32)| {
let size_px: f32 = *sz;
view! {
EuvAvatar {
initials: (*init).to_string()
size: size_px
tokens: tokens
}
}
})
.collect();
let badge_specs: [(&str, EuvTone); 5] = [
(DISPLAY_BADGE_PRIMARY, EuvTone::Primary),
(DISPLAY_BADGE_SUCCESS, EuvTone::Success),
(DISPLAY_BADGE_WARNING, EuvTone::Warning),
(DISPLAY_BADGE_DESTRUCTIVE, EuvTone::Destructive),
(DISPLAY_BADGE_NEUTRAL, EuvTone::Neutral),
];
let badges: Vec<NodeId> = badge_specs
.iter()
.map(|(lbl, tone): &(&str, EuvTone)| {
let tone_val: EuvTone = *tone;
view! {
EuvBadge {
label: (*lbl).to_string()
tone: tone_val
tokens: tokens
}
}
})
.collect();
let tag_specs: [(&str, EuvTone); 3] = [
(DISPLAY_TAG_RUST, EuvTone::Primary),
(DISPLAY_TAG_GPU, EuvTone::Success),
(DISPLAY_TAG_WASM, EuvTone::Neutral),
];
let tags: Vec<NodeId> = tag_specs
.iter()
.map(|(lbl, tone): &(&str, EuvTone)| {
let tone_val: EuvTone = *tone;
view! {
EuvTag {
label: (*lbl).to_string()
tone: tone_val
tokens: tokens
}
}
})
.collect();
view! {
EuvCard {
title: DISPLAY_IDENTITY_TITLE.to_string()
tokens: tokens
subtitle: DISPLAY_IDENTITY_SUB
column {
style: {
width: Length::Percent(100.0)
gap: SPACE_MD
}
row {
style: c_action_row()
..avatars
}
EuvHoverCard {
trigger_label: DISPLAY_HOVER_TRIGGER.to_string()
title: DISPLAY_HOVER_TITLE.to_string()
tokens: tokens
open: state.get_hover_card_open()
description: DISPLAY_HOVER_DESC
}
EuvSeparator {
label: DISPLAY_SEP_BADGES.to_string()
tokens: tokens
}
row {
style: c_action_row()
..badges
}
row {
style: c_action_row()
..tags
}
}
}
}
}
pub(crate) fn mount_display_alerts_card(tokens: ThemeTokens) -> NodeId {
view! {
EuvCard {
title: DISPLAY_ALERTS_TITLE.to_string()
tokens: tokens
subtitle: DISPLAY_ALERTS_SUB
column {
style: {
width: Length::Percent(100.0)
gap: SPACE_MD
}
EuvAlert {
title: DISPLAY_ALERT_INFO_TITLE.to_string()
description: DISPLAY_ALERT_INFO_DESC.to_string()
tone: EuvTone::Primary
tokens: tokens
}
EuvSeparator {
label: DISPLAY_SEP_DIVIDER.to_string()
tokens: tokens
}
EuvAlert {
title: DISPLAY_ALERT_OK_TITLE.to_string()
description: DISPLAY_ALERT_OK_DESC.to_string()
tone: EuvTone::Success
tokens: tokens
}
EuvAlert {
title: DISPLAY_ALERT_WARN_TITLE.to_string()
description: DISPLAY_ALERT_WARN_DESC.to_string()
tone: EuvTone::Warning
tokens: tokens
}
}
}
}
}
pub(crate) fn mount_display_disclosure_card(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
let p: ThemePalette = tokens.get_palette();
let acc_items: Vec<EuvAccordionItem> = vec![
EuvAccordionItem::new(
DISPLAY_ACC_1_TITLE.to_string(),
DISPLAY_ACC_1_BODY.to_string(),
),
EuvAccordionItem::new(
DISPLAY_ACC_2_TITLE.to_string(),
DISPLAY_ACC_2_BODY.to_string(),
),
EuvAccordionItem::new(
DISPLAY_ACC_3_TITLE.to_string(),
DISPLAY_ACC_3_BODY.to_string(),
),
];
let collapsible_body: NodeId = view! {
text {
style: {
width: Length::Percent(100.0)
font_size: 13.0
color: p.get_muted_foreground()
}
{ DISPLAY_COLLAPSE_BODY }
}
};
view! {
EuvCard {
title: DISPLAY_DISCLOSURE_TITLE.to_string()
tokens: tokens
subtitle: DISPLAY_DISCLOSURE_SUB
column {
style: {
width: Length::Percent(100.0)
gap: SPACE_MD
}
EuvAccordion {
items: acc_items
open_index: state.get_accordion_open()
tokens: tokens
}
EuvCollapsible {
open: state.get_collapsible_open()
title: DISPLAY_COLLAPSE_TITLE.to_string()
content: collapsible_body
tokens: tokens
}
}
}
}
}
pub(crate) fn mount_display_timeline_card(tokens: ThemeTokens) -> NodeId {
let items: Vec<EuvTimelineItem> = vec![
EuvTimelineItem::new(
DISPLAY_TL_1_TITLE.to_string(),
DISPLAY_TL_1_TIME.to_string(),
DISPLAY_TL_1_DESC.to_string(),
),
EuvTimelineItem::new(
DISPLAY_TL_2_TITLE.to_string(),
DISPLAY_TL_2_TIME.to_string(),
DISPLAY_TL_2_DESC.to_string(),
),
EuvTimelineItem::new(
DISPLAY_TL_3_TITLE.to_string(),
DISPLAY_TL_3_TIME.to_string(),
DISPLAY_TL_3_DESC.to_string(),
),
];
view! {
EuvCard {
title: DISPLAY_TIMELINE_TITLE.to_string()
tokens: tokens
subtitle: DISPLAY_TIMELINE_SUB
EuvTimeline {
items: items
tokens: tokens
}
}
}
}
pub(crate) fn mount_display_carousel_card(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
let p: ThemePalette = tokens.get_palette();
let slide_sig: Signal<usize> = state.get_carousel_index();
let slides: Vec<String> = vec![
DISPLAY_SLIDE_1.to_string(),
DISPLAY_SLIDE_2.to_string(),
DISPLAY_SLIDE_3.to_string(),
];
let slide_readout = move || -> String { format!("Active Slide: {} / 3", slide_sig.get() + 1) };
view! {
EuvCard {
title: DISPLAY_CAROUSEL_TITLE.to_string()
tokens: tokens
subtitle: DISPLAY_CAROUSEL_SUB
column {
style: {
width: Length::Percent(100.0)
gap: SPACE_MD
}
EuvCarousel {
slides: slides
active_slide: slide_sig
tokens: tokens
}
text {
style: {
width: Length::Percent(100.0)
font_size: 12.0
color: p.get_muted_foreground()
}
{ slide_readout }
}
EuvItem {
title: DISPLAY_ITEM_TITLE.to_string()
tokens: tokens
leading: "EU"
description: DISPLAY_ITEM_DESC
trailing: DISPLAY_ITEM_VER
}
}
}
}
}
pub(crate) fn mount_display_calendar_card(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
let p: ThemePalette = tokens.get_palette();
let day_sig: Signal<u32> = state.get_calendar_day();
let day_readout = move || -> String {
let day: u32 = day_sig.get();
format!("Selected Date: {LABEL_CALENDAR_MONTH} {day}")
};
view! {
EuvCard {
title: DISPLAY_CALENDAR_TITLE.to_string()
tokens: tokens
subtitle: DISPLAY_CALENDAR_SUB
column {
style: {
width: Length::Percent(100.0)
gap: SPACE_MD
}
EuvCalendar {
month_label: LABEL_CALENDAR_MONTH.to_string()
days_in_month: 30
selected_day: day_sig
tokens: tokens
}
text {
style: {
width: Length::Percent(100.0)
font_size: 12.0
color: p.get_muted_foreground()
}
{ day_readout }
}
}
}
}
}
pub(crate) fn mount_display_placeholder_card(tokens: ThemeTokens) -> NodeId {
view! {
EuvCard {
title: DISPLAY_PLACEHOLDER_TITLE.to_string()
tokens: tokens
subtitle: DISPLAY_PLACEHOLDER_SUB
column {
style: {
width: Length::Percent(100.0)
gap: SPACE_MD
}
column {
style: {
width: Length::Percent(100.0)
gap: SPACE_SM
}
EuvSkeleton {
width: 200.0
height: 18.0
tokens: tokens
}
EuvSkeleton {
width: 150.0
height: 14.0
tokens: tokens
}
}
EuvSeparator {
label: String::new()
tokens: tokens
}
EuvEmpty {
title: DISPLAY_EMPTY_TITLE.to_string()
description: DISPLAY_EMPTY_DESC.to_string()
tokens: tokens
}
}
}
}
}
pub fn mount_display_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
let cards: Vec<NodeId> = vec![
mount_display_identity_card(state, tokens),
mount_display_alerts_card(tokens),
mount_display_disclosure_card(state, tokens),
mount_display_timeline_card(tokens),
mount_display_carousel_card(state, tokens),
mount_display_calendar_card(state, tokens),
mount_display_placeholder_card(tokens),
];
let grid: NodeId = mount_responsive_grid(cards, 2);
view! {
EuvPage {
title: DISPLAY_TITLE.to_string()
subtitle: DISPLAY_SUBTITLE.to_string()
tokens: tokens
{ grid }
}
}
}