bevy_ui_builders/label/
types.rs

1//! Label component types and markers
2
3use bevy::prelude::*;
4
5/// Component for text labels
6#[derive(Component, Debug)]
7pub struct Label {
8    pub style: LabelStyle,
9}
10
11/// Label style variants
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
13pub enum LabelStyle {
14    Title,   // Large title text
15    Heading, // Section heading
16    #[default]
17    Body, // Normal body text
18    Caption, // Small caption text
19    Muted,   // De-emphasized text
20    Error,   // Error message text
21    Success, // Success message text
22    Warning, // Warning message text
23}
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}