use super::*;
pub(crate) fn mount_lab_architecture_card(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
let nav_items: Vec<(String, String)> = vec![
(
LAB_NAV_ARCH_LABEL.to_string(),
LAB_NAV_ARCH_DESC.to_string(),
),
(LAB_NAV_3D_LABEL.to_string(), LAB_NAV_3D_DESC.to_string()),
(
LAB_NAV_MEDIA_LABEL.to_string(),
LAB_NAV_MEDIA_DESC.to_string(),
),
];
let chart_data: Vec<EuvChartPoint> = vec![
EuvChartPoint::new("Mon".to_string(), 60.0),
EuvChartPoint::new("Tue".to_string(), 88.0),
EuvChartPoint::new("Wed".to_string(), 118.0),
EuvChartPoint::new("Thu".to_string(), 104.0),
EuvChartPoint::new("Fri".to_string(), 120.0),
EuvChartPoint::new("Sat".to_string(), 116.0),
];
let trace_spans: Vec<EuvTraceSpan> = vec![
EuvTraceSpan::new(
LAB_TRACE_LAYOUT.to_string(),
0.14,
0.0,
0.12,
EuvTone::Primary,
),
EuvTraceSpan::new(
LAB_TRACE_BVH.to_string(),
0.88,
0.12,
0.60,
EuvTone::Success,
),
EuvTraceSpan::new(
LAB_TRACE_TONEMAP.to_string(),
0.24,
0.72,
0.16,
EuvTone::Warning,
),
EuvTraceSpan::new(
LAB_TRACE_BLIT.to_string(),
0.16,
0.88,
0.12,
EuvTone::Neutral,
),
];
view! {
EuvCard {
title: LAB_ARCH_TITLE.to_string()
tokens: tokens
subtitle: LAB_ARCH_SUB
row {
style: c_action_row()
EuvMarker {
code: "01".to_string()
label: LAB_MARKER_ZERO.to_string()
tone: EuvTone::Primary
tokens: tokens
}
EuvMarker {
code: "02".to_string()
label: LAB_MARKER_FPS.to_string()
tone: EuvTone::Success
tokens: tokens
}
EuvMarker {
code: "03".to_string()
label: LAB_MARKER_FREEZE.to_string()
tone: EuvTone::Warning
tokens: tokens
}
}
EuvNavigationMenu {
items: nav_items
active: state.get_lab_nav_menu_active()
tokens: tokens
}
EuvChart {
title: LAB_CHART_TITLE.to_string()
kind: EuvChartKind::Bar
data: chart_data
tokens: tokens
}
EuvTrace {
title: LAB_TRACE_TITLE.to_string()
spans: trace_spans
tokens: tokens
}
}
}
}
pub(crate) fn mount_lab_scroll_recipe_card(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
let palette: ThemePalette = tokens.get_palette();
let touches_sig: Signal<Vec<(u64, Point)>> = current_context().get_active_touches();
let block_scroll: Signal<bool> = state.get_lab_block_scroll_chain();
let stop_bubble: Signal<bool> = state.get_lab_stop_click_bubble();
let parent_clicks: Signal<u32> = state.get_lab_parent_clicks();
let child_clicks: Signal<u32> = state.get_lab_child_clicks();
let clicks_readout = move || -> String {
format!(
"Inner Clicks: {} | Outer Parent Clicks: {} | Active Touches: {}",
child_clicks.get(),
parent_clicks.get(),
touches_sig.get().len()
)
};
let build_nested_box = move || -> Vec<NodeId> {
let live_tok: ThemeTokens = live_tokens_untracked(tokens);
let live_p: ThemePalette = live_tok.get_palette();
let live_g: ThemeGeometry = live_tok.get_geometry();
let locked: bool = block_scroll.get();
let stop_clk: bool = stop_bubble.get();
let on_outer_click = move |_: &UiEvent| {
let _: bool = parent_clicks.set(parent_clicks.get_untracked() + 1);
};
let on_inner_click = move |_: &UiEvent| {
let _: bool = child_clicks.set(child_clicks.get_untracked() + 1);
};
let rows: Vec<NodeId> = (1..=8_usize)
.map(|row_i: usize| {
let row_txt: String = format!(
"Nested Scroll Row #{row_i} (scroll_lock={locked}, stop_bubble={stop_clk})"
);
let text_eighth_style: Style = style! {
Width(Length::Percent(100.0))
FontSize(12.0)
TextColor(live_p.get_foreground())
};
view! {
text {
style: text_eighth_style
{ row_txt }
}
}
})
.collect();
vec![{
let column_eighth_style: Style = style! {
Width(Length::Percent(100.0))
Padding(Edges::all(SPACE_MD))
Gap(SPACE_SM)
Background(live_p.get_muted())
Border::new(live_g.get_border_width(), live_p.get_border())
Radius(live_g.get_radius_md())
};
let scroll_style: Style = style! {
Width(Length::Percent(100.0))
Height(Length::Px(104.0))
Padding(Edges::all(SPACE_SM))
Gap(SPACE_XS)
Background(live_p.get_card())
Border::new(live_g.get_border_width(), live_p.get_border())
Radius(live_g.get_radius_sm())
StopScrollPropagation(locked)
StopEventPropagation(stop_clk)
};
view! {
column {
style: column_eighth_style
on_click: on_outer_click
scroll {
style: scroll_style
..rows
}
EuvActionRow {
EuvButton {
label: LAB_BTN_INNER_TARGET.to_string()
tokens: live_tok
outline()
small()
on_click: on_inner_click
}
}
}
}
}]
};
let column_sixth_style: Style = style! {
Width(Length::Percent(100.0))
Gap(SPACE_SM)
};
let text_seventh_style: Style = style! {
Width(Length::Percent(100.0))
FontSize(12.0)
TextColor(palette.get_muted_foreground())
};
let column_seventh_style: Style = style! {
Width(Length::Percent(100.0))
};
view! {
EuvCard {
title: LAB_SCROLL_TITLE.to_string()
tokens: tokens
subtitle: LAB_SCROLL_SUB
column {
style: column_sixth_style
EuvSwitch {
checked: block_scroll
label: LAB_SWITCH_SCROLL_LOCK.to_string()
tokens: tokens
}
EuvSwitch {
checked: stop_bubble
label: LAB_SWITCH_STOP_BUBBLE.to_string()
tokens: tokens
}
text {
style: text_seventh_style
{ clicks_readout }
}
column {
style: column_seventh_style
bind_children: build_nested_box
}
}
}
}
}
pub(crate) fn mount_lab_rtl_recipe_card(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
let palette: ThemePalette = tokens.get_palette();
let rtl_sig: Signal<bool> = state.get_lab_rtl_mode();
let preserve_cnt: Signal<u32> = state.get_lab_resize_preserve_count();
let on_increment = move |_: &UiEvent| {
let _: bool = preserve_cnt.set(preserve_cnt.get_untracked() + 1);
};
let counter_readout = move || -> String {
format!(
"Resize-Preserved Counter: {} | Direction: {}",
preserve_cnt.get(),
if rtl_sig.get() { "RTL" } else { "LTR" }
)
};
let build_dir_preview = move || -> Vec<NodeId> {
let live_tok: ThemeTokens = live_tokens_untracked(tokens);
let live_p: ThemePalette = live_tok.get_palette();
let dir: EuvTextDirection = if rtl_sig.get() {
EuvTextDirection::Rtl
} else {
EuvTextDirection::Ltr
};
let dir_label: String =
format!("Direction preview ({dir:?}): Unified layout alignment across LTR & RTL");
let text_sixth_style: Style = style! {
Width(Length::Percent(100.0))
FontSize(13.0)
TextColor(live_p.get_foreground())
};
let child_node: NodeId = view! {
text {
style: text_sixth_style
{ dir_label }
}
};
vec![view! {
EuvDirection {
direction: dir
child: child_node
tokens: live_tok
}
}]
};
let column_quaternary_style: Style = style! {
Width(Length::Percent(100.0))
Gap(SPACE_MD)
};
let column_fifth_style: Style = style! {
Width(Length::Percent(100.0))
};
let text_fifth_style: Style = style! {
Width(Length::Percent(100.0))
FontSize(12.0)
TextColor(palette.get_muted_foreground())
};
view! {
EuvCard {
title: LAB_RTL_TITLE.to_string()
tokens: tokens
subtitle: LAB_RTL_SUB
column {
style: column_quaternary_style
EuvSwitch {
checked: rtl_sig
label: LAB_SWITCH_RTL.to_string()
tokens: tokens
}
column {
style: column_fifth_style
bind_children: build_dir_preview
}
EuvActionRow {
EuvButton {
label: LAB_BTN_PRESERVE.to_string()
tokens: tokens
small()
on_click: on_increment
}
}
text {
style: text_fifth_style
{ counter_readout }
}
}
}
}
}
pub(crate) fn mount_lab_settings_recipe_card(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
let palette: ThemePalette = tokens.get_palette();
let autosave: Signal<bool> = Signal::new(true);
let record_traces: Signal<bool> = Signal::new(false);
let split_ratio: Signal<f32> = state.get_lab_split_ratio();
let settings_summary = move || -> String {
format!(
"Split: {:.0}% | Auto-save: {} | Traces: {}",
split_ratio.get() * 100.0,
autosave.get(),
record_traces.get()
)
};
let column_tertiary_style: Style = style! {
Width(Length::Percent(100.0))
Gap(SPACE_SM)
};
let text_quaternary_style: Style = style! {
Width(Length::Percent(100.0))
FontSize(13.0)
FontWeight::SemiBold
TextColor(palette.get_foreground())
};
let left_pane: NodeId = view! {
column {
style: column_tertiary_style
text {
style: text_quaternary_style
{ LAB_SPLIT_LEFT_HEAD }
}
EuvSwitch {
checked: autosave
label: LAB_SWITCH_AUTOSAVE.to_string()
tokens: tokens
}
EuvSwitch {
checked: record_traces
label: LAB_SWITCH_TELEMETRY.to_string()
tokens: tokens
}
}
};
let column_secondary_style: Style = style! {
Width(Length::Percent(100.0))
Gap(SPACE_SM)
};
let text_style: Style = style! {
Width(Length::Percent(100.0))
FontSize(13.0)
FontWeight::SemiBold
TextColor(palette.get_foreground())
};
let text_secondary_style: Style = style! {
Width(Length::Percent(100.0))
FontSize(12.5)
TextColor(palette.get_muted_foreground())
};
let text_tertiary_style: Style = style! {
Width(Length::Percent(100.0))
FontSize(12.0)
TextColor(palette.get_primary())
};
let right_pane: NodeId = view! {
column {
style: column_secondary_style
text {
style: text_style
{ LAB_SPLIT_RIGHT_HEAD }
}
text {
style: text_secondary_style
{ LAB_SPLIT_RIGHT_DESC }
}
text {
style: text_tertiary_style
{ settings_summary }
}
}
};
view! {
EuvCard {
title: LAB_SETTINGS_TITLE.to_string()
tokens: tokens
subtitle: LAB_SETTINGS_SUB
EuvResizable {
left: left_pane
right: right_pane
split_ratio: split_ratio
tokens: tokens
}
}
}
}
pub(crate) fn mount_lab_thread_recipe_card(tokens: ThemeTokens) -> NodeId {
let attach_vis: Signal<bool> = Signal::new(true);
let poll_sel: Signal<Option<usize>> = Signal::new(Some(0));
let poll_options: Vec<String> = vec![
LAB_POLL_OPT_1.to_string(),
LAB_POLL_OPT_2.to_string(),
LAB_POLL_OPT_3.to_string(),
];
let column_style: Style = style! {
Width(Length::Percent(100.0))
Gap(SPACE_MD)
};
view! {
EuvCard {
title: LAB_THREAD_TITLE.to_string()
tokens: tokens
subtitle: LAB_THREAD_SUB
column {
style: column_style
EuvBubble {
author: LAB_BUBBLE_BOT_AUTHOR.to_string()
content: LAB_BUBBLE_BOT_BODY.to_string()
tokens: tokens
timestamp: LAB_TIME_A
}
EuvBubble {
author: LAB_BUBBLE_DEV_AUTHOR.to_string()
content: LAB_BUBBLE_DEV_BODY.to_string()
tokens: tokens
timestamp: LAB_TIME_B
outgoing: true
}
EuvAttachment {
filename: LAB_ATTACH_FILE.to_string()
meta: LAB_ATTACH_META.to_string()
visible: attach_vis
tokens: tokens
}
EuvQuestionnaire {
prompt: LAB_POLL_PROMPT.to_string()
options: poll_options
selected: poll_sel
tokens: tokens
}
}
}
}
}
pub fn mount_lab_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
let arch_card: NodeId = mount_lab_architecture_card(state, tokens);
let recipe_cards: Vec<NodeId> = vec![
mount_lab_scroll_recipe_card(state, tokens),
mount_lab_rtl_recipe_card(state, tokens),
mount_lab_settings_recipe_card(state, tokens),
mount_lab_thread_recipe_card(tokens),
];
let recipes_grid: NodeId = mount_responsive_grid(recipe_cards, 2);
view! {
EuvPage {
title: LAB_TITLE.to_string()
subtitle: LAB_SUBTITLE.to_string()
tokens: tokens
{ arch_card }
{ recipes_grid }
}
}
}