Skip to main content

aethermap_gui/theme/
styles.rs

1use super::palette::*;
2use iced::widget::{button, container, rule, text_input};
3use iced::{border, Color, Theme};
4
5pub fn card(_theme: &Theme) -> container::Appearance {
6    container::Appearance {
7        text_color: Some(TEXT_PRIMARY),
8        background: Some(BG_SURFACE.into()),
9        border: border::Border {
10            color: Color::TRANSPARENT,
11            width: 0.0,
12            radius: RADIUS_CARD.into(),
13        },
14        ..Default::default()
15    }
16}
17
18pub fn sidebar_item(active: bool) -> impl Fn(&Theme) -> button::Appearance {
19    move |_theme: &Theme| button::Appearance {
20        background: if active {
21            Some(BG_ELEVATED.into())
22        } else {
23            Some(Color::TRANSPARENT.into())
24        },
25        text_color: if active { ACCENT } else { TEXT_SECONDARY },
26        border: border::Border {
27            color: if active { ACCENT } else { Color::TRANSPARENT },
28            width: if active { 2.0 } else { 0.0 },
29            radius: [0.0, RADIUS_INPUT, RADIUS_INPUT, 0.0].into(),
30        },
31        ..Default::default()
32    }
33}
34
35pub fn primary_button(_theme: &Theme) -> button::Appearance {
36    button::Appearance {
37        background: Some(ACCENT.into()),
38        text_color: Color::WHITE,
39        border: border::Border {
40            color: Color::TRANSPARENT,
41            width: 0.0,
42            radius: RADIUS_INPUT.into(),
43        },
44        ..Default::default()
45    }
46}
47
48pub fn secondary_button(_theme: &Theme) -> button::Appearance {
49    button::Appearance {
50        background: Some(BG_ELEVATED.into()),
51        text_color: TEXT_PRIMARY,
52        border: border::Border {
53            color: Color::TRANSPARENT,
54            width: 0.0,
55            radius: RADIUS_INPUT.into(),
56        },
57        ..Default::default()
58    }
59}
60
61pub fn danger_button(_theme: &Theme) -> button::Appearance {
62    button::Appearance {
63        background: Some(DANGER.into()),
64        text_color: Color::WHITE,
65        border: border::Border {
66            color: Color::TRANSPARENT,
67            width: 0.0,
68            radius: RADIUS_INPUT.into(),
69        },
70        ..Default::default()
71    }
72}
73
74pub fn input_style(_theme: &Theme) -> text_input::Appearance {
75    text_input::Appearance {
76        background: BG_ELEVATED.into(),
77        border: border::Border {
78            color: BORDER_SUBTLE,
79            width: 1.0,
80            radius: RADIUS_INPUT.into(),
81        },
82        icon_color: TEXT_MUTED,
83    }
84}
85
86pub fn header_bar(_theme: &Theme) -> container::Appearance {
87    container::Appearance {
88        background: Some(BG_SURFACE.into()),
89        border: border::Border {
90            color: BORDER_SUBTLE,
91            width: 0.0,
92            radius: 0.0.into(),
93        },
94        ..Default::default()
95    }
96}
97
98pub fn footer_bar(_theme: &Theme) -> container::Appearance {
99    container::Appearance {
100        background: Some(BG_SURFACE.into()),
101        border: border::Border {
102            color: BORDER_SUBTLE,
103            width: 0.0,
104            radius: 0.0.into(),
105        },
106        ..Default::default()
107    }
108}
109
110pub fn subtle_rule(_theme: &Theme) -> rule::Appearance {
111    rule::Appearance {
112        color: BORDER_SUBTLE,
113        width: 1,
114        radius: 0.0.into(),
115        fill_mode: rule::FillMode::Full,
116    }
117}