-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
555 lines (530 loc) · 33.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
<!DOCTYPE html>
<html lang="en" x-data="navigation">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="An Alpine.js Movie DB application">
<title>Alpine.js · Movie DB</title>
<link rel="icon" type="image/png" href="favicon.png" />
<link rel="stylesheet" href="src/styles/main.css" />
<script defer type="module" src="src/main.ts"></script>
</head>
<body x-data="movieDB" class="antialiased min-h-screen bg-background-color text-white" x-init="fetchComingSoonMovies">
<header class="sticky z-50 bg-background-color top-0 p-4 lg:px-12 flex items-center shadow-lg">
<div class="flex items-center space-x-8">
<h1 @click="changeTab('home')"
class="flex items-center space-x-2 text-2xl font-bold text-primary-color cursor-pointer active:text-secondary-color transition duration-300">
<i class="ph-film-strip"></i><span>MOVIE DB</span>
</h1>
<nav class="flex items-center space-x-3 text-sm font-normal">
<div x-data="{ toggleDropdown: false }" @mouseover="toggleDropdown = true" @mouseleave="toggleDropdown = false"
class="relative">
<button class="relative flex items-center space-x-2 hover:secondary-color p-3">
<i class="ph-film-slate"></i><span class="hidden md:inline-block">Movies</span>
</button>
<div x-transition.opacity x-cloak x-show="toggleDropdown"
class="absolute top-10 left-0 bg-[#2a2a2a] rounded-lg shadow-lg text-sm w-48 z-30 p-4 space-y-4">
<button @click="toggleDropdown = false; changeTab('popularMovies')"
:class="{ 'text-secondary-color': currentTab === 'popularMovies' }"
class="flex items-center space-x-2 hover:secondary-color">
<i class="ph-fire"></i><span class="md:inline-block">Popular</span>
</button>
<button @click="toggleDropdown = false; changeTab('nowPlaying')"
:class="{ 'text-secondary-color': currentTab === 'nowPlaying' }"
class="flex items-center space-x-2 hover:secondary-color">
<i class="ph-ticket"></i><span class="md:inline-block">Now playing</span>
</button>
<button @click="toggleDropdown = false; changeTab('comingSoon')"
:class="{ 'text-secondary-color': currentTab === 'comingSoon' }"
class="flex items-center space-x-2 hover:secondary-color">
<i class="ph-clock"></i><span class="md:inline-block">Coming Soon</span>
</button>
<button @click="toggleDropdown = false; changeTab('topRatedMovies')"
:class="{ 'text-secondary-color': currentTab === 'topRatedMovies' }"
class="flex items-center space-x-2 hover:secondary-color">
<i class="ph-star"></i><span class="md:inline-block">Top 100</span>
</button>
<!-- <button @click="toggleDropdown = false; changeTab('categoriesMovies')"
:class="{ 'text-secondary-color': currentTab === 'categoriesMovies' }"
class="flex items-center space-x-2 hover:secondary-color">
<i class="ph-squares-four"></i><span class="md:inline-block">Categories</span>
</button> -->
<!-- <button @click="toggleDropdown = false; changeTab('favourites')" :class="{ 'text-secondary-color': currentTab === 'favourites' }"
class="flex items-center space-x-2 hover:secondary-color">
<i class="ph-heart"></i><span class="md:inline-block">Favourites</span>
</button> -->
</div>
</div>
<div x-data="{ toggleDropdown: false }" @mouseover="toggleDropdown = true" @mouseleave="toggleDropdown = false"
class="relative">
<button class="relative flex items-center space-x-2 hover:secondary-color p-3">
<i class="ph-television"></i><span class="hidden md:inline-block">TV Shows</span>
</button>
<div x-transition.opacity x-cloak x-show="toggleDropdown"
class="absolute top-10 left-0 bg-[#2a2a2a] rounded-lg shadow-lg text-sm w-48 z-30 p-4 space-y-4">
<button @click="toggleDropdown = false; changeTab('popularTvShows')"
:class="{ 'text-secondary-color': currentTab === 'popularTvShows' }"
class="flex items-center space-x-2 hover:secondary-color">
<i class="ph-fire"></i><span class="md:inline-block">Popular</span>
</button>
<button @click="toggleDropdown = false; changeTab('airingToday')"
:class="{ 'text-secondary-color': currentTab === 'airingToday' }"
class="flex items-center space-x-2 hover:secondary-color">
<i class="ph-calendar-check"></i><span class="md:inline-block">Airing Today</span>
</button>
<button @click="toggleDropdown = false; changeTab('onTv')"
:class="{ 'text-secondary-color': currentTab === 'onTv' }"
class="flex items-center space-x-2 hover:secondary-color">
<i class="ph-monitor-play"></i><span class="md:inline-block">On TV</span>
</button>
<button @click="toggleDropdown = false; changeTab('topRatedTvShows')"
:class="{ 'text-secondary-color': currentTab === 'topRatedTvShows' }"
class="flex items-center space-x-2 hover:secondary-color">
<i class="ph-star"></i><span class="md:inline-block">Top 100</span>
</button>
<!-- <button @click="toggleDropdown = false; changeTab('categoriesTvShows')"
:class="{ 'text-secondary-color': currentTab === 'categoriesTvShows' }"
class="flex items-center space-x-2 hover:secondary-color">
<i class="ph-squares-four"></i><span class="md:inline-block">Categories</span>
</button> -->
</div>
</div>
<button @click="changeTab('persons')" :class="{ 'text-secondary-color': currentTab === 'persons' }"
class="relative flex items-center space-x-2 hover:secondary-color p-3">
<i class="ph-user"></i><span class="hidden md:inline-block">People</span>
</button>
</nav>
</div>
<div class="flex-1"></div>
<div class="hidden lg:block relative flex-1 max-w-md ml-16">
<input type="text" x-model="search" @input="fetchSearchResults"
placeholder="Search for a movie, tv show, people..."
class="w-full bg-[#2a2a2a] text-sm placeholder-gray-400 text-white px-4 py-2 rounded-md focus:outline-none focus:ring-2 focus:ring-secondary-color" />
<button x-cloak x-show="search" @click="clearSearch" class="absolute inset-y-0 right-0 flex items-center pr-2">
<i class="ph ph-x text-gray-500 cursor-pointer hover:text-gray-700"></i>
</button>
<div
class="absolute z-50 bg-[#2a2a2a] mt-2 rounded-lg shadow-lg overflow-hidden max-h-[500px] w-full overflow-y-auto"
x-show="searchResults.length > 0" @click.away="clearSearch" x-transition>
<ul class="divide-y divide-[#3a3a3a]">
<template x-for="result in searchResults" :key="result.id">
<li @click="selectMovie(result.id, result.media_type)"
class="flex items-center space-x-4 p-3 hover:bg-[#1f1f1f] cursor-pointer">
<img
:src="result.poster_path ? getPosterUrl(result.poster_path) : result.profile_path ? getProfileUrl(result.profile_path) : '/default.png'"
:alt="`${result.title || result.name} poster`" class="w-12 h-16 object-cover rounded">
<div>
<h3 class="text-white font-semibold" x-text="result.title || result.name"></h3>
<div class="flex items-center text-xs text-white mt-2">
<span x-cloak x-show="result.media_type"
class="text-secondary-color bg-black bg-opacity-50 font-bold px-2 py-1 rounded mr-2"
x-text="result.media_type.length === 2 ? result.media_type.toUpperCase() : result.media_type?.charAt(0)?.toUpperCase() + result.media_type?.slice(1)"></span>
<span x-cloak x-show="result.release_date"
x-text="new Date(result.release_date).getFullYear()"></span>
<span x-cloak x-show="result.first_air_date"
x-text="new Date(result.first_air_date).getFullYear()"></span>
<span x-cloak x-show="result.known_for_department"
x-text="result.known_for_department?.charAt(0)?.toUpperCase() + result.known_for_department?.slice(1)"></span>
</div>
</div>
</li>
</template>
</ul>
</div>
</div>
</header>
<div class="absolute overflow-hidden inset-0">
<img x-transition.opacity :src="randomMoviePicture" class="object-cover h-full opacity-30 absolute w-full inset-0">
<div class="absolute inset-0 bg-gradient-to-t from-background-color to-25% to-transparent">
</div>
</div>
<main class="relative p-6 lg:p-12 min-h-screen">
<template x-if="currentTab === 'home'">
<div class="mt-24">
<div class="mb-8 space-y-2 flex flex-col lg:flex-row">
<img
:src="randomMovieDetails?.poster_path ? getPosterUrl(randomMovieDetails?.poster_path) : randomMovieDetails?.profile_path ? getProfileUrl(randomMovieDetails?.profile_path) : '/default.png'"
:alt="`${randomMovieDetails?.title || randomMovieDetails?.name} poster`"
class="w-32 h-48 object-cover rounded-sm mr-8 mb-8">
<div class="w-full lg:w-[50%]">
<h2 class="text-3xl lg:text-5xl font-bold text-white flex items-center" x-text="randomMovieDetails?.title">
</h2>
<div class="flex items-center text-lg lg:text-xl text-white mt-2">
<span class="text-secondary-color bg-black bg-opacity-50 font-bold px-2 py-1 rounded mr-2" x-cloak
x-show="randomMovieDetails?.vote_average !== 0"
x-text="randomMovieDetails?.vote_average?.toFixed(1)"></span>
<span x-text="formatDate(randomMovieDetails?.release_date)"></span>
</div>
<div class="mt-8 leading-7 italic">
<p x-text="randomMovieDetails?.overview"></p>
</div>
<div class="mt-8">
<button @click="changeTab('comingSoon')"
class="flex items-center text-white text-sm hover:text-secondary-color p-2 space-x-1">
<span>See all upcoming movies</span><i class="ph-caret-right text-sm"></i>
</button>
</div>
</div>
</div>
</div>
</template>
<template x-if="currentTab === 'popularMovies'" @scroll.window="popularMoviesCheckScroll">
<div x-init="fetchPopularMovies">
<div class="mb-8 space-y-2">
<h2 class="text-2xl lg:text-3xl font-bold text-white flex items-center"><i class="ph-fire mr-3"></i>Popular
movies
</h2>
<p class="text-gray-400">Discover the most popular movies</p>
</div>
<ul class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 mb-12" x-ref="popularMoviesList">
<template x-for="(movie, index) in popularMovies" :key="`${movie.id}-${index}`">
<li x-data="{ isVisible: false }"
class="relative group cursor-pointer overflow-hidden rounded-sm transform transition-transform duration-300 hover:scale-105 hover:shadow-2xl hover:shadow-black/70">
<img x-cloak x-show="isVisible" x-transition:enter="transition ease-out duration-500"
x-transition:enter-start="opacity-0 transform scale-75"
x-transition:enter-end="opacity-100 transform scale-100"
x-init="setTimeout(() => isVisible = true, index * 50)"
:src="movie.poster_path ? getPosterUrl(movie.poster_path) : '/default.png'"
:alt="`${movie.title} poster`" class="object-cover w-full h-full" />
<div
class="absolute inset-0 bg-black bg-opacity-60 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4">
<h3 class="text-sm font-semibold text-white" x-text="movie.title"></h3>
<div class="flex items-center text-xs text-white mt-2">
<span class="text-secondary-color bg-black bg-opacity-50 font-bold px-2 py-1 rounded mr-2" x-cloak
x-show="movie.vote_average !== 0" x-text="movie.vote_average.toFixed(1)"></span>
<span x-text="new Date(movie.release_date).getFullYear()"></span>
</div>
<!-- <button
class="flex absolute top-2 right-2 text-secondary-color bg-black bg-opacity-50 hover:bg-secondary-color hover:text-black p-2 rounded-full">
<i class="ph-heart text-xl"></i>
</button> -->
</div>
</li>
</template>
</ul>
</div>
</template>
<template x-if="currentTab === 'nowPlaying'">
<div x-init="fetchNowPlayingMovies">
<div class="mb-8 space-y-2">
<h2 class="text-2xl lg:text-3xl font-bold text-white flex items-center"><i class="ph-film-slate mr-3"></i>Now
playing</h2>
<p class="text-gray-400">Discover currently showing movies at the cinema</p>
</div>
<ul class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 mb-12">
<template x-for="(movie, index) in nowPlayingMovies" :key="`${movie.id}-${index}`">
<li x-data="{ isVisible: false }"
class="relative group cursor-pointer overflow-hidden rounded-sm transform transition-transform duration-300 hover:scale-105 hover:shadow-2xl hover:shadow-black/70">
<img x-cloak x-show="isVisible" x-transition:enter="transition ease-out duration-500"
x-transition:enter-start="opacity-0 transform scale-75"
x-transition:enter-end="opacity-100 transform scale-100"
x-init="setTimeout(() => isVisible = true, index * 50)"
:src="movie.poster_path ? getPosterUrl(movie.poster_path) : '/default.png'"
:alt="`${movie.title} poster`" class="object-cover w-full h-full" />
<div
class="absolute inset-0 bg-black bg-opacity-60 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4">
<h3 class="text-sm font-semibold text-white" x-text="movie.title"></h3>
<div class="flex items-center text-xs text-white mt-2">
<span class="text-secondary-color bg-black bg-opacity-50 font-bold px-2 py-1 rounded mr-2" x-cloak
x-show="movie.vote_average !== 0" x-text="movie.vote_average.toFixed(1)"></span>
<span x-text="new Date(movie.release_date).getFullYear()"></span>
</div>
<!-- <button
class="flex absolute top-2 right-2 text-secondary-color bg-black bg-opacity-50 hover:bg-secondary-color hover:text-black p-2 rounded-full">
<i class="ph-heart text-xl"></i>
</button> -->
</div>
</li>
</template>
</ul>
</div>
</template>
<template x-if="currentTab === 'comingSoon'">
<div>
<div class="mb-8 space-y-2">
<h2 class="text-2xl lg:text-3xl font-bold text-white flex items-center"><i class="ph-clock mr-3"></i>Coming
soon
</h2>
<p class="text-gray-400">Discover upcoming movies at the cinema</p>
</div>
<ul class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 mb-12">
<template x-for="(movie, index) in comingSoonMovies" :key="`${movie.id}-${index}`">
<li x-data="{ isVisible: false }"
class="relative group cursor-pointer overflow-hidden rounded-sm transform transition-transform duration-300 hover:scale-105 hover:shadow-2xl hover:shadow-black/70">
<img x-cloak x-show="isVisible" x-transition:enter="transition ease-out duration-500"
x-transition:enter-start="opacity-0 transform scale-75"
x-transition:enter-end="opacity-100 transform scale-100"
x-init="setTimeout(() => isVisible = true, index * 50)"
:src="movie.poster_path ? getPosterUrl(movie.poster_path) : '/default.png'"
:alt="`${movie.title} poster`" class="object-cover w-full h-full" />
<div
class="absolute inset-0 bg-black bg-opacity-60 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4">
<h3 class="text-sm font-semibold text-white" x-text="movie.title"></h3>
<div class="flex items-center text-xs text-white mt-2">
<span x-cloak x-show="movie.vote_average !== 0"
class="text-secondary-color bg-black bg-opacity-50 font-bold px-2 py-1 rounded mr-2"
x-text="movie.vote_average.toFixed(1)"></span>
<span x-text="new Date(movie.release_date).getFullYear()"></span>
</div>
<!-- <button
class="flex absolute top-2 right-2 text-secondary-color bg-black bg-opacity-50 hover:bg-secondary-color hover:text-black p-2 rounded-full">
<i class="ph-heart text-xl"></i>
</button> -->
</div>
</li>
</template>
</ul>
</div>
</template>
<template x-if="currentTab === 'topRatedMovies'" @scroll.window="topRatedMoviesCheckScroll">
<div x-init="fetchTopRatedMovies">
<div class="mb-8 space-y-2">
<h2 class="text-2xl lg:text-3xl font-bold text-white flex items-center"><i class="ph-star mr-3"></i>Top 100
movies</h2>
<p class="text-gray-400">Discover the top 100 most popular movies of all time</p>
</div>
<ul class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 mb-12"
x-ref="topRatedMoviesList">
<template x-for="(movie, index) in topRatedMovies" :key="`${movie.id}-${index}`">
<li x-data="{ isVisible: false }"
class="relative group cursor-pointer overflow-hidden rounded-sm transform transition-transform duration-300 hover:scale-105 hover:shadow-2xl hover:shadow-black/70">
<img x-cloak x-show="isVisible" x-transition:enter="transition ease-out duration-500"
x-transition:enter-start="opacity-0 transform scale-75"
x-transition:enter-end="opacity-100 transform scale-100"
x-init="setTimeout(() => isVisible = true, index * 50)"
:src="movie.poster_path ? getPosterUrl(movie.poster_path) : '/default.png'"
:alt="`${movie.title} poster`" class="object-cover w-full h-full" />
<div
class="absolute inset-0 bg-black bg-opacity-60 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4">
<h3 class="text-sm font-semibold text-white" x-text="movie.title"></h3>
<div class="flex items-center text-xs text-white mt-2">
<span class="text-secondary-color bg-black bg-opacity-50 font-bold px-2 py-1 rounded mr-2" x-cloak
x-show="movie.vote_average !== 0" x-text="movie.vote_average.toFixed(1)"></span>
<span x-text="new Date(movie.release_date).getFullYear()"></span>
</div>
<!-- <button
class="flex absolute top-2 right-2 text-secondary-color bg-black bg-opacity-50 hover:bg-secondary-color hover:text-black p-2 rounded-full">
<i class="ph-heart text-xl"></i>
</button> -->
</div>
</li>
</template>
</ul>
</div>
</template>
<!--<template x-if="currentTab === 'categoriesMovies'">
<div>
<div class="mb-8 space-y-2">
<h2 class="text-2xl lg:text-3xl font-bold text-white flex items-center"><i class="ph-squares-four mr-3"></i>Categories
</h2>
<p class="text-gray-400">Browse all the different movie categories</p>
</div>
</div>
</template>-->
<template x-if="currentTab === 'popularTvShows'" @scroll.window="popularTvShowsCheckScroll">
<div x-init="fetchPopularTvShows">
<div class="mb-8 space-y-2">
<h2 class="text-2xl lg:text-3xl font-bold text-white flex items-center"><i class="ph-fire mr-3"></i>Popular TV
shows
</h2>
<p class="text-gray-400">Discover the most popular TV shows</p>
</div>
<ul class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 mb-12"
x-ref="popularTvShowsList">
<template x-for="(tvShow, index) in popularTvShows" :key="`${tvShow.id}-${index}`">
<li x-data="{ isVisible: false }"
class="relative group cursor-pointer overflow-hidden rounded-sm transform transition-transform duration-300 hover:scale-105 hover:shadow-2xl hover:shadow-black/70">
<img x-cloak x-show="isVisible" x-transition:enter="transition ease-out duration-500"
x-transition:enter-start="opacity-0 transform scale-75"
x-transition:enter-end="opacity-100 transform scale-100"
x-init="setTimeout(() => isVisible = true, index * 50)"
:src="tvShow.poster_path ? getPosterUrl(tvShow.poster_path) : '/default.png'"
:alt="`${tvShow.name} poster`" class="object-cover w-full h-full" />
<div
class="absolute inset-0 bg-black bg-opacity-60 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4">
<h3 class="text-sm font-semibold text-white" x-text="tvShow.name"></h3>
<div class="flex items-center text-xs text-white mt-2">
<span class="text-secondary-color bg-black bg-opacity-50 font-bold px-2 py-1 rounded mr-2" x-cloak
x-show="tvShow.vote_average !== 0" x-text="tvShow.vote_average.toFixed(1)"></span>
<span x-text="new Date(tvShow.first_air_date).getFullYear()"></span>
</div>
<!-- <button
class="flex absolute top-2 right-2 text-secondary-color bg-black bg-opacity-50 hover:bg-secondary-color hover:text-black p-2 rounded-full">
<i class="ph-heart text-xl"></i>
</button> -->
</div>
</li>
</template>
</ul>
</div>
</template>
<template x-if="currentTab === 'airingToday'">
<div x-init="fetchAiringTodayTvShows">
<div class="mb-8 space-y-2">
<h2 class="text-2xl lg:text-3xl font-bold text-white flex items-center"><i
class="ph-calendar-check mr-3"></i>Airing today
</h2>
<p class="text-gray-400">Browse all the TV shows airing today</p>
</div>
<ul class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 mb-12">
<template x-for="(tvShow, index) in airingTodayTvShows" :key="`${tvShow.id}-${index}`">
<li x-data="{ isVisible: false }"
class="relative group cursor-pointer overflow-hidden rounded-sm transform transition-transform duration-300 hover:scale-105 hover:shadow-2xl hover:shadow-black/70">
<img x-cloak x-show="isVisible" x-transition:enter="transition ease-out duration-500"
x-transition:enter-start="opacity-0 transform scale-75"
x-transition:enter-end="opacity-100 transform scale-100"
x-init="setTimeout(() => isVisible = true, index * 50)"
:src="tvShow.poster_path ? getPosterUrl(tvShow.poster_path) : '/default.png'"
:alt="`${tvShow.name} poster`" class="object-cover w-full h-full" />
<div
class="absolute inset-0 bg-black bg-opacity-60 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4">
<h3 class="text-sm font-semibold text-white" x-text="tvShow.name"></h3>
<div class="flex items-center text-xs text-white mt-2">
<span class="text-secondary-color bg-black bg-opacity-50 font-bold px-2 py-1 rounded mr-2" x-cloak
x-show="tvShow.vote_average !== 0" x-text="tvShow.vote_average.toFixed(1)"></span>
<span x-text="new Date(tvShow.first_air_date).getFullYear()"></span>
</div>
<!-- <button
class="flex absolute top-2 right-2 text-secondary-color bg-black bg-opacity-50 hover:bg-secondary-color hover:text-black p-2 rounded-full">
<i class="ph-heart text-xl"></i>
</button> -->
</div>
</li>
</template>
</ul>
</div>
</template>
<template x-if="currentTab === 'onTv'">
<div x-init="fetchOnTheAirTvShows">
<div class="mb-8 space-y-2">
<h2 class="text-2xl lg:text-3xl font-bold text-white flex items-center"><i class="ph-monitor-play mr-3"></i>On
TV</h2>
<p class="text-gray-400">Browse all TV shows currently on air</p>
</div>
<ul class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 mb-12">
<template x-for="(tvShow, index) in onTheAirTvShows" :key="`${tvShow.id}-${index}`">
<li x-data="{ isVisible: false }"
class="relative group cursor-pointer overflow-hidden rounded-sm transform transition-transform duration-300 hover:scale-105 hover:shadow-2xl hover:shadow-black/70">
<img x-cloak x-show="isVisible" x-transition:enter="transition ease-out duration-500"
x-transition:enter-start="opacity-0 transform scale-75"
x-transition:enter-end="opacity-100 transform scale-100"
x-init="setTimeout(() => isVisible = true, index * 50)"
:src="tvShow.poster_path ? getPosterUrl(tvShow.poster_path) : '/default.png'"
:alt="`${tvShow.name} poster`" class="object-cover w-full h-full" />
<div
class="absolute inset-0 bg-black bg-opacity-60 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4">
<h3 class="text-sm font-semibold text-white" x-text="tvShow.name"></h3>
<div class="flex items-center text-xs text-white mt-2">
<span class="text-secondary-color bg-black bg-opacity-50 font-bold px-2 py-1 rounded mr-2" x-cloak
x-show="tvShow.vote_average !== 0" x-text="tvShow.vote_average.toFixed(1)"></span>
<span x-text="new Date(tvShow.first_air_date).getFullYear()"></span>
</div>
<!-- <button
class="flex absolute top-2 right-2 text-secondary-color bg-black bg-opacity-50 hover:bg-secondary-color hover:text-black p-2 rounded-full">
<i class="ph-heart text-xl"></i>
</button> -->
</div>
</li>
</template>
</ul>
</div>
</template>
<template x-if="currentTab === 'topRatedTvShows'" @scroll.window="topRatedTvShowsCheckScroll">
<div x-init="fetchTopRatedTvShows">
<div class="mb-8 space-y-2">
<h2 class="text-2xl lg:text-3xl font-bold text-white flex items-center"><i class="ph-star mr-3"></i>Top 100 TV
shows</h2>
<p class="text-gray-400">Discover the top 100 most popular TV shows of all time</p>
</div>
<ul class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 mb-12"
x-ref="topRatedTvShowsList">
<template x-for="(tvShow, index) in topRatedTvShows" :key="`${tvShow.id}-${index}`">
<li x-data="{ isVisible: false }"
class="relative group cursor-pointer overflow-hidden rounded-sm transform transition-transform duration-300 hover:scale-105 hover:shadow-2xl hover:shadow-black/70">
<img x-cloak x-show="isVisible" x-transition:enter="transition ease-out duration-500"
x-transition:enter-start="opacity-0 transform scale-75"
x-transition:enter-end="opacity-100 transform scale-100"
x-init="setTimeout(() => isVisible = true, index * 50)"
:src="tvShow.poster_path ? getPosterUrl(tvShow.poster_path) : '/default.png'"
:alt="`${tvShow.name} poster`" class="object-cover w-full h-full" />
<div
class="absolute inset-0 bg-black bg-opacity-60 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4">
<h3 class="text-sm font-semibold text-white" x-text="tvShow.name"></h3>
<div class="flex items-center text-xs text-white mt-2">
<span class="text-secondary-color bg-black bg-opacity-50 font-bold px-2 py-1 rounded mr-2" x-cloak
x-show="tvShow.vote_average !== 0" x-text="tvShow.vote_average.toFixed(1)"></span>
<span x-text="new Date(tvShow.first_air_date).getFullYear()"></span>
</div>
<!-- <button
class="flex absolute top-2 right-2 text-secondary-color bg-black bg-opacity-50 hover:bg-secondary-color hover:text-black p-2 rounded-full">
<i class="ph-heart text-xl"></i>
</button> -->
</div>
</li>
</template>
</ul>
</div>
</template>
<!--<template x-if="currentTab === 'categoriesTvShows'">
<div>
<div class="mb-8 space-y-2">
<h2 class="text-2xl lg:text-3xl font-bold text-white flex items-center"><i class="ph-squares-four mr-3"></i>Categories
</h2>
<p class="text-gray-400">Browse all the different Tv shows categories</p>
</div>
</div>
</template>-->
<template x-if="currentTab === 'persons'" @scroll.window="popularPersonsCheckScroll">
<div x-init="fetchPopularPersons">
<div class="mb-8 space-y-2">
<h2 class="text-2xl lg:text-3xl font-bold text-white flex items-center"><i class="ph-user mr-3"></i>Popular
People</h2>
<p class="text-gray-400">Browse all popular personalities</p>
</div>
<ul class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 mb-12"
x-ref="popularPersonsList">
<template x-for="(person, index) in popularPersons" :key="`${person.id}-${index}`">
<li x-data="{ isVisible: false }"
class="relative group cursor-pointer overflow-hidden rounded-sm transform transition-transform duration-300 hover:scale-105 hover:shadow-2xl hover:shadow-black/70">
<img x-cloak x-show="isVisible" x-transition:enter="transition ease-out duration-500"
x-transition:enter-start="opacity-0 transform scale-75"
x-transition:enter-end="opacity-100 transform scale-100"
x-init="setTimeout(() => isVisible = true, index * 50)"
:src="person.profile_path ? getPosterUrl(person.profile_path) : '/default.png'"
:alt="`${person.name} poster`" class="object-cover w-full h-full" />
<div
class="absolute inset-0 bg-black bg-opacity-60 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4">
<h3 class="text-sm font-semibold text-white" x-text="person.name"></h3>
<div class="flex items-center text-xs text-white mt-2">
<span class="text-secondary-color bg-black bg-opacity-50 font-bold px-2 py-1 rounded mr-2" x-cloak
x-show="person.popularity !== 0" x-text="person.popularity.toFixed(0)"></span>
<span x-cloak x-show="person.known_for_department"
x-text="person.known_for_department.charAt(0).toUpperCase() + person.known_for_department.slice(1)"></span>
</div>
<!-- <button
class="flex absolute top-2 right-2 text-secondary-color bg-black bg-opacity-50 hover:bg-secondary-color hover:text-black p-2 rounded-full">
<i class="ph-heart text-xl"></i>
</button> -->
</div>
</li>
</template>
</ul>
</div>
</template>
<div x-data="{ showButton: false }"
x-init="window.addEventListener('scroll', () => { showButton = window.scrollY > 200 })">
<button x-cloak x-show="showButton" @click="scrollToTop" x-transition:enter="transition transform duration-300"
x-transition:enter-start="opacity-0 scale-75" x-transition:enter-end="opacity-100 scale-100"
x-transition:leave="transition transform duration-300" x-transition:leave-start="opacity-100 scale-100"
x-transition:leave-end="opacity-0 scale-75"
class="fixed flex bottom-6 left-1/2 transform -translate-x-1/2 bg-black bg-opacity-50 hover:bg-secondary-color hover:text-black text-secondary-color p-4 rounded-full shadow-lg focus:outline-none">
<i class="ph-caret-up text-xl"></i>
</button>
</div>
</main>
<p data-cy="feedback-message" x-cloak x-show="$store.feedback.message" x-text="$store.feedback.message"
:class="$store.feedback.type" class="mt-2 text-sm feedback" aria-live="polite">
</p>
</body>
</html>