//! Loading spinner component

use leptos::prelude::*;

/// Loading spinner component
///
/// Displays an animated loading spinner with optional message.
/// Used during async operations or data fetching.
///
/// # Props
///
/// - `message`: Optional loading message to display
#[component]
pub fn Loading(
    /// Optional message to display with the spinner
    #[prop(optional)]
    message: Option<&'static str>,
) -> impl IntoView {
    let display_message = message.unwrap_or("Loading...");

    view! {
        <div class="flex flex-col items-center justify-center p-8">
            <div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"></div>
            <p class="mt-4 text-gray-600 dark:text-gray-400">{display_message}</p>
        </div>
    }
}

/// Inline loading spinner (smaller version)
///
/// A compact loading spinner for inline use within components.
#[component]
pub fn LoadingInline() -> impl IntoView {
    view! {
        <div class="inline-block animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"></div>
    }
}
