11<template >
2- <div class =" w-full" >
3- <h3 class =" h-12 py-4 mt-2 text-2xl font-bold text-center" >Cart summary</h3 >
4- </div >
2+ <div class =" w-full" >
3+ <h3 class =" h-12 py-4 mt-2 text-2xl font-bold text-center" >
4+ Cart summary
5+ </h3 >
6+ </div >
57
6- <div class =" relative mt-2 overflow-x-auto" >
7- <table
8- class =" w-full flex flex-row flex-no-wrap sm:bg-white rounded-lg overflow-hidden sm:shadow-lg my-5"
9- >
10- <caption class =" sr-only" >
11- Cart summary
12- </caption >
13- <thead class =" text-white" >
14- <template v-for =" _content in getCartContent " :key =" content " >
15- <tr
16- class =" bg-gray-600 flex flex-col flex-no wrap sm:table-row rounded-l-lg sm:rounded-none mb-2 sm:mb-0"
17- >
18- <th
19- v-for =" header in tableHeaders"
20- :key =" header"
21- scope =" col"
22- class =" p-3 text-center h-12"
23- >
24- {{ header }}
25- </th >
26- </tr >
27- </template >
28- </thead >
29- <tbody class =" flex-1 sm:flex-none" >
30- <template
31- v-for =" { id , name , quantity , price } in getCartContent "
32- :key =" id "
33- class="border-grey-light border hover:bg-gray-100 p-3 text-center"
8+ <div class =" relative mt-2 overflow-x-auto" >
9+ <table
10+ class =" w-full flex flex-row flex-no-wrap sm:bg-white rounded-lg overflow-hidden sm:shadow-lg my-5"
3411 >
35- <tr class =" flex flex-col flex-no wrap sm:table-row mb-2 sm:mb-0" >
36- <td class =" border-grey-light border hover:bg-gray-100 h-12" >
37- <a tabindex =" 0" @click =" removeProductFromCart(id)" >
38- <img
39- class =" mt-2 mx-auto cursor-pointer"
40- alt =" Remove icon"
41- aria-label =" Remove"
42- src =" ../../../img/svg/Remove.svg"
43- />
44- </a >
45- </td >
46- <td class =" border-grey-light border hover:bg-gray-100 p-3 text-center h-12" >
47- {{ name }}
48- </td >
49- <td class =" border-grey-light border hover:bg-gray-100 p-3 text-center h-12" >
50- {{ quantity }}
51- </td >
52- <td class =" border-grey-light border hover:bg-gray-100 p-3 text-center h-12" >
53- {{ formatPrice(price) }}
54- </td >
55- </tr >
56- </template >
57- </tbody >
58- </table >
59- <div
60- v-if =" getCartQuantity"
61- class =" container mx-auto flex flex-wrap flex-row justify-end items-end content-center"
62- >
63- <span class =" p-4 text-xl font-bold text-right"
64- >Total: {{ formatPrice(getCartTotal) }}</span
65- >
12+ <caption class =" sr-only" >
13+ Cart summary
14+ </caption >
15+ <thead class =" text-white" >
16+ <template v-for =" _content in getCartContent " :key =" content " >
17+ <tr
18+ class =" bg-gray-600 flex flex-col flex-no wrap sm:table-row rounded-l-lg sm:rounded-none mb-2 sm:mb-0"
19+ >
20+ <th
21+ v-for =" header in tableHeaders"
22+ :key =" header"
23+ scope =" col"
24+ class =" p-3 text-center h-12"
25+ >
26+ {{ header }}
27+ </th >
28+ </tr >
29+ </template >
30+ </thead >
31+ <tbody class =" flex-1 sm:flex-none" >
32+ <template
33+ v-for =" { id , name , quantity , price } in getCartContent "
34+ :key =" id "
35+ class="border-grey-light border hover:bg-gray-100 p-3 text-center"
36+ >
37+ <tr
38+ class =" flex flex-col flex-no wrap sm:table-row mb-2 sm:mb-0"
39+ >
40+ <td
41+ class =" border-grey-light border hover:bg-gray-100 h-12"
42+ >
43+ <a tabindex =" 0" @click =" removeProductFromCart(id)" >
44+ <img
45+ class =" mt-2 mx-auto cursor-pointer"
46+ alt =" Remove icon"
47+ aria-label =" Remove"
48+ src =" ../../../img/svg/Remove.svg"
49+ />
50+ </a >
51+ </td >
52+ <td
53+ class =" border-grey-light border hover:bg-gray-100 p-3 text-center h-12"
54+ >
55+ {{ name }}
56+ </td >
57+ <td
58+ class =" border-grey-light border hover:bg-gray-100 p-3 text-center h-12"
59+ >
60+ {{ quantity }}
61+ </td >
62+ <td
63+ class =" border-grey-light border hover:bg-gray-100 p-3 text-center h-12"
64+ >
65+ {{ formatPrice(price) }}
66+ </td >
67+ </tr >
68+ </template >
69+ </tbody >
70+ </table >
71+ <div
72+ v-if =" getCartQuantity"
73+ class =" container mx-auto flex flex-wrap flex-row justify-end items-end content-center"
74+ >
75+ <span class =" p-4 text-xl font-bold text-right"
76+ >Total: {{ formatPrice(getCartTotal) }}</span
77+ >
78+ </div >
6679 </div >
67- </div >
6880</template >
6981
7082<script setup>
@@ -80,26 +92,26 @@ const store = useCart();
8092const { getCartContent , getCartTotal , getCartQuantity } = storeToRefs (store);
8193
8294const removeProductFromCart = (id ) => {
83- store .removeProductFromCart (id);
95+ store .removeProductFromCart (id);
8496};
8597 </script >
8698
8799<style >
88100@media (min-width : 640px ) {
89- table {
90- display : inline-table !important ;
91- }
101+ table {
102+ display : inline-table !important ;
103+ }
92104
93- thead tr :not (:first-child ) {
94- display : none ;
95- }
105+ thead tr :not (:first-child ) {
106+ display : none ;
107+ }
96108}
97109
98110td :not (:last-child ) {
99- border-bottom : 0 ;
111+ border-bottom : 0 ;
100112}
101113
102114th :not (:last-child ) {
103- border-bottom : 2px solid rgba (0 , 0 , 0 , 0.1 );
115+ border-bottom : 2px solid rgba (0 , 0 , 0 , 0.1 );
104116}
105117 </style >
0 commit comments