{# Button components #} {% macro button(text, variant="primary", size="md", type="button", href=None, disabled=false, icon=None, loading=false) %} {% set base_classes = "inline-flex items-center justify-center font-semibold shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 transition-colors" %} {% set size_classes = { 'xs': 'rounded px-2 py-1 text-xs gap-x-1', 'sm': 'rounded px-2.5 py-1.5 text-sm gap-x-1.5', 'md': 'rounded-md px-3 py-2 text-sm gap-x-2', 'lg': 'rounded-md px-3.5 py-2.5 text-sm gap-x-2', 'xl': 'rounded-md px-4 py-3 text-base gap-x-2.5' } %} {% set variant_classes = { 'primary': 'bg-indigo-600 text-white hover:bg-indigo-500 focus-visible:outline-indigo-600', 'secondary': 'bg-white text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50', 'danger': 'bg-red-600 text-white hover:bg-red-500 focus-visible:outline-red-600', 'success': 'bg-green-600 text-white hover:bg-green-500 focus-visible:outline-green-600', 'ghost': 'bg-transparent text-gray-600 hover:bg-gray-100 hover:text-gray-900', 'link': 'bg-transparent text-indigo-600 hover:text-indigo-500 shadow-none' } %} {% set disabled_classes = "opacity-50 cursor-not-allowed" if disabled else "" %} {% if href %} {% if loading %} {% elif icon %}{{ icon }}{% endif %} {{ text }} {% else %} {% endif %} {% endmacro %} {% macro button_group() %} {{ caller() }} {% endmacro %} {% macro icon_button(icon, label, variant="ghost", size="md", href=None, type="button") %} {% set size_classes = { 'sm': 'p-1', 'md': 'p-1.5', 'lg': 'p-2' } %} {% set icon_size_classes = { 'sm': 'h-4 w-4', 'md': 'h-5 w-5', 'lg': 'h-6 w-6' } %} {% set variant_classes = { 'primary': 'text-indigo-600 hover:text-indigo-500 hover:bg-indigo-50', 'danger': 'text-red-600 hover:text-red-500 hover:bg-red-50', 'ghost': 'text-gray-400 hover:text-gray-500 hover:bg-gray-100' } %} {% if href %} {{ label }} {{ icon }} {% else %} {% endif %} {% endmacro %} {# Common icons as SVG strings #} {% set icons = { 'plus': '', 'edit': '', 'trash': '', 'view': '' } %}