use crate::traits::ToCss;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum Shadow {
Xs2,
Xs,
Sm,
Md,
Lg,
Xl,
S2xl,
#[default]
None,
}
impl ToCss for Shadow {
fn to_css(&self) -> String {
match self {
Shadow::Xs2 => "0 1px rgb(0 0 0 / 0.05)".to_string(),
Shadow::Xs => "0 1px 2px 0 rgb(0 0 0 / 0.05)".to_string(),
Shadow::Sm => {
"0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)".to_string()
}
Shadow::Md => {
"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)".to_string()
}
Shadow::Lg => {
"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)".to_string()
}
Shadow::Xl => {
"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)".to_string()
}
Shadow::S2xl => "0 25px 50px -12px rgb(0 0 0 / 0.25)".to_string(),
Shadow::None => "none".to_string(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum InsetShadow {
Xs2,
Xs,
Sm,
None,
}
impl ToCss for InsetShadow {
fn to_css(&self) -> String {
match self {
InsetShadow::Xs2 => "inset 0 1px rgb(0 0 0 / 0.05)".to_string(),
InsetShadow::Xs => "inset 0 1px 1px rgb(0 0 0 / 0.05)".to_string(),
InsetShadow::Sm => "inset 0 2px 4px rgb(0 0 0 / 0.05)".to_string(),
InsetShadow::None => "none".to_string(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum DropShadow {
Xs,
Sm,
Md,
Lg,
Xl,
S2xl,
None,
}
impl ToCss for DropShadow {
fn to_css(&self) -> String {
match self {
DropShadow::Xs => "drop-shadow(0 1px 1px rgb(0 0 0 / 0.05))".to_string(),
DropShadow::Sm => "drop-shadow(0 1px 2px rgb(0 0 0 / 0.15))".to_string(),
DropShadow::Md => "drop-shadow(0 3px 3px rgb(0 0 0 / 0.12))".to_string(),
DropShadow::Lg => "drop-shadow(0 4px 4px rgb(0 0 0 / 0.15))".to_string(),
DropShadow::Xl => "drop-shadow(0 9px 7px rgb(0 0 0 / 0.1))".to_string(),
DropShadow::S2xl => "drop-shadow(0 25px 25px rgb(0 0 0 / 0.15))".to_string(),
DropShadow::None => "none".to_string(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum TextShadow {
Xs2,
Xs,
Sm,
Md,
Lg,
None,
}
impl ToCss for TextShadow {
fn to_css(&self) -> String {
match self {
TextShadow::Xs2 => "0px 1px 0px rgb(0 0 0 / 0.15)".to_string(),
TextShadow::Xs => "0px 1px 1px rgb(0 0 0 / 0.2)".to_string(),
TextShadow::Sm => "0px 1px 0px rgb(0 0 0 / 0.075), 0px 1px 1px rgb(0 0 0 / 0.075), 0px 2px 2px rgb(0 0 0 / 0.075)".to_string(),
TextShadow::Md => "0px 1px 1px rgb(0 0 0 / 0.1), 0px 1px 2px rgb(0 0 0 / 0.1), 0px 2px 4px rgb(0 0 0 / 0.1)".to_string(),
TextShadow::Lg => "0px 1px 2px rgb(0 0 0 / 0.1), 0px 3px 2px rgb(0 0 0 / 0.1), 0px 4px 8px rgb(0 0 0 / 0.1)".to_string(),
TextShadow::None => "none".to_string(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_shadow_css() {
assert!(Shadow::Sm.to_css().contains("0 1px 3px"));
assert_eq!(Shadow::None.to_css(), "none");
}
}