Skip to main content

teksilo_core/styles/
search_field_style.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! Tier-3 style protocol for `SearchField`. See `docs/styling-system.md`.
5//!
6//! `SearchField` composes a themed `TextInput` (which already owns its
7//! bordered surface chrome via `TextInputStyle`) with a leading
8//! magnifier glyph dropped into the field's leading slot and a
9//! trailing clear-button toggled by `show_clear_button(true)`. The
10//! suggestions popup surface is routed through `PopoverStyle::Menu`.
11//!
12//! What remains is a thin chrome hook for apps that want to wrap or
13//! replace the field — same pattern as `DateEditStyle`. Default is a
14//! passthrough. Dim constants (glyph size, row metrics, panel padding,
15//! input/panel gap) live as `pub const`s on
16//! `teksilo_widgets::styles::recipe_search_field_style`.
17
18use std::rc::Rc;
19
20use crate::build_context::BuildContext;
21use crate::widget_id::WidgetId;
22
23pub struct SearchFieldStyleConfig {
24    /// Pre-assembled body — the `TextInput` already carrying the
25    /// magnifier glyph in its leading slot and the clear button
26    /// enabled via `show_clear_button(true)`.
27    pub body: WidgetId,
28}
29
30pub trait SearchFieldStyle: 'static {
31    fn make_body(&self, cfg: &SearchFieldStyleConfig, ctx: &mut BuildContext) -> WidgetId;
32}
33
34pub type SharedSearchFieldStyle = Rc<dyn SearchFieldStyle>;