feat: complete TailAdmin parity with remaining macro features
Add missing features identified in TailAdmin gap analysis: cards.html: - stat_card_with_trend: Stats card with up/down trend indicator and percentage - card_with_menu: Card with dropdown menu in header - card_with_menu_simple: Simplified version with menu_items parameter tables.html: - sortable_table_header: Table header with sortable columns, sort indicators, and Alpine.js integration for sort state management forms.html: - searchable_select: Dropdown with search/filter functionality - multi_select: Multi-select dropdown with tag display This completes feature parity with TailAdmin free template. The tailadmin-free-tailwind-dashboard-template folder can now be deleted. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,65 @@
|
||||
{% 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'
|
||||
} %}
|
||||
<div class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center">
|
||||
<div class="p-3 mr-4 rounded-full {{ colors[color] }}">
|
||||
<span x-html="$icon('{{ icon }}', 'w-5 h-5')"></span>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-sm font-medium text-gray-600 dark:text-gray-400">{{ label }}</p>
|
||||
<p class="text-2xl font-semibold text-gray-700 dark:text-gray-200"
|
||||
x-text="{% if format %}{{ format }}({{ value }}){% else %}{{ value }} || 0{% endif %}">0</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<span class="inline-flex items-center text-sm font-medium"
|
||||
:class="{
|
||||
'text-green-600 dark:text-green-400': {{ trend_direction }} === 'up',
|
||||
'text-red-600 dark:text-red-400': {{ trend_direction }} === 'down',
|
||||
'text-gray-500 dark:text-gray-400': {{ trend_direction }} === 'neutral'
|
||||
}">
|
||||
<svg x-show="{{ trend_direction }} === 'up'" class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 10l7-7m0 0l7 7m-7-7v18"/>
|
||||
</svg>
|
||||
<svg x-show="{{ trend_direction }} === 'down'" class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 14l-7 7m0 0l-7-7m7 7V3"/>
|
||||
</svg>
|
||||
<span x-text="{{ trend_value }}"></span>
|
||||
</span>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">{{ compare_label }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{#
|
||||
Stats Grid
|
||||
==========
|
||||
@@ -97,6 +156,110 @@
|
||||
{% 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='') %}
|
||||
<div x-data="{ {{ menu_var }}: false }" class="bg-white rounded-lg shadow-xs dark:bg-gray-800 {{ class_extra }}">
|
||||
<div class="flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-gray-700 dark:text-gray-200">{{ title }}</h3>
|
||||
{% if subtitle %}
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">{{ subtitle }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="relative">
|
||||
<button
|
||||
@click="{{ menu_var }} = !{{ menu_var }}"
|
||||
@click.outside="{{ menu_var }} = false"
|
||||
class="p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"
|
||||
>
|
||||
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>
|
||||
</svg>
|
||||
</button>
|
||||
<div
|
||||
x-show="{{ menu_var }}"
|
||||
x-transition
|
||||
class="absolute right-0 mt-1 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-10"
|
||||
>
|
||||
{{ caller_menu() if caller_menu is defined else '' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-4">
|
||||
{{ caller() }}
|
||||
</div>
|
||||
</div>
|
||||
{% 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='') %}
|
||||
<div x-data="{ menuOpen: false }" class="bg-white rounded-lg shadow-xs dark:bg-gray-800 {{ class_extra }}">
|
||||
<div class="flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-gray-700 dark:text-gray-200">{{ title }}</h3>
|
||||
{% if subtitle %}
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">{{ subtitle }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if menu_items %}
|
||||
<div class="relative">
|
||||
<button
|
||||
@click="menuOpen = !menuOpen"
|
||||
@click.outside="menuOpen = false"
|
||||
class="p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"
|
||||
>
|
||||
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>
|
||||
</svg>
|
||||
</button>
|
||||
<div
|
||||
x-show="menuOpen"
|
||||
x-transition
|
||||
class="absolute right-0 mt-1 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-10"
|
||||
>
|
||||
{% for item in menu_items %}
|
||||
<button
|
||||
@click="{{ item.onclick }}; menuOpen = false"
|
||||
class="flex items-center w-full px-4 py-2 text-sm font-medium transition-colors {{ 'text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20' if item.variant == 'danger' else 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700' }}"
|
||||
>
|
||||
{% if item.icon %}
|
||||
<span x-html="$icon('{{ item.icon }}', 'w-4 h-4 mr-3')"></span>
|
||||
{% endif %}
|
||||
{{ item.label }}
|
||||
</button>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="p-4">
|
||||
{{ caller() }}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{#
|
||||
Info Card
|
||||
=========
|
||||
|
||||
Reference in New Issue
Block a user