use crate::types::Validation;
use leptos::prelude::*;
use std::process;
#[component]
pub fn Circle(color: &'static str, size: u32) -> impl IntoView {
let Ok(_) = color.validate_color_code() else {
eprintln!("Spux Error - Color should be in the #hex format (e.g #000000) for black");
process::exit(1);
};
let half_size = size / 2;
let quarter_size = size / 4;
let style = format!(
"
.spux-circle {{
background: transparent;
display:flex;
width: {size}px;
height: {size}px;
border-radius: 100%;
margin-top:0px;
margin-left:0px;
animation: spux-circle 1400ms ease-in-out forwards;
animation-iteration-count: infinite;
}}
@keyframes spux-circle {{
0% {{
width:{size}px;
height:{size}px;
margin-top:0px;
margin-left:0px;
}}
50% {{
width:{half_size}px;
height:{half_size}px;
margin-top:{quarter_size}px;
margin-left:{quarter_size}px;
}}
100% {{
width:{size}px;
height:{size}px;
margin-top:0px;
margin-left:0px;
}}
}}
"
);
view! {
<style>
{style}
</style>
<div class="spux-circle"
style:border="2px solid"
style:border-color=color
></div>
}
}