use super::animated_icon_type::AnimatedIconType;
static HEART_CSS: &str = r#"[data-name="HeartAnimate"]:hover {
animation: HeartAnimation 1.2s ease-in-out;
}
@keyframes HeartAnimation {
0% { transform: scale(1); }
14% { transform: scale(1.15); }
28% { transform: scale(1); }
42% { transform: scale(1.08); }
56% { transform: scale(1); }
100% { transform: scale(1); }
}"#;
static PLUS_CSS: &str = r#"[data-name="PlusAnimate"] {
transition: transform 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
[data-name="PlusAnimate"]:hover {
transform: rotate(180deg);
}"#;
pub fn get_icon_css(icon_type: AnimatedIconType) -> Option<&'static str> {
match icon_type {
AnimatedIconType::Heart => Some(HEART_CSS),
AnimatedIconType::Plus => Some(PLUS_CSS),
}
}
pub fn has_animation_css(icon_type: AnimatedIconType) -> bool {
get_icon_css(icon_type).is_some()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_css_registry_returns_static_references() {
if let Some(css) = get_icon_css(AnimatedIconType::Heart) {
let ptr1 = css.as_ptr();
let css2 = get_icon_css(AnimatedIconType::Heart).unwrap();
let ptr2 = css2.as_ptr();
assert_eq!(ptr1, ptr2, "CSS should be static reference");
}
}
#[test]
fn test_has_animation_css_consistency() {
let icon = AnimatedIconType::Heart;
let has_css = has_animation_css(icon);
let css_option = get_icon_css(icon);
assert_eq!(has_css, css_option.is_some());
}
}