Skip to content

Commit

Permalink
Add product color switching
Browse files Browse the repository at this point in the history
  • Loading branch information
rayc2045 committed May 5, 2024
1 parent 1f5dea3 commit 98191ad
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/pages/shop/shop.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
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)"
class="grid place-content-center grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-x-8 gap-y-12 tracking-wide"
>
<template x-for="product in shop.filteredProducts" :key="product.name">
<li
Expand All @@ -25,16 +24,18 @@
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"
x-text="`${product.name}${product.colors.length > 1 && ` (${currentColor})`}`"
class="block mb-1 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'"
Expand All @@ -50,6 +51,19 @@
class="px-2 rounded-xl text-xs text-red-600 border border-red-600"
></span>
</div>

<template x-if="product.colors.length > 1">
<div class="mt-3 flex gap-x-1.5">
<template x-for="color in product.colors">
<button
class="w-5 aspect-square rounded-full border border-gray-500 pointer"
:class="color"
:title="color"
@click="currentColor = color"
></button>
</template>
</div>
</template>
</li>
</template>
</ul>
Expand Down
24 changes: 24 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,27 @@ body {
#side-menu::-webkit-scrollbar {
width: 0;
}

.white {
background-color: ghostwhite;
}

.gray {
background-color: gray;
}

.black {
background-color: #333;
}

.amber {
background-color: peru;
}

.green {
background-color: olivedrab;
}

.blue {
background-color: steelblue;
}

0 comments on commit 98191ad

Please sign in to comment.