use parley::FontWeight;
use smudge_core::reactive::{provide_context, use_context};
use smudge_core::theme::{ColorToken, ColorValue};
#[derive(Clone, Debug, PartialEq)]
pub struct TextStyle {
pub family: parley::FontFamily<'static>,
pub size: f32,
pub weight: FontWeight,
pub line_height: f32,
pub color: ColorValue,
}
impl Default for TextStyle {
fn default() -> Self {
TextStyle {
family: parley::FontFamily::named(crate::fonts::SANS_FAMILY),
size: 14.0,
weight: FontWeight::NORMAL,
line_height: 1.3,
color: ColorValue::Token(ColorToken::TEXT),
}
}
}
pub fn provide_text_style(style: TextStyle) {
provide_context(style);
}
pub fn current_text_style() -> TextStyle {
use_context::<TextStyle>().unwrap_or_default()
}