use bevy_color::Color;
use std::ops::Index;
mod button;
pub use self::button::{button, Button};
mod container;
pub use self::container::{container, Container};
mod radio;
pub use self::radio::{radio_button, RadioButton};
mod ui;
pub use self::ui::{material_ui, MaterialUi};
pub mod text;
#[derive(Clone, PartialEq)]
pub struct Colors {
pub background: Color,
pub primary: Color,
pub surface_container: Color,
pub text: Color,
}
#[derive(Clone, PartialEq)]
pub struct TypographyStyle {
pub font_size: f32,
pub font_weight: f32,
pub line_height: f32,
}
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum TypographyStyleKind {
Small,
Medium,
Large,
}
#[derive(Clone, PartialEq)]
pub struct TypographyToken {
pub small: TypographyStyle,
pub medium: TypographyStyle,
pub large: TypographyStyle,
}
impl Index<TypographyStyleKind> for TypographyToken {
type Output = TypographyStyle;
fn index(&self, index: TypographyStyleKind) -> &Self::Output {
match index {
TypographyStyleKind::Small => &self.small,
TypographyStyleKind::Medium => &self.medium,
TypographyStyleKind::Large => &self.large,
}
}
}
#[derive(Clone, Copy)]
pub enum TypographyKind {
Body,
Headline,
Label,
Title,
}
#[derive(Clone, PartialEq)]
pub struct Typography {
pub body: TypographyToken,
pub headline: TypographyToken,
pub label: TypographyToken,
pub title: TypographyToken,
}
impl Index<TypographyKind> for Typography {
type Output = TypographyToken;
fn index(&self, index: TypographyKind) -> &Self::Output {
match index {
TypographyKind::Body => &self.body,
TypographyKind::Headline => &self.headline,
TypographyKind::Label => &self.label,
TypographyKind::Title => &self.title,
}
}
}
#[derive(Clone, PartialEq)]
pub struct Theme {
pub colors: Colors,
pub typography: Typography,
}
impl Default for Theme {
fn default() -> Self {
Self {
colors: Colors {
background: Color::WHITE,
primary: Color::srgb_u8(103, 80, 164),
surface_container: Color::srgb_u8(230, 224, 233),
text: Color::BLACK,
},
typography: Typography {
body: TypographyToken {
small: TypographyStyle {
font_size: 12.,
font_weight: 400.,
line_height: 16.,
},
medium: TypographyStyle {
font_size: 14.,
font_weight: 400.,
line_height: 20.,
},
large: TypographyStyle {
font_size: 16.,
font_weight: 400.,
line_height: 24.,
},
},
headline: TypographyToken {
small: TypographyStyle {
font_size: 24.,
font_weight: 400.,
line_height: 32.,
},
medium: TypographyStyle {
font_size: 28.,
font_weight: 400.,
line_height: 36.,
},
large: TypographyStyle {
font_size: 32.,
font_weight: 400.,
line_height: 40.,
},
},
label: TypographyToken {
small: TypographyStyle {
font_size: 11.,
font_weight: 500.,
line_height: 16.,
},
medium: TypographyStyle {
font_size: 12.,
font_weight: 500.,
line_height: 16.,
},
large: TypographyStyle {
font_size: 14.,
font_weight: 500.,
line_height: 20.,
},
},
title: TypographyToken {
small: TypographyStyle {
font_size: 14.,
font_weight: 500.,
line_height: 20.,
},
medium: TypographyStyle {
font_size: 16.,
font_weight: 500.,
line_height: 24.,
},
large: TypographyStyle {
font_size: 22.,
font_weight: 400.,
line_height: 28.,
},
},
},
}
}
}