Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +120 -79
templates/index.html
CHANGED
@@ -4,8 +4,9 @@
|
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>AI Flashcards Generator</title>
|
|
|
|
|
7 |
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
-
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
9 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.6.2/axios.min.js"></script>
|
10 |
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" rel="stylesheet">
|
11 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
@@ -24,15 +25,6 @@
|
|
24 |
border: 1px solid rgba(255, 255, 255, 0.1);
|
25 |
}
|
26 |
|
27 |
-
.card-hover {
|
28 |
-
transition: all 0.3s ease;
|
29 |
-
}
|
30 |
-
|
31 |
-
.card-hover:hover {
|
32 |
-
transform: translateY(-5px);
|
33 |
-
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
|
34 |
-
}
|
35 |
-
|
36 |
.gradient-text {
|
37 |
background: linear-gradient(45deg, #60a5fa, #a855f7);
|
38 |
-webkit-background-clip: text;
|
@@ -65,6 +57,38 @@
|
|
65 |
border-bottom-color: #60a5fa;
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
@keyframes rotation {
|
69 |
0% { transform: rotate(0deg) }
|
70 |
100% { transform: rotate(360deg) }
|
@@ -89,7 +113,7 @@
|
|
89 |
<!-- Main Content -->
|
90 |
<div class="max-w-4xl mx-auto">
|
91 |
<!-- Input Section -->
|
92 |
-
<div class="glass-morph rounded-2xl p-8 mb-12
|
93 |
<div class="mb-6">
|
94 |
<label for="topic" class="block text-lg font-medium mb-3 text-gray-300">Quel sujet souhaitez-vous explorer ?</label>
|
95 |
<div class="relative">
|
@@ -151,20 +175,34 @@
|
|
151 |
<div
|
152 |
v-for="(card, index) in flashcards"
|
153 |
:key="index"
|
154 |
-
class="
|
|
|
155 |
@click="card.showAnswer = !card.showAnswer"
|
156 |
>
|
157 |
-
<div class="
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
</div>
|
161 |
-
|
162 |
-
|
163 |
-
<
|
164 |
-
<div
|
|
|
|
|
|
|
165 |
<p class="text-gray-300">[[card.answer]]</p>
|
|
|
166 |
</div>
|
167 |
-
</
|
168 |
</div>
|
169 |
</div>
|
170 |
</div>
|
@@ -181,71 +219,74 @@
|
|
181 |
</div>
|
182 |
|
183 |
<script>
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
methods: {
|
198 |
-
async generateFlashcards() {
|
199 |
-
if (!this.topic) {
|
200 |
-
this.error = 'Veuillez entrer un sujet.'
|
201 |
-
return
|
202 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
setTimeout(() => {
|
221 |
-
this.flashcards = cards
|
222 |
-
this.$nextTick(() => {
|
223 |
-
gsap.from('.card-hover', {
|
224 |
-
y: 30,
|
225 |
-
opacity: 0,
|
226 |
-
duration: 0.5,
|
227 |
-
stagger: 0.1
|
228 |
})
|
229 |
-
})
|
230 |
-
}
|
|
|
|
|
|
|
|
|
231 |
}
|
232 |
-
} catch (error) {
|
233 |
-
this.error = error.response?.data?.error || 'Une erreur est survenue lors de la génération.'
|
234 |
-
} finally {
|
235 |
-
this.isLoading = false
|
236 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
}
|
238 |
-
}
|
239 |
-
|
240 |
-
// Animation du titre à l'entrée
|
241 |
-
gsap.from('.gradient-text', {
|
242 |
-
y: -50,
|
243 |
-
opacity: 0,
|
244 |
-
duration: 1,
|
245 |
-
ease: 'power3.out'
|
246 |
-
})
|
247 |
-
}
|
248 |
-
}).mount('#app')
|
249 |
</script>
|
250 |
</body>
|
251 |
</html>
|
|
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>AI Flashcards Generator</title>
|
7 |
+
<!-- Chargement des scripts dans le bon ordre -->
|
8 |
+
<script src="https://unpkg.com/[email protected]/dist/vue.global.js"></script>
|
9 |
<script src="https://cdn.tailwindcss.com"></script>
|
|
|
10 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.6.2/axios.min.js"></script>
|
11 |
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" rel="stylesheet">
|
12 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
|
|
25 |
border: 1px solid rgba(255, 255, 255, 0.1);
|
26 |
}
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
.gradient-text {
|
29 |
background: linear-gradient(45deg, #60a5fa, #a855f7);
|
30 |
-webkit-background-clip: text;
|
|
|
57 |
border-bottom-color: #60a5fa;
|
58 |
}
|
59 |
|
60 |
+
/* Styles pour la rotation des cartes */
|
61 |
+
.flashcard {
|
62 |
+
perspective: 1000px;
|
63 |
+
transform-style: preserve-3d;
|
64 |
+
}
|
65 |
+
|
66 |
+
.flashcard-inner {
|
67 |
+
position: relative;
|
68 |
+
width: 100%;
|
69 |
+
height: 100%;
|
70 |
+
text-align: left;
|
71 |
+
transition: transform 0.8s;
|
72 |
+
transform-style: preserve-3d;
|
73 |
+
}
|
74 |
+
|
75 |
+
.flashcard.flipped .flashcard-inner {
|
76 |
+
transform: rotateY(180deg);
|
77 |
+
}
|
78 |
+
|
79 |
+
.flashcard-front,
|
80 |
+
.flashcard-back {
|
81 |
+
position: absolute;
|
82 |
+
width: 100%;
|
83 |
+
height: 100%;
|
84 |
+
backface-visibility: hidden;
|
85 |
+
-webkit-backface-visibility: hidden;
|
86 |
+
}
|
87 |
+
|
88 |
+
.flashcard-back {
|
89 |
+
transform: rotateY(180deg);
|
90 |
+
}
|
91 |
+
|
92 |
@keyframes rotation {
|
93 |
0% { transform: rotate(0deg) }
|
94 |
100% { transform: rotate(360deg) }
|
|
|
113 |
<!-- Main Content -->
|
114 |
<div class="max-w-4xl mx-auto">
|
115 |
<!-- Input Section -->
|
116 |
+
<div class="glass-morph rounded-2xl p-8 mb-12">
|
117 |
<div class="mb-6">
|
118 |
<label for="topic" class="block text-lg font-medium mb-3 text-gray-300">Quel sujet souhaitez-vous explorer ?</label>
|
119 |
<div class="relative">
|
|
|
175 |
<div
|
176 |
v-for="(card, index) in flashcards"
|
177 |
:key="index"
|
178 |
+
class="flashcard min-h-[200px]"
|
179 |
+
:class="{ 'flipped': card.showAnswer }"
|
180 |
@click="card.showAnswer = !card.showAnswer"
|
181 |
>
|
182 |
+
<div class="flashcard-inner">
|
183 |
+
<!-- Front of card -->
|
184 |
+
<div class="flashcard-front glass-morph rounded-xl p-6">
|
185 |
+
<div class="flex items-start space-x-4">
|
186 |
+
<div class="w-12 h-12 flex items-center justify-center rounded-full bg-blue-500/20 text-blue-400 font-bold">
|
187 |
+
[[index + 1]]
|
188 |
+
</div>
|
189 |
+
<div class="flex-1">
|
190 |
+
<h3 class="text-xl font-medium">[[card.question]]</h3>
|
191 |
+
<p class="text-gray-400 mt-2">(Cliquez pour voir la réponse)</p>
|
192 |
+
</div>
|
193 |
+
</div>
|
194 |
</div>
|
195 |
+
<!-- Back of card -->
|
196 |
+
<div class="flashcard-back glass-morph rounded-xl p-6">
|
197 |
+
<div class="flex items-start space-x-4">
|
198 |
+
<div class="w-12 h-12 flex items-center justify-center rounded-full bg-purple-500/20 text-purple-400 font-bold">
|
199 |
+
[[index + 1]]
|
200 |
+
</div>
|
201 |
+
<div class="flex-1">
|
202 |
<p class="text-gray-300">[[card.answer]]</p>
|
203 |
+
<p class="text-gray-400 mt-2">(Cliquez pour voir la question)</p>
|
204 |
</div>
|
205 |
+
</div>
|
206 |
</div>
|
207 |
</div>
|
208 |
</div>
|
|
|
219 |
</div>
|
220 |
|
221 |
<script>
|
222 |
+
// Attendre que le DOM soit chargé
|
223 |
+
document.addEventListener('DOMContentLoaded', () => {
|
224 |
+
const { createApp } = Vue
|
225 |
+
|
226 |
+
createApp({
|
227 |
+
delimiters: ['[[', ']]'],
|
228 |
+
data() {
|
229 |
+
return {
|
230 |
+
topic: '',
|
231 |
+
flashcards: [],
|
232 |
+
activeTab: 'study',
|
233 |
+
isLoading: false,
|
234 |
+
error: null
|
|
|
|
|
|
|
|
|
|
|
235 |
}
|
236 |
+
},
|
237 |
+
methods: {
|
238 |
+
async generateFlashcards() {
|
239 |
+
if (!this.topic) {
|
240 |
+
this.error = 'Veuillez entrer un sujet.'
|
241 |
+
return
|
242 |
+
}
|
243 |
+
|
244 |
+
this.isLoading = true
|
245 |
+
this.error = null
|
246 |
+
this.flashcards = []
|
247 |
+
|
248 |
+
try {
|
249 |
+
const response = await axios.post('/generate', {
|
250 |
+
topic: this.topic
|
251 |
+
})
|
252 |
|
253 |
+
if (response.data.success) {
|
254 |
+
const cards = response.data.flashcards.map(card => ({
|
255 |
+
...card,
|
256 |
+
showAnswer: false
|
257 |
+
}))
|
258 |
+
|
259 |
+
// Animation des cartes à leur apparition
|
260 |
+
setTimeout(() => {
|
261 |
+
this.flashcards = cards
|
262 |
+
this.$nextTick(() => {
|
263 |
+
gsap.from('.flashcard', {
|
264 |
+
y: 30,
|
265 |
+
opacity: 0,
|
266 |
+
duration: 0.5,
|
267 |
+
stagger: 0.1
|
268 |
+
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
})
|
270 |
+
}, 300)
|
271 |
+
}
|
272 |
+
} catch (error) {
|
273 |
+
this.error = error.response?.data?.error || 'Une erreur est survenue lors de la génération.'
|
274 |
+
} finally {
|
275 |
+
this.isLoading = false
|
276 |
}
|
|
|
|
|
|
|
|
|
277 |
}
|
278 |
+
},
|
279 |
+
mounted() {
|
280 |
+
// Animation du titre à l'entrée
|
281 |
+
gsap.from('.gradient-text', {
|
282 |
+
y: -50,
|
283 |
+
opacity: 0,
|
284 |
+
duration: 1,
|
285 |
+
ease: 'power3.out'
|
286 |
+
})
|
287 |
}
|
288 |
+
}).mount('#app')
|
289 |
+
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
</script>
|
291 |
</body>
|
292 |
</html>
|