euv-ui 0.47.1

Cross-platform UI component library and 17-scheme design system for the euv framework with pixel-consistent rendering across Web, Android, iOS, iPadOS, macOS, Windows, and Linux.
Documentation
use super::*;

/// Adaptive cross-platform application shell (Desktop sidebar + top context bar, iPadOS rail, Mobile header + drawer).
#[derive(Clone, CustomDebug, Data, New, Props)]
pub struct EuvAppShell {
    /// Application brand title shown in sidebar or mobile top bar.
    pub(crate) brand: String,
    /// Mounted sidebar navigation content node.
    #[get(type(copy))]
    pub(crate) sidebar: NodeId,
    /// Mounted main page content node.
    #[get(type(copy))]
    pub(crate) main_content: NodeId,
    /// Active theme tokens.
    #[get(type(copy))]
    pub(crate) tokens: ThemeTokens,
    /// Optional active route signal used to auto-close the mobile drawer on navigation.
    #[new(skip)]
    #[get(skip)]
    pub(crate) route_signal: Option<Signal<String>>,
    /// Optional action controls rendered on the right side of the persistent top header bar.
    #[new(skip)]
    #[get(skip)]
    #[prop(custom)]
    pub(crate) top_bar_actions: Option<NodeId>,
    /// Optional compact inline actions rendered beside the mobile header Menu button.
    #[new(skip)]
    #[get(skip)]
    #[prop(custom)]
    pub(crate) mobile_header_actions: Option<NodeId>,
    /// Optional footer widget rendered at the bottom of the navigation sidebar / mobile drawer.
    #[new(skip)]
    #[get(skip)]
    #[prop(custom)]
    pub(crate) sidebar_footer: Option<NodeId>,
    /// Optional live breadcrumb / page context label rendered in the desktop top header bar.
    #[new(skip)]
    #[get(skip)]
    #[prop(custom)]
    pub(crate) breadcrumb: Option<Signal<String>>,
    /// Optional persistent bottom navigation bar activating Twitter/X-style bottom-tab shell layout.
    #[new(skip)]
    #[get(skip)]
    #[prop(custom)]
    pub(crate) bottom_nav: Option<NodeId>,
    /// Ordered route paths cycled directly by horizontal left/right swipes across the viewport.
    #[new(skip)]
    #[prop(custom)]
    pub(crate) swipe_routes: Vec<String>,
    /// Optional reactive toggle enabling or disabling horizontal swipe route navigation live.
    #[new(skip)]
    #[get(skip)]
    #[prop(custom)]
    pub(crate) swipe_routes_enabled: Option<Signal<bool>>,
    /// Whether the top navigation bar renders a live real-time FPS telemetry pill.
    #[new(skip)]
    #[get(type(copy))]
    #[prop(custom)]
    pub(crate) show_fps: bool,
    /// Optional reactive toggle controlling visibility of the live FPS telemetry pill.
    #[new(skip)]
    #[get(skip)]
    #[prop(custom)]
    pub(crate) show_fps_signal: Option<Signal<bool>>,
    /// Optional reactive theme controller enabling zero-teardown in-place shell restyling.
    #[new(skip)]
    #[get(skip)]
    #[prop(custom)]
    pub(crate) theme: Option<UiThemeState>,
    /// Optional reactive per-page padding signal synchronized with an embedded `EuvRouterOutlet`.
    #[new(skip)]
    #[get(skip)]
    #[prop(custom)]
    pub(crate) page_padding: Option<Signal<Edges>>,
    /// Whether vertical scrolling auto-hides the top bar and bottom navigation bar in Twitter/X style.
    #[new(skip)]
    #[get(type(copy))]
    #[prop(custom)]
    pub(crate) auto_hide_chrome_on_scroll: bool,
    /// Optional reactive toggle enabling or disabling scroll-driven chrome auto-hide live.
    #[new(skip)]
    #[get(skip)]
    #[prop(custom)]
    pub(crate) auto_hide_chrome_signal: Option<Signal<bool>>,
    /// Optional external URL dispatched via `open_url` when clicking the brand header (default opens the left sidebar drawer).
    #[new(skip)]
    #[get(skip)]
    #[prop(custom)]
    pub(crate) brand_url: Option<String>,
    /// Optional custom click handler overriding the top-left brand click action (default opens the left sidebar drawer).
    #[new(skip)]
    #[debug(skip)]
    #[get(skip)]
    #[prop(custom)]
    pub(crate) on_brand_click: Option<ShellBrandClickHandler>,
}

