use super::Tint;
use crate::density;
use crate::theme::{self, surface, FontScale};
use iced::widget::{container, text, text::IntoFragment, Text};
use iced::{Background, Border, Element};
const CHIP_FILL_ALPHA: f32 = 0.10;
const CHIP_BORDER_ALPHA: f32 = 0.45;
pub fn chip<'a, Message: 'a>(
label: impl IntoFragment<'a>,
tint: Tint,
scale: FontScale,
) -> Element<'a, Message> {
let color = tint.iced();
container(
text(label)
.font(theme::mono_font())
.size(scale.apply(density::META_TEXT_BASE * 0.9))
.color(color)
.wrapping(iced::widget::text::Wrapping::None),
)
.padding([1.0, scale.apply(6.0)])
.style(move |_t: &iced::Theme| container::Style {
background: Some(Background::Color(iced::Color { a: CHIP_FILL_ALPHA, ..color })),
border: Border {
radius: density::nested_radius().into(),
width: 1.0,
color: iced::Color { a: CHIP_BORDER_ALPHA, ..color },
},
..container::Style::default()
})
.into()
}
pub fn keycap<'a, Message: 'a>(label: impl IntoFragment<'a>, scale: FontScale) -> Element<'a, Message> {
container(
text(label)
.font(iced::Font { weight: iced::font::Weight::Semibold, ..theme::mono_font() })
.size(scale.apply(density::META_TEXT_BASE * 0.85))
.color(theme::text()),
)
.padding([1.0, scale.apply(6.0)])
.style(|_t: &iced::Theme| container::Style {
background: Some(Background::Color(surface::sidebar())),
border: Border {
radius: density::nested_radius().into(),
width: 1.0,
color: surface::card_border(),
},
..container::Style::default()
})
.into()
}
pub fn config_line<'a>(content: impl IntoFragment<'a>, scale: FontScale) -> Text<'a> {
text(content)
.font(theme::mono_font())
.size(scale.apply(density::META_TEXT_BASE * 0.9))
.color(theme::text_dim())
}