Skip to content

Commit c6a8c43

Browse files
committed
feat: Add visual feedback for added-to-cart button state
Introduces a new 'button-bezel-added' class to style the add-to-cart button when an item is added. The button now visually distinguishes between 'add' and 'added' states, improving user feedback.
1 parent 072dfcf commit c6a8c43

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

app/pages/product/[id].vue

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ const { handleAddToCart, addToCartButtonStatus } = useCart();
211211
<button
212212
@click="handleAddToCart(selectedVariation.databaseId)"
213213
:disabled="addToCartButtonStatus !== 'add'"
214-
class="button-bezel w-full h-12 rounded-md relative tracking-wide font-semibold text-white text-sm flex justify-center items-center">
214+
class="w-full h-12 rounded-md relative tracking-wide font-semibold text-white text-sm flex justify-center items-center"
215+
:class="addToCartButtonStatus === 'added' ? 'button-bezel-added' : 'button-bezel'">
215216
<Transition name="slide-up">
216217
<div v-if="addToCartButtonStatus === 'add'" class="absolute">{{ $t('cart.add_to_cart') }}</div>
217218
<UIcon v-else-if="addToCartButtonStatus === 'loading'" class="absolute" name="i-svg-spinners-90-ring-with-bg" size="22" />
@@ -288,6 +289,24 @@ const { handleAddToCart, addToCartButtonStatus } = useCart();
288289
}
289290
}
290291
292+
.button-bezel-added {
293+
box-shadow: 0 0 0 var(--button-outline, 0px) rgba(96, 222, 92, 0.3), inset 0 -1px 1px 0 rgba(0, 0, 0, 0.25), inset 0 1px 0 0 rgba(255, 255, 255, 0.3),
294+
0 1px 2px 0 rgba(0, 0, 0, 0.5);
295+
@apply bg-green-600 outline-none tracking-[-0.125px] transition scale-[var(--button-scale,1)] duration-200;
296+
&:hover {
297+
@apply bg-green-500;
298+
}
299+
&:active {
300+
--button-outline: 4px;
301+
--button-scale: 0.975;
302+
}
303+
}
304+
305+
button.button-bezel,
306+
button.button-bezel-added {
307+
@apply transition-colors duration-300;
308+
}
309+
291310
.description ul li {
292311
background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxlbGxpcHNlIHJ5PSIzIiByeD0iMyIgY3k9IjMiIGN4PSIzIiBmaWxsPSIjYzljOWM5Ii8+PC9zdmc+)
293312
no-repeat 0 0.7rem;

0 commit comments

Comments
 (0)