update
This commit is contained in:
parent
8208fa8899
commit
ed739d792f
35 changed files with 1675 additions and 447 deletions
129
src/ui/color.rs
Normal file
129
src/ui/color.rs
Normal file
|
@ -0,0 +1,129 @@
|
|||
/// UI Color
|
||||
pub trait UIColor {
|
||||
fn color_class(&self) -> &str;
|
||||
}
|
||||
|
||||
pub trait ColorCircle {
|
||||
fn previous(&self) -> Self;
|
||||
fn next(&self) -> Self;
|
||||
}
|
||||
|
||||
macro_rules! color_map {
|
||||
($name:ident, $id:literal) => {
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum $name {
|
||||
_50,
|
||||
_100,
|
||||
_200,
|
||||
_300,
|
||||
_400,
|
||||
_500,
|
||||
_600,
|
||||
_700,
|
||||
_800,
|
||||
_900,
|
||||
_950,
|
||||
}
|
||||
|
||||
impl UIColor for $name {
|
||||
fn color_class(&self) -> &str {
|
||||
match self {
|
||||
$name::_50 => concat!($id, "-50"),
|
||||
$name::_100 => concat!($id, "-100"),
|
||||
$name::_200 => concat!($id, "-200"),
|
||||
$name::_300 => concat!($id, "-300"),
|
||||
$name::_400 => concat!($id, "-400"),
|
||||
$name::_500 => concat!($id, "-500"),
|
||||
$name::_600 => concat!($id, "-600"),
|
||||
$name::_700 => concat!($id, "-700"),
|
||||
$name::_800 => concat!($id, "-800"),
|
||||
$name::_900 => concat!($id, "-900"),
|
||||
$name::_950 => concat!($id, "-950"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ColorCircle for $name {
|
||||
fn next(&self) -> Self {
|
||||
match self {
|
||||
$name::_50 => $name::_100,
|
||||
$name::_100 => $name::_200,
|
||||
$name::_200 => $name::_300,
|
||||
$name::_300 => $name::_400,
|
||||
$name::_400 => $name::_500,
|
||||
$name::_500 => $name::_600,
|
||||
$name::_600 => $name::_700,
|
||||
$name::_700 => $name::_800,
|
||||
$name::_800 => $name::_900,
|
||||
$name::_900 => $name::_950,
|
||||
$name::_950 => $name::_50,
|
||||
}
|
||||
}
|
||||
|
||||
fn previous(&self) -> Self {
|
||||
match self {
|
||||
$name::_50 => $name::_950,
|
||||
$name::_100 => $name::_50,
|
||||
$name::_200 => $name::_100,
|
||||
$name::_300 => $name::_200,
|
||||
$name::_400 => $name::_300,
|
||||
$name::_500 => $name::_400,
|
||||
$name::_600 => $name::_500,
|
||||
$name::_700 => $name::_600,
|
||||
$name::_800 => $name::_700,
|
||||
$name::_900 => $name::_800,
|
||||
$name::_950 => $name::_900,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
color_map!(Slate, "slate");
|
||||
color_map!(Gray, "gray");
|
||||
color_map!(Zinc, "zinc");
|
||||
color_map!(Neutral, "neutral");
|
||||
color_map!(Stone, "stone");
|
||||
color_map!(Red, "red");
|
||||
color_map!(Orange, "orange");
|
||||
color_map!(Amber, "amber");
|
||||
color_map!(Yellow, "yellow");
|
||||
color_map!(Lime, "lime");
|
||||
color_map!(Green, "green");
|
||||
color_map!(Emerald, "emerald");
|
||||
color_map!(Teal, "teal");
|
||||
color_map!(Cyan, "cyan");
|
||||
color_map!(Sky, "sky");
|
||||
color_map!(Blue, "blue");
|
||||
color_map!(Indigo, "indigo");
|
||||
color_map!(Violet, "violet");
|
||||
color_map!(Purple, "purple");
|
||||
color_map!(Fuchsia, "fuchsia");
|
||||
color_map!(Pink, "pink");
|
||||
color_map!(Rose, "rose");
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Colors {
|
||||
/// Inherit a color
|
||||
Inherit,
|
||||
/// Use current color
|
||||
Current,
|
||||
/// Transparency
|
||||
Transparent,
|
||||
/// Black
|
||||
Black,
|
||||
/// White
|
||||
White,
|
||||
}
|
||||
|
||||
impl UIColor for Colors {
|
||||
fn color_class(&self) -> &str {
|
||||
match self {
|
||||
Colors::Inherit => "inherit",
|
||||
Colors::Current => "current",
|
||||
Colors::Transparent => "transparent",
|
||||
Colors::Black => "black",
|
||||
Colors::White => "white",
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue