-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
88 lines (78 loc) · 4.47 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
<!DOCTYPE html>
<html lang="en">
<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 Board Game Explorer application">
<link rel="icon" type="image/png" href="favicon.png">
<title>Alpine.js · Board Game Explorer</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/@phosphor-icons/web"></script>
<script src="https://cdn.jsdelivr.net/npm/@alpinejs/persist@latest/dist/cdn.min.js"></script>
<script defer src="https://unpkg.com/alpinejs"></script>
<script src="board-game-explorer.js"></script>
<link rel="stylesheet" href="styles.css">
</head>
<body x-data="boardGameExplorer" class="bg-gray-100 antialiased">
<h1 class="text-2xl font-bold mb-4 text-center">Board Game Explorer</h1>
<div class="container mx-auto p-5">
<div class="text-center mb-4">
<label for="search" class="sr-only">Search for a Board Game</label>
<div class="relative w-full max-w-md mx-auto">
<input type="text" id="search" x-model="search" placeholder="Search for a board game..."
@input="searchGames"
class="w-full p-2 border border-gray-300 rounded-md focus:outline-none focus:border-blue-500 transition pr-10"
aria-describedby="search-help">
<button x-cloak x-show="search" @click="clearFilter"
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" title="Clear search"></i>
</button>
</div>
</div>
<div class="container mx-auto mb-4 flex justify-center space-x-4 mb-8">
<div>
<label for="sortRating" class="sr-only">Sort by rating</label>
<select id="sortRating" x-model="sortByRating"
class="p-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-400 transition">
<option value="none">Rating</option>
<option value="desc">Highest to Lowest</option>
<option value="asc">Lowest to Highest</option>
</select>
</div>
<div>
<label for="sortComplexity" class="sr-only">Sort by complexity</label>
<select id="sortComplexity" x-model="sortByComplexity"
class="p-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-400 transition">
<option value="none">Complexity</option>
<option value="desc">Most to Least</option>
<option value="asc">Least to Most</option>
</select>
</div>
</div>
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6">
<template x-for="game in sortedGames" :key="game.id">
<div class="bg-white rounded-lg shadow-lg overflow-hidden transform transition hover:scale-105">
<img :src="game.image" alt="Game cover image" class="w-full h-48 object-cover">
<div class="p-4">
<h2 class="text-xl font-bold text-gray-800 truncate" x-text="game.name"></h2>
<p class="text-sm text-gray-500 mt-1" x-text="'Year: ' + game.year"></p>
<p class="text-sm text-gray-500 mt-1"
x-text="'Players: ' + game.minPlayers + ' - ' + game.maxPlayers"></p>
<p class="text-sm text-gray-500 mt-1"
x-text="'Play time: ' + game.minPlayTime + ' - ' + game.maxPlayTime + ' min'"></p>
<div class="mt-4">
<span
class="inline-block bg-blue-100 text-blue-800 text-xs px-2 py-1 rounded-full font-semibold"
x-text="`Rating: ${game.rating.toFixed(2)}/10`"></span>
<span
class="inline-block bg-green-100 text-green-800 text-xs px-2 py-1 rounded-full font-semibold"
x-text="`Complexity: ${game.complexity.toFixed(2)}/5`"></span>
</div>
</div>
</div>
</template>
</div>
</div>
</body>
</html>