Comparatif.vue 7.4 KB

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