bevy_ui_builders/label/
types.rs1use bevy::prelude::*;
4
5#[derive(Component, Debug)]
7pub struct Label {
8 pub style: LabelStyle,
9}
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
13pub enum LabelStyle {
14 Title, Heading, #[default]
17 Body, Caption, Muted, Error, Success, Warning, }
24
25impl LabelStyle {
26 pub fn font_size(&self) -> f32 {
27 match self {
28 LabelStyle::Title => crate::dimensions::FONT_SIZE_TITLE,
29 LabelStyle::Heading => crate::dimensions::FONT_SIZE_LARGE,
30 LabelStyle::Body => crate::dimensions::FONT_SIZE_NORMAL,
31 LabelStyle::Caption => crate::dimensions::FONT_SIZE_SMALL,
32 LabelStyle::Muted => crate::dimensions::FONT_SIZE_SMALL,
33 LabelStyle::Error => crate::dimensions::FONT_SIZE_NORMAL,
34 LabelStyle::Success => crate::dimensions::FONT_SIZE_NORMAL,
35 LabelStyle::Warning => crate::dimensions::FONT_SIZE_NORMAL,
36 }
37 }
38
39 pub fn text_color(&self) -> Color {
40 match self {
41 LabelStyle::Title => crate::colors::TEXT_TITLE,
42 LabelStyle::Heading => crate::colors::TEXT_PRIMARY,
43 LabelStyle::Body => crate::colors::TEXT_SECONDARY,
44 LabelStyle::Caption => crate::colors::TEXT_MUTED,
45 LabelStyle::Muted => crate::colors::TEXT_MUTED,
46 LabelStyle::Error => crate::colors::DANGER,
47 LabelStyle::Success => crate::colors::SUCCESS,
48 LabelStyle::Warning => crate::colors::WARNING,
49 }
50 }
51}