Comparatif.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <LayoutContainer>
  3. <v-row class="center-90">
  4. <table v-if="mdAndUp">
  5. <thead>
  6. <tr>
  7. <th/>
  8. <th>
  9. <p class="standard">Standard</p>
  10. <p class="from">À partir de</p>
  11. <p class="price">
  12. {{ standardPrice }} <span class="ttc">ttc</span>
  13. </p>
  14. <p class="month">/mois</p>
  15. </th>
  16. <th class="premium-column">
  17. <p class="standard">Premium</p>
  18. <p class="from">À partir de</p>
  19. <p class="price">
  20. {{ premiumPrice }} <span class="ttc">ttc</span>
  21. </p>
  22. <p class="month">/mois</p>
  23. </th>
  24. </tr>
  25. </thead>
  26. <tbody>
  27. <tr
  28. v-for="(item, index) in items"
  29. :key="item.label"
  30. >
  31. <td class="label-column">
  32. {{ item.label }}
  33. </td>
  34. <td>
  35. <v-icon
  36. v-if="item.includedInStandard === true"
  37. icon="far fa-check-circle"
  38. size="18"
  39. />
  40. <v-icon
  41. v-else-if="item.includedInStandard === false"
  42. icon="far fa-times-circle"
  43. size="18"
  44. color="red"
  45. />
  46. <span v-else>
  47. {{ item.includedInStandard }}
  48. </span>
  49. </td>
  50. <td>
  51. <v-icon
  52. v-if="item.includedInPremium === true"
  53. icon="far fa-check-circle"
  54. size="18"
  55. />
  56. <v-icon
  57. v-else-if="item.includedInPremium === false"
  58. icon="far fa-times-circle"
  59. size="18"
  60. color="red"
  61. />
  62. <span v-else>
  63. {{ item.includedInPremium }}
  64. </span>
  65. </td>
  66. </tr>
  67. </tbody>
  68. </table>
  69. <div v-else>
  70. <div class="d-flex flex-row flex-grow-1 justify-center mt-2">
  71. <v-btn
  72. :disabled="carouselPos === 0"
  73. icon="fas fa-chevron-left"
  74. class="mr-6"
  75. @click="goToPrevious"
  76. />
  77. <v-btn
  78. :disabled="carouselPos === 1"
  79. icon="fas fa-chevron-right"
  80. @click="goToNext"
  81. />
  82. </div>
  83. <v-carousel
  84. v-model="carouselPos"
  85. :hide-delimiters="true"
  86. :show-arrows="false"
  87. :height="height"
  88. >
  89. <v-carousel-item>
  90. <h4>Standard</h4>
  91. <div>
  92. <p class="from">À partir de</p>
  93. <p class="price">
  94. {{ standardPrice }} <span class="ttc">ttc</span>
  95. <span class="month">/mois</span>
  96. </p>
  97. </div>
  98. <table>
  99. <tbody>
  100. <tr
  101. v-for="(item, index) in items"
  102. :key="item.label"
  103. >
  104. <td class="label-column">
  105. {{ item.label }}
  106. </td>
  107. <td>
  108. <v-icon
  109. v-if="item.includedInStandard === true"
  110. icon="far fa-check-circle"
  111. size="18"
  112. />
  113. <v-icon
  114. v-else-if="item.includedInStandard === false"
  115. icon="far fa-times-circle"
  116. size="18"
  117. color="red"
  118. />
  119. <span v-else>
  120. {{ item.includedInStandard }}
  121. </span>
  122. </td>
  123. </tr>
  124. </tbody>
  125. </table>
  126. </v-carousel-item>
  127. <v-carousel-item>
  128. <h4>Premium</h4>
  129. <div>
  130. <p class="from">À partir de</p>
  131. <p class="price">
  132. {{ premiumPrice }} <span class="ttc">ttc</span>
  133. <span class="month">/mois</span>
  134. </p>
  135. </div>
  136. <table>
  137. <tbody>
  138. <tr
  139. v-for="(item, index) in items"
  140. :key="item.label"
  141. >
  142. <td class="label-column">
  143. {{ item.label }}
  144. </td>
  145. <td>
  146. <v-icon
  147. v-if="item.includedInPremium === true"
  148. icon="far fa-check-circle"
  149. size="18"
  150. />
  151. <v-icon
  152. v-else-if="item.includedInPremium === false"
  153. icon="far fa-times-circle"
  154. size="18"
  155. color="red"
  156. />
  157. <span v-else>
  158. {{ item.includedInPremium }}
  159. </span>
  160. </td>
  161. </tr>
  162. </tbody>
  163. </table>
  164. </v-carousel-item>
  165. </v-carousel>
  166. </div>
  167. </v-row>
  168. </LayoutContainer>
  169. </template>
  170. <script setup lang="ts">
  171. import type { ComparisonItem } from "~/types/interface";
  172. import { useDisplay } from "vuetify";
  173. const { mdAndUp } = useDisplay()
  174. const props = defineProps({
  175. standardPrice: {
  176. type: String,
  177. required: true
  178. },
  179. premiumPrice: {
  180. type: String,
  181. required: true
  182. },
  183. items: {
  184. type: Array as PropType<Array<ComparisonItem>>,
  185. required: true
  186. }
  187. });
  188. const height = computed(() => 150 + props.items.length * 48)
  189. const carouselPos = ref(0)
  190. const goToPrevious = () => {
  191. carouselPos.value = 0
  192. };
  193. const goToNext = () => {
  194. carouselPos.value = 1
  195. };
  196. </script>
  197. <style scoped lang="scss">
  198. .v-row {
  199. align-items: center;
  200. display: flex;
  201. flex-direction: row;
  202. justify-content: center;
  203. }
  204. table {
  205. width: 70%;
  206. margin-top: 1rem;
  207. margin-right: auto;
  208. margin-left: auto;
  209. border: none;
  210. border-collapse: collapse;
  211. @media (max-width: 940px) {
  212. width: 100%;
  213. }
  214. }
  215. th {
  216. height: 8rem;
  217. font-weight: 400;
  218. font-size: 30px;
  219. line-height: 34px;
  220. @media (max-width: 600px) {
  221. font-size: 18px;
  222. }
  223. }
  224. tr {
  225. height: 3rem;
  226. text-align: center;
  227. }
  228. tbody tr:nth-child(even) {
  229. background-color: var(--secondary-color);
  230. }
  231. td {
  232. padding-right: 5rem;
  233. @media (max-width: 600px) {
  234. padding-right: 0;
  235. }
  236. }
  237. td:first-child {
  238. text-align: left;
  239. padding-left: 20px;
  240. font-weight: 600;
  241. font-size: 12px;
  242. line-height: 16px;
  243. letter-spacing: 0.18em;
  244. text-transform: uppercase;
  245. color: var(--on-neutral-color-alt);
  246. @media (max-width: 600px) {
  247. padding-left: 5px;
  248. }
  249. }
  250. .standard {
  251. font-weight: 600;
  252. font-size: 12px;
  253. line-height: 16px;
  254. text-align: center;
  255. letter-spacing: 0.18em;
  256. text-transform: uppercase;
  257. color: var(--primary-color);
  258. padding-right: 5rem;
  259. margin-bottom: 1rem;
  260. }
  261. .from,
  262. .ttc {
  263. font-weight: 300;
  264. font-size: 12px;
  265. line-height: 14px;
  266. text-align: center;
  267. color: var(--on-neutral-color-alt);
  268. padding-right: 5rem;
  269. }
  270. .ttc {
  271. text-transform: uppercase;
  272. }
  273. .price,
  274. .month {
  275. font-size: 30px;
  276. line-height: 34px;
  277. text-align: center;
  278. color: var(--on-neutral-color-alt);
  279. }
  280. .month {
  281. padding-right: 5rem;
  282. @media (max-width: 600px) {
  283. padding-right: 0;
  284. }
  285. }
  286. .v-carousel {
  287. h4 {
  288. text-align: center;
  289. margin: 24px auto 12px auto;
  290. text-transform: uppercase;
  291. letter-spacing: 0.25em;
  292. }
  293. p {
  294. padding-right: 0;
  295. }
  296. .price {
  297. margin-top: 12px;
  298. }
  299. .ttc {
  300. padding-right: 10px;
  301. }
  302. }
  303. </style>