11<script setup lang="ts">
2+ defineOptions ({ name: ' PlaygroundCart' })
23definePageMeta ({
34 title: ' Shopping Cart' ,
45})
@@ -40,7 +41,10 @@ function removeItem(productId: string) {
4041 Shopping Cart
4142 </h1 >
4243
43- <div v-if =" cart.isEmpty.value" class =" flex flex-col items-center gap-4 py-16 text-center" >
44+ <div
45+ v-if =" cart.isEmpty.value"
46+ class =" flex flex-col items-center gap-4 py-16 text-center"
47+ >
4448 <span class =" i-lucide-shopping-cart text-6xl text-muted" />
4549 <p class =" text-lg text-muted" >
4650 Your cart is empty
@@ -50,7 +54,10 @@ function removeItem(productId: string) {
5054 </UButton >
5155 </div >
5256
53- <div v-else class =" grid gap-8 lg:grid-cols-3" >
57+ <div
58+ v-else
59+ class =" grid gap-8 lg:grid-cols-3"
60+ >
5461 <div class =" space-y-3 lg:col-span-2" >
5562 <UCard
5663 v-for =" item in cart .items .value "
@@ -63,7 +70,7 @@ function removeItem(productId: string) {
6370 :src =" item.image"
6471 :alt =" item.name"
6572 class =" h-20 w-20 flex-shrink-0 rounded-lg object-cover"
66- / >
73+ >
6774 <div class =" min-w-0 flex-1" >
6875 <p class =" font-medium truncate" >
6976 {{ item.name }}
@@ -103,7 +110,12 @@ function removeItem(productId: string) {
103110 </div >
104111 </UCard >
105112
106- <UButton variant="soft" color="error" size="sm" @click =" cart .clear ()" >
113+ <UButton
114+ variant="soft"
115+ color="error"
116+ size="sm"
117+ @click =" cart .clear ()"
118+ >
107119 Clear Cart
108120 </UButton >
109121 </div >
@@ -122,12 +134,15 @@ function removeItem(productId: string) {
122134 <span >${{ cart.totalAmount.value.toFixed(2) }}</span >
123135 </div >
124136
125- <div v-if =" cart.coupon.value" class =" flex items-center justify-between text-green-600" >
137+ <div
138+ v-if =" cart.coupon.value"
139+ class =" flex items-center justify-between text-green-600"
140+ >
126141 <div class =" flex items-center gap-1" >
127142 <span >Discount ({{ cart.coupon.value.code }})</span >
128143 <UButton
129144 icon="i-lucide-x"
130- size="2xs "
145+ size="xs "
131146 color="error"
132147 variant="ghost"
133148 @click =" removeCoupon "
@@ -136,15 +151,22 @@ function removeItem(productId: string) {
136151 <span >- ${{ (cart.totalAmount.value - cart.discountedTotal.value).toFixed(2) }}</span >
137152 </div >
138153
139- <div v-if =" cart.coupons && !cart.coupon.value" class =" flex gap-2" >
154+ <div
155+ v-if =" !cart.coupon.value"
156+ class =" flex gap-2"
157+ >
140158 <UInput
141159 v-model =" couponCode "
142160 placeholder="Coupon code"
143161 size="sm"
144162 class="flex-1"
145163 @keydown .enter =" applyCoupon "
146164 />
147- <UButton size="sm" variant="soft" @click =" applyCoupon " >
165+ <UButton
166+ size="sm"
167+ variant="soft"
168+ @click =" applyCoupon "
169+ >
148170 Apply
149171 </UButton >
150172 </div >
0 commit comments