{# Card Macros =========== Reusable card components including stats cards, info cards, and action cards. Usage: {% from 'shared/macros/cards.html' import stat_card, info_card, card %} {{ stat_card('users', 'Total Users', 'stats.total', 'blue') }} {{ info_card('User Details', 'View and edit user information') }} #} {# Stat Card ========= A statistics card with icon and value. Parameters: - icon: Icon name - label: Card label/title - value: Alpine.js expression for the value - color: 'orange' | 'green' | 'blue' | 'purple' | 'red' | 'yellow' (default: 'orange') - format: Optional format function to apply to value #} {% macro stat_card(icon, label, value, color='orange', format=none) %} {% set colors = { 'orange': 'text-orange-500 bg-orange-100 dark:text-orange-100 dark:bg-orange-500', 'green': 'text-green-500 bg-green-100 dark:text-green-100 dark:bg-green-500', 'blue': 'text-blue-500 bg-blue-100 dark:text-blue-100 dark:bg-blue-500', 'purple': 'text-purple-500 bg-purple-100 dark:text-purple-100 dark:bg-purple-500', 'red': 'text-red-500 bg-red-100 dark:text-red-100 dark:bg-red-500', 'yellow': 'text-yellow-500 bg-yellow-100 dark:text-yellow-100 dark:bg-yellow-500', 'teal': 'text-teal-500 bg-teal-100 dark:text-teal-100 dark:bg-teal-500' } %}

{{ label }}

0

{% endmacro %} {# Stat Card with Trend ==================== A statistics card with icon, value, and trend indicator. Parameters: - icon: Icon name - label: Card label/title - value: Alpine.js expression for the value - trend_value: Alpine.js expression for trend percentage (e.g., '+12.5%' or '-3.2%') - trend_direction: Alpine.js expression for direction ('up' | 'down' | 'neutral') - color: Card color theme - format: Optional format function - compare_label: Label for comparison period (default: 'vs last month') #} {% macro stat_card_with_trend(icon, label, value, trend_value, trend_direction='neutral', color='orange', format=none, compare_label='vs last month') %} {% set colors = { 'orange': 'text-orange-500 bg-orange-100 dark:text-orange-100 dark:bg-orange-500', 'green': 'text-green-500 bg-green-100 dark:text-green-100 dark:bg-green-500', 'blue': 'text-blue-500 bg-blue-100 dark:text-blue-100 dark:bg-blue-500', 'purple': 'text-purple-500 bg-purple-100 dark:text-purple-100 dark:bg-purple-500', 'red': 'text-red-500 bg-red-100 dark:text-red-100 dark:bg-red-500', 'yellow': 'text-yellow-500 bg-yellow-100 dark:text-yellow-100 dark:bg-yellow-500', 'teal': 'text-teal-500 bg-teal-100 dark:text-teal-100 dark:bg-teal-500' } %}

{{ label }}

0

{{ compare_label }}

{% endmacro %} {# Stats Grid ========== A grid container for stat cards. Parameters: - columns: Number of columns (default: 4) #} {% macro stats_grid(columns=4) %} {% set col_classes = { 2: 'md:grid-cols-2', 3: 'md:grid-cols-3', 4: 'md:grid-cols-2 xl:grid-cols-4' } %}
{{ caller() }}
{% endmacro %} {# Card ==== A basic card container. Parameters: - title: Card title (optional) - subtitle: Card subtitle (optional) - class_extra: Additional CSS classes - padding: Whether to add padding (default: true) #} {% macro card(title=none, subtitle=none, class_extra='', padding=true) %}
{% if title %}

{{ title }}

{% if subtitle %}

{{ subtitle }}

{% endif %}
{% endif %}
{{ caller() }}
{% endmacro %} {# Card with Menu ============== A card with a dropdown menu in the header. Parameters: - title: Card title - subtitle: Card subtitle (optional) - menu_var: Alpine.js variable for menu open state (default: 'menuOpen') - class_extra: Additional CSS classes #} {% macro card_with_menu(title, subtitle=none, menu_var='menuOpen', class_extra='') %}

{{ title }}

{% if subtitle %}

{{ subtitle }}

{% endif %}
{{ caller_menu() if caller_menu is defined else '' }}
{{ caller() }}
{% endmacro %} {# Card with Menu (Simple) ======================= A simpler card with menu that accepts menu items as a parameter. Parameters: - title: Card title - menu_items: List of menu items [{'label': '', 'onclick': '', 'icon': '', 'variant': ''}] - subtitle: Card subtitle (optional) - class_extra: Additional CSS classes #} {% macro card_with_menu_simple(title, menu_items=[], subtitle=none, class_extra='') %}

{{ title }}

{% if subtitle %}

{{ subtitle }}

{% endif %}
{% if menu_items %}
{% for item in menu_items %} {% endfor %}
{% endif %}
{{ caller() }}
{% endmacro %} {# Info Card ========= An informational card with icon and description. Parameters: - icon: Icon name - title: Card title - description: Card description - color: Icon color (default: 'purple') - href: Optional link URL #} {% macro info_card(icon, title, description, color='purple', href=none) %} {% set colors = { 'purple': 'text-purple-500 bg-purple-100 dark:text-purple-100 dark:bg-purple-500', 'blue': 'text-blue-500 bg-blue-100 dark:text-blue-100 dark:bg-blue-500', 'green': 'text-green-500 bg-green-100 dark:text-green-100 dark:bg-green-500', 'orange': 'text-orange-500 bg-orange-100 dark:text-orange-100 dark:bg-orange-500' } %} {% if href %} {% else %}
{% endif %}

{{ title }}

{{ description }}

{% if href %}
{% else %}
{% endif %} {% endmacro %} {# Quick Actions Card ================== A card with quick action buttons and status badges. Parameters: - title: Card title (default: 'Quick Actions') #} {% macro quick_actions_card(title='Quick Actions') %}

{{ title }}

{{ caller() }}
{% endmacro %} {# Coming Soon Card ================ A placeholder card for features under development. Parameters: - emoji: Emoji to display - title: Feature title - description: Feature description - back_url: URL for back button - back_label: Back button text (default: 'Go Back') #} {% macro coming_soon_card(emoji='📦', title='Coming Soon', description='This feature is under development.', back_url='/', back_label='Go Back') %}
{{ emoji }}

{{ title }}

{{ description }}

{{ back_label }}
{% endmacro %} {# Filter Card =========== A card for search and filter controls. Parameters: - show_condition: Alpine.js condition (default: '!loading') #} {% macro filter_card(show_condition='!loading') %}
{{ caller() }}
{% endmacro %}