Skip to main content

ferrix_app/
styles.rs

1/* styles.rs
2 *
3 * Copyright 2025 Michail Krasnov <mskrasnov07@ya.ru>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 *
18 * SPDX-License-Identifier: GPL-3.0-or-later
19 */
20
21use iced::{Color, Theme, color, widget::button};
22
23pub const CPU_CHARTS_COLORS: &'static [Color] = &[
24    color!(0xe6194b),
25    color!(0xF58231),
26    color!(0xFFE119),
27    color!(0xBFEF45),
28    color!(0x3CB44B),
29    color!(0x42D4F4),
30    color!(0x4363D8),
31    color!(0x911EB4),
32    color!(0xff00e3),
33    color!(0xffb5ba),
34    color!(0x00a800),
35    color!(0xfdffc5),
36];
37
38/// A link button
39pub fn link_button(theme: &Theme, status: button::Status) -> button::Style {
40    let palette = theme.extended_palette();
41
42    let base = button::Style {
43        text_color: palette.danger.strong.color,
44        ..button::Style::default()
45    };
46
47    match status {
48        button::Status::Active | button::Status::Pressed => base,
49        button::Status::Hovered => button::Style {
50            text_color: palette.danger.base.color.scale_alpha(0.8),
51            ..base
52        },
53        button::Status::Disabled => button_disabled(base),
54    }
55}
56
57pub fn button_disabled(style: button::Style) -> button::Style {
58    button::Style {
59        background: style.background.map(|b| b.scale_alpha(0.5)),
60        text_color: style.text_color.scale_alpha(0.5),
61        ..style
62    }
63}