Skip to content

Commit

Permalink
Add products
Browse files Browse the repository at this point in the history
  • Loading branch information
rayc2045 committed May 5, 2024
1 parent 6a0bfbc commit 91d0263
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/pages/shop/shop.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<div class="flex">
<div class="flex-1">
<div
x-text="`${shop.filteredProducts.length} products`"
class="mb-8 text-gray-500"
></div>
<ul
class="sm:grid place-content-center gap-x-8 gap-y-16 tracking-wide"
style="grid-template-columns: repeat(auto-fit, 18em)"
>
<template x-for="product in shop.filteredProducts" :key="product.name">
<li
x-data="{
lowerName: product.name.toLowerCase().replaceAll(' ', '_'),
currentColor: product.colors[0]
}"
>
<a
:href="`#/shop/${product.category}/${lowerName}`"
class="block mb-1 rounded-md overflow-hidden"
>
<img
:src="`./src/images/products/${lowerName}_${currentColor}.png`"
:alt="product.name"
class="min-w-full"
/>
</a>
<div
x-text="product.label && product.label[0].toUpperCase() + product.label.slice(1)"
class="text-red-500 text-xs font-semibold"
></div>
<a
:href="`#/shop/${product.category}/${lowerName}`"
x-text="product.name"
class="block mb-2 text-lg font-semibold"
:class="!product.label.length && 'mt-5'"
></a>
<div class="space-x-1">
<span
:class="product.discount && 'line-through text-gray-400'"
x-text="`$${product.price}`"
></span>
<span
x-show="product.discount"
x-text="`$${Math.round(product.price * (100 - product.discount.split('%')[0]) / 100) }`"
></span>
<span
x-show="product.discount"
x-text="`-${product.discount}`"
class="px-2 rounded-xl text-xs text-red-600 border border-red-600"
></span>
</div>
</li>
</template>
</ul>
</div>
</div>

0 comments on commit 91d0263

Please sign in to comment.