{# ================================================================================ Search Inline Component (Kida-Native) ================================================================================ A compact, embeddable search component that matches the modal design language. Can be included on any page for inline search functionality. KIDA FEATURES: - {% let %} for template-scoped variables and nil-resilient defaults - Optional chaining (?.) for null-safe config access - Null coalescing (??) for smart defaults - {% match %} for variant-based rendering - {% spaceless %} for clean HTML output - {% capture %} for buffered content - t() for full i18n support Dependencies: - JavaScript: /assets/js/core/search.js (BengalSearch module) - CSS: /assets/css/components/search.css Usage: {% include 'partials/search.html' %} {% include 'partials/search.html' with variant='compact' %} {% include 'partials/search.html' with show_filters=true %} ================================================================================ #} {# ============================================================================ Configuration & Defaults (nil-resilient) ============================================================================ #} {% let search_config = config?.search ?? {} %} {% let ui_config = search_config?.ui ?? {} %} {% let variant = variant ?? ui_config?.inline_variant ?? 'default' %} {% let show_filters = show_filters ?? ui_config?.show_filters ?? true %} {% let show_shortcuts = show_shortcuts ?? ui_config?.show_shortcuts ?? true %} {% let placeholder = placeholder ?? ui_config?.placeholder ?? t('search.placeholder', default='Search documentation...') %} {% let autofocus = autofocus ?? false %} {# ============================================================================ Variant Configuration ============================================================================ #} {% let VARIANT_CONFIG = { 'default': {'show_header': true, 'max_results': 10, 'collapsed_api': true}, 'compact': {'show_header': false, 'max_results': 5, 'collapsed_api': true}, 'full': {'show_header': true, 'max_results': 20, 'collapsed_api': false} } %} {% let active_config = VARIANT_CONFIG[variant] ?? VARIANT_CONFIG['default'] %} {# ============================================================================ Main Component ============================================================================ #}
{# -------------------------------------------------------------------- Search Input Section -------------------------------------------------------------------- #}
{{ icon('magnifying-glass', size=18, css_class='search-inline__icon') }} {# Keyboard shortcut hint (hideable) #} {% if show_shortcuts %} {% spaceless %} {% endspaceless %} {% end %} {# Loading indicator #} {# Clear button #}
{# -------------------------------------------------------------------- Screen Reader Status -------------------------------------------------------------------- #}
{# -------------------------------------------------------------------- Filters Section (optional) -------------------------------------------------------------------- #} {% if show_filters %} {% end %} {# -------------------------------------------------------------------- Search Results Container -------------------------------------------------------------------- #} {# -------------------------------------------------------------------- Loading State -------------------------------------------------------------------- #} {# -------------------------------------------------------------------- Error State -------------------------------------------------------------------- #}
{# ============================================================================ Component Initialization ============================================================================ The search functionality is handled by /assets/js/core/search.js which provides the BengalSearch module. The inline component uses the same search engine as the modal and search page for consistency. CSS is loaded from /assets/css/components/search.css ============================================================================ #}