Bruno Predot

Ajout composant Poster.

Déclacement du composant SearchBar dans le fichier ui-components.
1 <script lang="ts" setup> 1 <script lang="ts" setup>
2 //#region --import--. 2 //#region --import--.
3 -import SearchBar from "~/components/SearchBar.vue";  
4 import { onBeforeUnmount, ref } from "vue"; 3 import { onBeforeUnmount, ref } from "vue";
5 import { useTMDB } from "~/composables/tMDB"; 4 import { useTMDB } from "~/composables/tMDB";
6 import { Movie } from "~/models/movie"; 5 import { Movie } from "~/models/movie";
@@ -155,7 +154,7 @@ onBeforeUnmount(() => { @@ -155,7 +154,7 @@ onBeforeUnmount(() => {
155 <section> 154 <section>
156 <h1 class="text-4xl font-bold mb-8 text-center">Découvrez les films populaires</h1> 155 <h1 class="text-4xl font-bold mb-8 text-center">Découvrez les films populaires</h1>
157 <!-- Barre de recherche --> 156 <!-- Barre de recherche -->
158 - <search-bar 157 + <ui-components-search-bar
159 placeholder="Rechercher un film..." 158 placeholder="Rechercher un film..."
160 @event:search="handleSearchEvent" 159 @event:search="handleSearchEvent"
161 @event:clear_search="handleClearSearchEvent" 160 @event:clear_search="handleClearSearchEvent"
1 <script lang="ts" setup> 1 <script lang="ts" setup>
2 -//#region --Props--. 2 +//#region --Import--.
3 import type { Genre } from "~/interfaces/movie"; 3 import type { Genre } from "~/interfaces/movie";
  4 +//#endregion
4 5
5 -const props = defineProps({ 6 +//#region --Props--.
  7 +defineProps({
6 genres: { 8 genres: {
7 type: Array<Genre>, 9 type: Array<Genre>,
8 required: true, 10 required: true,
  1 +<script setup lang="ts">
  2 +//#region --Props--.
  3 +import { FilmIcon } from "lucide-vue-next";
  4 +
  5 +defineProps({
  6 + src: {
  7 + type: String,
  8 + required: true,
  9 + nullable: false,
  10 + },
  11 + title: {
  12 + type: String,
  13 + required: true,
  14 + nullable: false,
  15 + },
  16 +});
  17 +//#endregion
  18 +</script>
  19 +
  20 +<template>
  21 + <section class="w-full md:w-1/3 lg:w-1/4">
  22 + <div class="rounded-lg overflow-hidden shadow-lg bg-gray-800">
  23 + <img
  24 + v-if="src"
  25 + :alt="title"
  26 + :src="`https://image.tmdb.org/t/p/w500${src}`"
  27 + class="w-full h-auto"
  28 + />
  29 + <div v-else class="aspect-[2/3] bg-gray-700 flex items-center justify-center">
  30 + <FilmIcon :size="64" class="text-gray-500" />
  31 + </div>
  32 + </div>
  33 + </section>
  34 +</template>
  35 +
  36 +<style scoped>
  37 +
  38 +</style>
@@ -147,22 +147,10 @@ onMounted(() => { @@ -147,22 +147,10 @@ onMounted(() => {
147 147
148 <div class="flex flex-col md:flex-row gap-8"> 148 <div class="flex flex-col md:flex-row gap-8">
149 <!-- Poster --> 149 <!-- Poster -->
150 - <div class="w-full md:w-1/3 lg:w-1/4"> 150 + <ui-components-poster v-if="movie.poster_path" :src="movie.poster_path" :title="movie.title" />
151 - <div class="rounded-lg overflow-hidden shadow-lg bg-gray-800">  
152 - <img  
153 - v-if="movie.poster_path"  
154 - :alt="movie.title"  
155 - :src="`https://image.tmdb.org/t/p/w500${movie.poster_path}`"  
156 - class="w-full h-auto"  
157 - />  
158 - <div v-else class="aspect-[2/3] bg-gray-700 flex items-center justify-center">  
159 - <FilmIcon :size="64" class="text-gray-500" />  
160 - </div>  
161 - </div>  
162 - </div>  
163 151
164 <!-- Informations du film --> 152 <!-- Informations du film -->
165 - <div class="w-full md:w-2/3 lg:w-3/4"> 153 + <section class="w-full md:w-2/3 lg:w-3/4">
166 <h1 class="text-3xl md:text-4xl font-bold mb-2">{{ movie.title }}</h1> 154 <h1 class="text-3xl md:text-4xl font-bold mb-2">{{ movie.title }}</h1>
167 <p v-if="movie.release_date" class="text-gray-400 mb-4"> 155 <p v-if="movie.release_date" class="text-gray-400 mb-4">
168 {{ useDateFormat(movie.release_date, "DD-MM-YYYY") }} • {{ formatRuntime(movie.runtime) }} 156 {{ useDateFormat(movie.release_date, "DD-MM-YYYY") }} • {{ formatRuntime(movie.runtime) }}
@@ -196,7 +184,7 @@ onMounted(() => { @@ -196,7 +184,7 @@ onMounted(() => {
196 }} 184 }}
197 </div> 185 </div>
198 </div> 186 </div>
199 - </div> 187 + </section>
200 </div> 188 </div>
201 </div> 189 </div>
202 </div> 190 </div>