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::{Theme, widget::button};
22
23/// A link button
24pub fn link_button(theme: &Theme, status: button::Status) -> button::Style {
25 let palette = theme.extended_palette();
26
27 let base = button::Style {
28 text_color: palette.danger.strong.color,
29 ..button::Style::default()
30 };
31
32 match status {
33 button::Status::Active | button::Status::Pressed => base,
34 button::Status::Hovered => button::Style {
35 text_color: palette.danger.base.color.scale_alpha(0.8),
36 ..base
37 },
38 button::Status::Disabled => button_disabled(base),
39 }
40}
41
42pub fn button_disabled(style: button::Style) -> button::Style {
43 button::Style {
44 background: style.background.map(|b| b.scale_alpha(0.5)),
45 text_color: style.text_color.scale_alpha(0.5),
46 ..style
47 }
48}