hyprforge_ui/widgets/
badges.rs1use super::Tint;
4use crate::density;
5use crate::theme::{self, surface, FontScale};
6use iced::widget::{container, text, text::IntoFragment, Text};
7use iced::{Background, Border, Element};
8
9const CHIP_FILL_ALPHA: f32 = 0.10;
15const CHIP_BORDER_ALPHA: f32 = 0.45;
16
17pub fn chip<'a, Message: 'a>(
24 label: impl IntoFragment<'a>,
25 tint: Tint,
26 scale: FontScale,
27) -> Element<'a, Message> {
28 let color = tint.iced();
29 container(
30 text(label)
31 .font(theme::mono_font())
32 .size(scale.apply(density::META_TEXT_BASE * 0.9))
33 .color(color)
34 .wrapping(iced::widget::text::Wrapping::None),
37 )
38 .padding([1.0, scale.apply(6.0)])
39 .style(move |_t: &iced::Theme| container::Style {
40 background: Some(Background::Color(iced::Color { a: CHIP_FILL_ALPHA, ..color })),
41 border: Border {
42 radius: density::nested_radius().into(),
43 width: 1.0,
44 color: iced::Color { a: CHIP_BORDER_ALPHA, ..color },
45 },
46 ..container::Style::default()
47 })
48 .into()
49}
50
51pub fn keycap<'a, Message: 'a>(label: impl IntoFragment<'a>, scale: FontScale) -> Element<'a, Message> {
58 container(
59 text(label)
60 .font(iced::Font { weight: iced::font::Weight::Semibold, ..theme::mono_font() })
61 .size(scale.apply(density::META_TEXT_BASE * 0.85))
62 .color(theme::text()),
63 )
64 .padding([1.0, scale.apply(6.0)])
65 .style(|_t: &iced::Theme| container::Style {
66 background: Some(Background::Color(surface::sidebar())),
67 border: Border {
68 radius: density::nested_radius().into(),
69 width: 1.0,
70 color: surface::card_border(),
71 },
72 ..container::Style::default()
73 })
74 .into()
75}
76
77pub fn config_line<'a>(content: impl IntoFragment<'a>, scale: FontScale) -> Text<'a> {
83 text(content)
84 .font(theme::mono_font())
85 .size(scale.apply(density::META_TEXT_BASE * 0.9))
86 .color(theme::text_dim())
87}