icons 0.7.0

Icons for Rust fullstack applications — Leptos and Dioxus.
Documentation
//! Single Icon component using registry pattern
//!
//! This module provides a unified Icon component that replaces 1,636 individual
//! icon components with a single registry-based implementation.

use leptos::prelude::*;

use super::icon_registry::get_icon_elements;
use super::icon_type::IconType;
use super::svg_icon::SvgIcon;

/// Single Icon component using registry lookup (Dioxus pattern for Leptos)
///
/// This component replaces all individual icon components with a unified
/// registry-based implementation for better build performance.
///
/// # Example
/// ```rust
/// use icons::leptos::{Icon, IconType};
/// use leptos::prelude::*;
///
/// fn example() -> impl IntoView {
///     view! {
///         <Icon icon=IconType::Activity class="w-6 h-6" />
///         <Icon icon=IconType::ArrowRight class="text-blue-500" />
///     }
/// }
/// ```
#[component]
pub fn Icon(
    /// The icon type from the registry
    icon: IconType,
    /// Optional CSS classes (reactive)
    #[prop(into, optional)]
    class: Signal<String>,
) -> impl IntoView {
    // Get elements from static registry, zero allocation
    let elements = get_icon_elements(icon).unwrap_or(&[]);

    view! {
        <SvgIcon class=class data_name=icon.to_string()>
            <title>{format!("Rust UI Icons - {icon}")}</title>

            {elements.iter().map(|element| { element.to_leptos_view() }).collect::<Vec<_>>()}
        </SvgIcon>
    }
}