Skip to main content

teksilo_core/styles/
badge_style.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! Tier-3 style protocol for `Badge`. See `docs/styling-system.md`.
5//!
6//! Themes the pill-shaped label chrome — the rounded background fill
7//! and the content padding inset. `Badge` builds the label
8//! `TextWidget` (with the resolved text color) itself; `BadgeStyle`
9//! only owns the surrounding pill.
10
11use std::rc::Rc;
12
13use crate::build_context::BuildContext;
14use crate::color_prop::ColorProp;
15use crate::widget_id::WidgetId;
16
17#[derive(Clone, Debug)]
18pub struct BadgeStyleConfig {
19    /// Pre-built label subtree the pill wraps.
20    pub content: WidgetId,
21    /// Caller override for the pill background — `None` means "use the
22    /// recipe default" (`SurfaceRole::AccentSubtle`). Custom styles may
23    /// ignore it.
24    pub background_override: Option<ColorProp>,
25}
26
27pub trait BadgeStyle: 'static {
28    fn make_body(&self, cfg: &BadgeStyleConfig, ctx: &mut BuildContext) -> WidgetId;
29}
30
31pub type SharedBadgeStyle = Rc<dyn BadgeStyle>;