Skip to main content

euv_ui/component/dropdown/view/
struct.rs

1use super::*;
2
3/// One entry of the [`euv_dropdown`] menu.
4///
5/// Carries the display label and the opaque value handed to `on_select`.
6#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
7pub struct EuvDropdownItem {
8    /// The display label.
9    #[get(type(copy))]
10    pub label: &'static str,
11    /// The opaque value passed to the select callback.
12    #[get(type(copy))]
13    pub value: &'static str,
14    /// Whether this item is the currently selected value.
15    ///
16    /// Drives the `_active` class: the accent fill and the `text-on-accent`
17    /// label colour, matching how `euv_sidebar` marks the current page.
18    /// Defaults to `false`, so existing call sites keep the neutral look.
19    #[get(type(copy))]
20    pub active: bool,
21}
22
23/// Props for the [`euv_dropdown`] component.
24///
25/// The open state is owned by the caller so the trigger (passed as children)
26/// can toggle it; selecting an item closes the menu.
27#[derive(Clone, CustomDebug, Default)]
28pub struct EuvDropdownProps {
29    /// The open state signal toggled by the trigger children.
30    pub open: Signal<bool>,
31    /// The menu items.
32    pub items: Vec<EuvDropdownItem>,
33    /// Optional select callback receiving the chosen item value.
34    #[debug(skip)]
35    pub on_select: Option<Rc<dyn Fn(&'static str)>>,
36}