use leptos::prelude::*;

use crate::theme::Size;

#[component]
pub fn SpinnerSSR(size: Size, class: &'static str) -> impl IntoView {
    let size_classes = match size {
        Size::Small => "w-4 h-4",
        Size::Medium => "w-8 h-8",
        Size::Large => "w-12 h-12",
    };

    let base_classes =
        "inline-block border-2 border-cyan-500/30 border-t-cyan-400 rounded-full animate-spin";
    let combined_classes = format!("{} {} {}", base_classes, size_classes, class);

    view! {
        <div class=combined_classes role="status" aria-label="Loading">
            <span class="sr-only">"Loading..."</span>
        </div>
    }
}
