Skip to main content

teksilo_core/styles/
panel_style.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! Tier-3 style protocol for `Panel`. See `docs/styling-system.md`.
5
6use std::rc::Rc;
7
8use serde::{Deserialize, Serialize};
9
10use crate::build_context::BuildContext;
11use crate::color_prop::ColorProp;
12use crate::signal::Prop;
13use crate::widget_id::WidgetId;
14
15#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default, Serialize, Deserialize)]
16pub enum PanelVariant {
17    /// Bare surface, no border.
18    #[default]
19    Plain,
20    /// Sunken below the parent surface (form sections).
21    Sunken,
22    /// Raised with a subtle shadow.
23    Raised,
24    /// Highlighted accent surface (info banners, on-boarding).
25    Highlighted,
26}
27
28#[derive(Clone, Debug)]
29pub struct PanelStyleConfig {
30    /// Pre-built content subtree wrapped by the panel's chrome.
31    pub content: WidgetId,
32    pub variant: PanelVariant,
33    /// Caller overrides — when `Some`, the style should use these
34    /// values instead of the variant's defaults. Custom styles may
35    /// ignore them, in which case the override is silently dropped.
36    pub background_override: Option<ColorProp>,
37    pub border_color_override: Option<ColorProp>,
38    pub border_width_override: Option<Prop<f32>>,
39    pub corner_radius_override: Option<Prop<f32>>,
40    pub padding_override: Option<Prop<f32>>,
41}
42
43pub trait PanelStyle: 'static {
44    fn make_body(&self, cfg: &PanelStyleConfig, ctx: &mut BuildContext) -> WidgetId;
45}
46
47pub type SharedPanelStyle = Rc<dyn PanelStyle>;