//! Unified brand header component
//!
//! Provides consistent branding (logo or title) with identical behavior
//! across navigation menu and footer components.

use leptos::prelude::*;

/// Extract logo configuration from registered theme
///
/// This function reads from the registered theme resources (loaded at server
/// startup from config/themes/default.toml) to get configuration-driven logo
/// paths. PAP-compliant: Uses registered resources, no hardcoding.
fn get_logo_config() -> (String, String, String) {
    // Always use fallback for consistency between SSR and client
    // Theme loading happens at startup/server-side only
    // For hydration safety, we render without dynamic theme lookups
    (String::new(), String::new(), "Logo".to_string())
}

/// Unified brand header that works consistently in nav and footer
#[component]
#[allow(unused_variables)]
pub fn BrandHeader(
    /// Language for loading configuration
    #[prop(optional)]
    language: Option<String>,
    /// CSS classes for the brand element
    #[prop(default = "text-xl font-bold".to_string())]
    class: String,
    /// Force show/hide logo (overrides config)
    #[prop(optional)]
    force_logo: Option<bool>,
    /// Use footer logo settings instead of nav settings
    #[prop(default = false)]
    is_footer: bool,
) -> impl IntoView {
    // Get logo configuration
    let (logo_light, logo_dark, logo_alt) = get_logo_config();

    // Always render text for hydration safety - use static classes to avoid string
    // issues
    view! {
        <a href="/" class="text-xl font-bold transition-colors flex items-center gap-2">
            <span class="ds-text">"Rustelo"</span>
        </a>
    }
}
