Skip to main content

material_ui_rs/design/style/
rule.rs

1use iced_widget::core::border::Radius;
2use iced_widget::rule::{Catalog, FillMode, Style, StyleFn};
3
4use crate::Theme;
5use crate::tokens;
6
7impl Catalog for Theme {
8    type Class<'a> = StyleFn<'a, Self>;
9
10    fn default<'a>() -> Self::Class<'a> {
11        Box::new(inset)
12    }
13
14    fn style(&self, class: &Self::Class<'_>) -> Style {
15        class(self)
16    }
17}
18
19pub fn inset(theme: &Theme) -> Style {
20    Style {
21        color: theme.colors().outline.variant,
22        fill_mode: FillMode::AsymmetricPadding(
23            tokens::component::divider::LIST_ITEM_LEADING_SPACE,
24            tokens::component::divider::LIST_ITEM_TRAILING_SPACE,
25        ),
26        radius: Radius::default(),
27        snap: cfg!(feature = "crisp"),
28    }
29}
30pub fn full_width(theme: &Theme) -> Style {
31    Style {
32        color: theme.colors().outline.variant,
33        fill_mode: FillMode::Full,
34        radius: Radius::default(),
35        snap: cfg!(feature = "crisp"),
36    }
37}
38
39#[cfg(test)]
40#[path = "../../../tests/design/style/rule.rs"]
41mod tests;