Bruno Predot

Chargement des premiers film au mounted du composant.

Formattage.
1 -<script setup lang="ts"> 1 +<script lang="ts" setup></script>
2 -  
3 -</script>  
4 2
5 <template> 3 <template>
6 <v-locale-provider> 4 <v-locale-provider>
@@ -12,6 +10,4 @@ @@ -12,6 +10,4 @@
12 </v-locale-provider> 10 </v-locale-provider>
13 </template> 11 </template>
14 12
15 -<style scoped> 13 +<style scoped></style>
16 -  
17 -</style>  
1 -<script setup lang="ts"> 1 +<script lang="ts" setup>
2 //#region --import--. 2 //#region --import--.
3 import SearchBar from "~/components/SearchBar.vue"; 3 import SearchBar from "~/components/SearchBar.vue";
4 import { ref } from "vue"; 4 import { ref } from "vue";
@@ -54,7 +54,13 @@ const fetchMovies = async (page: number) => { @@ -54,7 +54,13 @@ const fetchMovies = async (page: number) => {
54 isLoadingMore.value = false; 54 isLoadingMore.value = false;
55 } 55 }
56 }; 56 };
57 -fetchMovies(1) 57 +//#endregion
  58 +
  59 +//#region --Global event--.
  60 +onMounted(() => {
  61 + // Chargement des premiers films.
  62 + fetchMovies(1);
  63 +});
58 //#endregion 64 //#endregion
59 </script> 65 </script>
60 66
@@ -62,14 +68,12 @@ fetchMovies(1) @@ -62,14 +68,12 @@ fetchMovies(1)
62 <section> 68 <section>
63 <h1 class="text-4xl font-bold mb-8 text-center">Découvrez les films populaires</h1> 69 <h1 class="text-4xl font-bold mb-8 text-center">Découvrez les films populaires</h1>
64 <!-- Barre de recherche --> 70 <!-- Barre de recherche -->
65 - <search-bar placeholder="Rechercher un film..."/> 71 + <search-bar placeholder="Rechercher un film..." />
66 <!-- Loading Skeleton --> 72 <!-- Loading Skeleton -->
67 <skeleton-movies-loader :is-initial-loading="isInitialLoading" :skeleton-number="20" /> 73 <skeleton-movies-loader :is-initial-loading="isInitialLoading" :skeleton-number="20" />
68 <!-- Liste des films --> 74 <!-- Liste des films -->
69 -<!-- <pre>{{ movies }}</pre>--> 75 + <!-- <pre>{{ movies }}</pre>-->
70 </section> 76 </section>
71 </template> 77 </template>
72 78
73 -<style scoped> 79 +<style scoped></style>
74 -  
75 -</style>  
1 -<script setup lang="ts"> 1 +<script lang="ts" setup>
2 //#region --import--. 2 //#region --import--.
3 import { SearchIcon, XIcon } from "lucide-vue-next"; 3 import { SearchIcon, XIcon } from "lucide-vue-next";
4 import { ref } from "vue"; 4 import { ref } from "vue";
@@ -14,8 +14,8 @@ defineProps({ @@ -14,8 +14,8 @@ defineProps({
14 type: String, 14 type: String,
15 required: false, 15 required: false,
16 nullable: false, 16 nullable: false,
17 - default: '' 17 + default: "",
18 - } 18 + },
19 }); 19 });
20 //#endregion 20 //#endregion
21 21
@@ -30,11 +30,11 @@ const searchQuery = ref(""); @@ -30,11 +30,11 @@ const searchQuery = ref("");
30 <div class="relative max-w-xl mx-auto"> 30 <div class="relative max-w-xl mx-auto">
31 <input 31 <input
32 v-model="searchQuery" 32 v-model="searchQuery"
33 - type="text"  
34 :placeholder="placeholder" 33 :placeholder="placeholder"
35 class="w-full px-4 py-3 bg-gray-800 rounded-full text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-primary" 34 class="w-full px-4 py-3 bg-gray-800 rounded-full text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-primary"
  35 + type="text"
36 @input="console.log('debouncedSearch à prévoir')" 36 @input="console.log('debouncedSearch à prévoir')"
37 - > 37 + />
38 <button 38 <button
39 v-if="searchQuery" 39 v-if="searchQuery"
40 class="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-white" 40 class="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-white"
@@ -49,6 +49,4 @@ const searchQuery = ref(""); @@ -49,6 +49,4 @@ const searchQuery = ref("");
49 </section> 49 </section>
50 </template> 50 </template>
51 51
52 -<style scoped> 52 +<style scoped></style>
53 -  
54 -</style>  
1 -<script setup lang="ts"> 1 +<script lang="ts" setup>
2 //#region --Props--. 2 //#region --Props--.
3 defineProps({ 3 defineProps({
4 isInitialLoading: { 4 isInitialLoading: {
@@ -10,26 +10,23 @@ defineProps({ @@ -10,26 +10,23 @@ defineProps({
10 type: Number, 10 type: Number,
11 required: false, 11 required: false,
12 nullable: false, 12 nullable: false,
13 - default: 12 13 + default: 12,
14 - } 14 + },
15 }); 15 });
16 //#endregion 16 //#endregion
17 -  
18 </script> 17 </script>
19 18
20 <template> 19 <template>
21 <!-- Skeleton loader pendant le chargement initial --> 20 <!-- Skeleton loader pendant le chargement initial -->
22 <section v-if="isInitialLoading" class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6"> 21 <section v-if="isInitialLoading" class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6">
23 <div v-for="i in skeletonNumber" :key="i" class="bg-gray-800 rounded-lg overflow-hidden shadow-lg animate-pulse"> 22 <div v-for="i in skeletonNumber" :key="i" class="bg-gray-800 rounded-lg overflow-hidden shadow-lg animate-pulse">
24 - <div class="h-80 bg-gray-700"/> 23 + <div class="h-80 bg-gray-700" />
25 <div class="p-4"> 24 <div class="p-4">
26 - <div class="h-6 bg-gray-700 rounded mb-3"/> 25 + <div class="h-6 bg-gray-700 rounded mb-3" />
27 - <div class="h-4 bg-gray-700 rounded w-2/3"/> 26 + <div class="h-4 bg-gray-700 rounded w-2/3" />
28 </div> 27 </div>
29 </div> 28 </div>
30 </section> 29 </section>
31 </template> 30 </template>
32 31
33 -<style scoped> 32 +<style scoped></style>
34 -  
35 -</style>  
1 -<script setup lang="ts"> 1 +<script lang="ts" setup></script>
2 -  
3 -</script>  
4 2
5 <template> 3 <template>
6 <v-container class="mx-auto px-4 py-8"> 4 <v-container class="mx-auto px-4 py-8">
7 - <movies-list/> 5 + <movies-list />
8 </v-container> 6 </v-container>
9 </template> 7 </template>
10 8
11 -<style scoped> 9 +<style scoped></style>
12 -  
13 -</style>