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 p: 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.update(|v: &mut u32| *v += 1);
};
let on_inner_click = move |_: &UiEvent| {
let _: bool = child_clicks.update(|v: &mut u32| *v += 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})"
);
view! {
text {
style: {
width: Length::Percent(100.0)
font_size: 12.0
color: live_p.get_foreground()
}
{ row_txt }
}
}
})
.collect();
vec![view! {
column {
style: {
width: Length::Percent(100.0)
padding: Edges::all(SPACE_MD)
gap: SPACE_SM
background: live_p.get_muted()
border: (live_g.get_border_width(), live_p.get_border())
radius: live_g.get_radius_md()
}
on_click: on_outer_click
scroll {
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: (live_g.get_border_width(), live_p.get_border())
radius: live_g.get_radius_sm()
stop_scroll_propagation: locked
stop_event_propagation: stop_clk
}
..rows
}
EuvActionRow {
EuvButton {
label: LAB_BTN_INNER_TARGET.to_string()
tokens: live_tok
outline()
sm()
on_click: on_inner_click
}
}
}
}]
};
view! {
EuvCard {
title: LAB_SCROLL_TITLE.to_string()
tokens: tokens
subtitle: LAB_SCROLL_SUB
column {
style: {
width: Length::Percent(100.0)
gap: SPACE_SM
}
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: {
width: Length::Percent(100.0)
font_size: 12.0
color: p.get_muted_foreground()
}
{ clicks_readout }
}
column {
style: {
width: Length::Percent(100.0)
}
bind_children: build_nested_box
}
}
}
}
}
pub(crate) fn mount_lab_rtl_recipe_card(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
let p: 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.update(|v: &mut u32| *v += 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 child_node: NodeId = view! {
text {
style: {
width: Length::Percent(100.0)
font_size: 13.0
color: live_p.get_foreground()
}
{ dir_label }
}
};
vec![view! {
EuvDirection {
direction: dir
child: child_node
tokens: live_tok
}
}]
};
view! {
EuvCard {
title: LAB_RTL_TITLE.to_string()
tokens: tokens
subtitle: LAB_RTL_SUB
column {
style: {
width: Length::Percent(100.0)
gap: SPACE_MD
}
EuvSwitch {
checked: rtl_sig
label: LAB_SWITCH_RTL.to_string()
tokens: tokens
}
column {
style: {
width: Length::Percent(100.0)
}
bind_children: build_dir_preview
}
EuvActionRow {
EuvButton {
label: LAB_BTN_PRESERVE.to_string()
tokens: tokens
sm()
on_click: on_increment
}
}
text {
style: {
width: Length::Percent(100.0)
font_size: 12.0
color: p.get_muted_foreground()
}
{ counter_readout }
}
}
}
}
}
pub(crate) fn mount_lab_settings_recipe_card(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
let p: 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 left_pane: NodeId = view! {
column {
style: {
width: Length::Percent(100.0)
gap: SPACE_SM
}
text {
style: {
width: Length::Percent(100.0)
font_size: 13.0
font_weight: FontWeight::SemiBold
color: p.get_foreground()
}
{ 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 right_pane: NodeId = view! {
column {
style: {
width: Length::Percent(100.0)
gap: SPACE_SM
}
text {
style: {
width: Length::Percent(100.0)
font_size: 13.0
font_weight: FontWeight::SemiBold
color: p.get_foreground()
}
{ LAB_SPLIT_RIGHT_HEAD }
}
text {
style: {
width: Length::Percent(100.0)
font_size: 12.5
color: p.get_muted_foreground()
}
{ LAB_SPLIT_RIGHT_DESC }
}
text {
style: {
width: Length::Percent(100.0)
font_size: 12.0
color: p.get_primary()
}
{ 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(),
];
view! {
EuvCard {
title: LAB_THREAD_TITLE.to_string()
tokens: tokens
subtitle: LAB_THREAD_SUB
column {
style: {
width: Length::Percent(100.0)
gap: SPACE_MD
}
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 }
}
}
}