Comparatif.vue 7.3 KB

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