/// Hysteresis tracker driving Twitter/X-style top and bottom chrome auto-hide during vertical scrolling.
#[derive(Clone, Copy, Data, Debug, Default)]
pub(crate) struct ChromeScrollAutoHideState {
    /// Most recently observed active scroll container node handle.
    #[get(type(copy))]
    pub(crate) active_scroll_node: NodeId,
    /// Whether `last_scroll_y` has been seeded for `active_scroll_node`.
    #[get(type(copy))]
    pub(crate) has_sample: bool,
    /// Last observed vertical scroll offset in logical pixels.
    #[get(type(copy))]
    pub(crate) last_scroll_y: f32,
    /// Signed accumulated vertical scroll delta in the current uninterrupted direction.
    #[get(type(copy))]
    pub(crate) accum_delta_y: f32,
    /// Remaining downward scroll ticks suppressed after a viewport resize reveals chrome so leftover inertia does not immediately re-hide it.
    #[get(type(copy))]
    pub(crate) suppress_hide_ticks: u8,
}

/// Shared scroll observer state driving Twitter/X-style chrome auto-hide across direct and outlet scroll views.
#[derive(Clone, Getter, New)]
pub(crate) struct ChromeScrollObserver {
    /// Whether auto-hide is statically enabled for the owning shell.
    #[get(type(copy))]
    pub(crate) enabled: bool,
    /// Optional reactive auto-hide toggle overriding `enabled` live.
    #[get(type(copy))]
    pub(crate) auto_hide_signal: Option<Signal<bool>>,
    /// Shared scene handle for reading scroll offsets.
    pub(crate) scene: SceneHandle,
    /// Shared hysteresis tracker state.
    pub(crate) state: Rc<Cell<ChromeScrollAutoHideState>>,
    /// Context-level immersive fullscreen signal.
    #[get(type(copy))]
    pub(crate) ctx_fs: Signal<bool>,
    /// Compact drawer open state signal.
    #[get(type(copy))]
    pub(crate) menu_open: Signal<bool>,
    /// Chrome hidden state signal updated on threshold crossings.
    #[get(type(copy))]
    pub(crate) chrome_hidden: Signal<bool>,
}

/// Hairline horizontal or vertical structural divider.
#[derive(Clone, Copy, Data, Debug, New, Props)]
pub struct EuvDivider {
    /// True for vertical divider; false for horizontal.
    #[get(type(copy))]
    #[prop(custom)]
    pub(crate) vertical: bool,
    /// Active theme tokens.
    #[get(type(copy))]
    pub(crate) tokens: ThemeTokens,
}

/// Zero-boilerplate standardized page wrapper combining `EuvHeader` and uniform vertical section spacing.
#[derive(Clone, Data, Debug, New, Props)]
pub struct EuvPage {
    /// Page title text.
    pub(crate) title: String,
    /// Page subtitle description.
    pub(crate) subtitle: String,
    /// Active theme tokens.
    #[get(type(copy))]
    pub(crate) tokens: ThemeTokens,
    /// Optional maximum content width constraint (`None` renders full fluid width).
    #[new(skip)]
    #[get(type(copy))]
    #[prop(custom)]
    pub(crate) max_width: Option<Length>,
    /// Ordered section children rendered beneath the page header.
    #[new(skip)]
    pub(crate) sections: Vec<NodeId>,
}

/// Standardized wrapping horizontal action bar aligning buttons and controls on one center baseline.
#[derive(Clone, Data, Debug, Default, New, Props)]
pub struct EuvActionRow {
    /// Pre-mounted child controls inside the action row.
    #[new(skip)]
    pub(crate) children: Vec<NodeId>,
}

/// Responsive 1/2/3-column KPI stat grid synchronized with the active viewport breakpoint.
#[derive(Clone, Data, Debug, Default, New, Props)]
pub struct EuvStatGrid {
    /// Pre-mounted stat card children.
    #[new(skip)]
    pub(crate) cards: Vec<NodeId>,
}