feat: improved UI
This commit is contained in:
@@ -1,75 +1,43 @@
|
||||
{% 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="icon-button">
|
||||
{% include 'components/icons/cart.svg' %}
|
||||
<span class="hidden sm:flex">
|
||||
{% translate 'Carrito' %}</span>
|
||||
<span class="ml-1">({{ cart.items.count }})</span>
|
||||
</button>
|
||||
{% if cart.items.count == 0 %}
|
||||
<p class="text-sm text-base-content/70 py-2">{% translate 'No hay nada en el carrito' %}</p>
|
||||
{% else %}
|
||||
<ul class="flex flex-col gap-3 max-h-80 overflow-y-auto">
|
||||
{% for cart_item in cart.items.all %}
|
||||
<li class="flex items-start gap-3 {% if not forloop.last %}pb-3 border-b border-base-300{% endif %}">
|
||||
<a href="{% url 'web:product_detail' pk=cart_item.product.pk slug=cart_item.product.slug %}" class="shrink-0">
|
||||
<img class="h-14 w-14 rounded-md object-cover bg-base-200" src="{{ cart_item.product.images.all.0.s.url }}" alt="{{ cart_item.product.name }}">
|
||||
</a>
|
||||
|
||||
<!-- Cart -->
|
||||
<div id="myCartDropdown1"
|
||||
class="cart-navbar-floating hidden"
|
||||
>
|
||||
<div>
|
||||
{% if cart.items.count == 0 %}
|
||||
<h2 class="text-sm font-medium ">No hay nada en el carrito</h2>
|
||||
{% endif %}
|
||||
|
||||
{% for cart_item in cart.items.all %}
|
||||
<div>
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex">
|
||||
<a href="{% url 'web:product_detail' pk=cart_item.product.pk slug=cart_item.product.slug %}"
|
||||
class="text-sm font-semibold leading-none hover:underline">
|
||||
{{ cart_item.product.name }}
|
||||
class="text-sm font-semibold leading-snug hover:text-primary line-clamp-2">
|
||||
{{ cart_item.product.name }}
|
||||
</a>
|
||||
{% if cart_item.variant %}
|
||||
<p class="text-xs">
|
||||
<p class="text-xs text-base-content/60">
|
||||
{% for attribute_value in cart_item.variant.attribute_values.all %}{{ attribute_value }}{% if not forloop.last %}, {% endif %}{% endfor %}
|
||||
</p>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<div class="flex items-center justify-between gap-6">
|
||||
<p
|
||||
class="mt-0.5 truncate text-sm font-normal ">
|
||||
{{ cart_item.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 mr-2">
|
||||
{% translate 'Cantidad' %}: {{ cart_item.quantity }}
|
||||
|
||||
</span>
|
||||
<button data-tooltip-target="tooltipRemoveItem1a" type="submit"
|
||||
class="text-red-600 hover:text-red-700 :text-red-600 cursor-pointer"
|
||||
>
|
||||
{% csrf_token %}
|
||||
<span class="sr-only">{% translate 'Quitar' %}</span>
|
||||
{% include 'components/icons/remove.svg' %}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div id="tooltipRemoveItem1a" role="tooltip"
|
||||
class="tooltip invisible absolute z-10 inline-block rounded-lg px-3 py-2 text-sm font-medium
|
||||
text-white opacity-0 shadow-md transition-opacity duration-300 "
|
||||
>
|
||||
{% translate 'Quitar del carrito' %}
|
||||
<div class="tooltip-arrow" data-popper-arrow></div>
|
||||
</div>
|
||||
<div class="flex items-center justify-between gap-2 mt-1">
|
||||
<span class="text-xs text-base-content/60 mx-2">{% translate 'x' %} {{ cart_item.quantity }}</span>
|
||||
<span class="text-sm font-bold">{{ cart_item.price.price_with_tax }} €</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form hx-post="{% url 'web:delete_cart_item' pk=cart_item.pk %}" hx-swap="none">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-ghost btn-xs btn-circle text-error" aria-label="{% translate 'Quitar' %}">
|
||||
{% include 'components/icons/remove.svg' %}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<hr class="h-px mx-4 my-2 " />
|
||||
{% endfor %}
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% if cart.items.count > 0 %}
|
||||
<a href="{% url 'web:cart_detail' %}"
|
||||
class="btn btn-primary"
|
||||
role="button"> {% translate 'Ver carrito' %}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
<a href="{% url 'web:cart_detail' %}" class="btn btn-primary btn-sm w-full mt-4">
|
||||
{% translate 'Ver carrito' %}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user