Files
shoppy/web/templates/components/cart/cart_navbar.html
T
2024-11-27 18:12:50 +01:00

94 lines
4.1 KiB
HTML

{% load i18n %}
<button
hx-on:click="htmx.toggleClass(htmx.find('#myCartDropdown1'), 'hidden'); htmx.addClass(htmx.find('#userDropdown1'), 'hidden')"
id="myCartDropdownButton1"
data-dropdown-toggle="myCartDropdown1" type="button"
class="inline-flex items-center rounded-lg justify-center p-2 hover:bg-gray-100 dark:hover:bg-gray-700 text-sm font-medium leading-none text-gray-900 dark:text-white">
<span class="sr-only">
{% blocktranslate %}
Carrito
{% endblocktranslate %}({{ cart.items.count }})
</span>
<svg class="w-5 h-5 lg:me-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24"
fill="none" viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M5 4h1.5L9 16m0 0h8m-8 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4Zm8 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4Zm-8.5-3h9.25L19 7H7.312"/>
</svg>
<span class="sm:flex">
{% blocktranslate %}
Carrito
{% endblocktranslate %}({{ cart.items.count }})</span>
<svg class="hidden sm:flex w-4 h-4 text-gray-900 dark:text-white ms-1" aria-hidden="true"
xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="m19 9-7 7-7-7"/>
</svg>
</button>
<!-- Cart -->
<div id="myCartDropdown1"
class="absolute top-10 hidden z-10 mx-auto max-w-sm space-y-4 overflow-hidden rounded-lg bg-white p-4 antialiased shadow-lg dark:bg-gray-800">
<div>
{% if cart.items.count == 0 %}
<h2 class="text-sm font-medium text-gray-900 dark:text-white">No hay nada en el carrito</h2>
{% endif %}
{% for cart_item in cart.items.all %}
<div>
<a href="#"
class="truncate text-sm font-semibold leading-none text-gray-900 dark:text-white hover:underline">
{{ cart_item.product.name }}
</a>
<div class="flex items-center justify-between gap-6">
<p
class="mt-0.5 truncate text-sm font-normal text-gray-500 dark:text-gray-400">
{{ cart_item.product.price.price_with_tax }}€
</p>
<form hx-post="{% url 'web:delete_cart_item' pk=cart_item.pk %}"
hx-swap="none">
<span class="mt-0.5 truncate text-sm font-normal text-gray-500 dark:text-gray-400 mr-2">
{% translate 'Cantidad' %}: {{ cart_item.quantity }}
</span>
<button data-tooltip-target="tooltipRemoveItem1a" type="submit"
class="text-red-600 hover:text-red-700 dark:text-red-500 dark:hover:text-red-600"
>
{% csrf_token %}
<span class="sr-only">{% translate 'Quitar' %}</span>
<svg class="h-4 w-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
viewBox="0 0 24 24">
<path fill-rule="evenodd"
d="M2 12a10 10 0 1 1 20 0 10 10 0 0 1-20 0Zm7.7-3.7a1 1 0 0 0-1.4 1.4l2.3 2.3-2.3 2.3a1 1 0 1 0 1.4 1.4l2.3-2.3 2.3 2.3a1 1 0 0 0 1.4-1.4L13.4 12l2.3-2.3a1 1 0 0 0-1.4-1.4L12 10.6 9.7 8.3Z"
clip-rule="evenodd"/>
</svg>
</button>
</form>
<div id="tooltipRemoveItem1a" role="tooltip"
class="tooltip invisible absolute z-10 inline-block rounded-lg bg-gray-900 px-3 py-2 text-sm font-medium
text-white opacity-0 shadow-sm transition-opacity duration-300 dark:bg-gray-700"
>
{% translate 'Quitar del carrito' %}
<div class="tooltip-arrow" data-popper-arrow></div>
</div>
</div>
</div>
{% endfor %}
</div>
{% if cart.items.count > 0 %}
<a href="#" title=""
class="mb-2 me-2 inline-flex w-full items-center justify-center rounded-lg bg-primary-700 px-5 py-2.5 text-sm
font-medium text-white hover:bg-primary-800 focus:outline-none focus:ring-4 focus:ring-primary-300
dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800"
role="button"> {% translate 'Ir a pagar' %}
</a>
{% endif %}
</div>