Skip to content

Commit 081d9f5

Browse files
committed
update
1 parent c7c16a6 commit 081d9f5

File tree

3 files changed

+135
-6
lines changed

3 files changed

+135
-6
lines changed

apps/languagesv2/languages-v2-web/src/App.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import React from 'react';
22
import './App.css';
33
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
44
import Home from './pages/Home';
5-
import Quiz from './pages/Quiz';
65
import Nav from './pages/Nav';
6+
import Quiz from './pages/Quiz';
7+
import Video from './pages/Video';
8+
79

810
function App() {
911
return (
@@ -14,6 +16,7 @@ function App() {
1416
<Routes>
1517
<Route path="/" element={<Home />} />
1618
<Route path="/quiz" element={<Quiz />} />
19+
<Route path="/video/:language" element={<Video />} />
1720
</Routes>
1821
</div>
1922
</div>

apps/languagesv2/languages-v2-web/src/pages/Home.tsx

+20-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Link } from 'react-router-dom';
33

44
function Home() {
55
return (
6-
<div className="w-full p-6 space-y-8">
6+
<div className="w-full pt-24 space-y-4">
77
{/* Header Section */}
88
<header className="text-left">
99
<h1 className="text-5xl font-bold mb-2 text-blue-700">Languages</h1>
@@ -14,43 +14,58 @@ function Home() {
1414
<section className="bg-white shadow-md rounded-lg p-6 transition-transform transform hover:scale-105 hover:bg-blue-50">
1515
<h2 className="text-3xl font-semibold mb-4 text-blue-700">English 🇬🇧</h2>
1616
<p className="text-md text-gray-700 mb-6">Master English with our engaging quizzes and exercises. Unlock the full potential of your language skills and take your communication to the next level!</p>
17-
<div className="mb-8">
17+
<div className="mb-8 space-x-4">
1818
<Link
1919
to="/quiz?language=English"
2020
className="inline-block bg-blue-600 text-white px-6 py-3 rounded-full font-semibold text-center hover:bg-blue-800 shadow-lg">
2121
🚀 Start Your English Adventure Now!
2222
</Link>
23+
<Link
24+
to="/video/English"
25+
className="inline-block bg-blue-400 text-white px-6 py-3 rounded-full font-semibold text-center hover:bg-blue-600 shadow-lg">
26+
🎥 Watch English Videos
27+
</Link>
2328
</div>
2429
</section>
2530

2631
{/* Vietnamese Section */}
2732
<section className="bg-white shadow-md rounded-lg p-6 transition-transform transform hover:scale-105 hover:bg-green-50">
2833
<h2 className="text-3xl font-semibold mb-4 text-green-700">Vietnamese 🇻🇳</h2>
2934
<p className="text-md text-gray-700 mb-6">Discover the beauty of the Vietnamese language through fun and immersive quizzes. Let’s explore the culture and language together!</p>
30-
<div className="mb-8">
35+
<div className="mb-8 space-x-4">
3136
<Link
3237
to="/quiz?language=Vietnamese"
3338
className="inline-block bg-green-600 text-white px-6 py-3 rounded-full font-semibold text-center hover:bg-green-800 shadow-lg">
3439
🌟 Start Vietnamese Quiz and Uncover the Magic!
3540
</Link>
41+
<Link
42+
to="/video/Vietnamese"
43+
className="inline-block bg-green-400 text-white px-6 py-3 rounded-full font-semibold text-center hover:bg-green-600 shadow-lg">
44+
🎥 Watch Vietnamese Videos
45+
</Link>
3646
</div>
3747
</section>
3848

3949
{/* Chinese Section */}
4050
<section className="bg-white shadow-md rounded-lg p-6 transition-transform transform hover:scale-105 hover:bg-red-50">
4151
<h2 className="text-3xl font-semibold mb-4 text-red-700">Chinese 🇨🇳</h2>
4252
<p className="text-md text-gray-700 mb-6">Begin your Mandarin Chinese journey with fun, engaging quizzes. Unlock the wonders of the Chinese language and culture!</p>
43-
<div className="mb-8">
53+
<div className="mb-8 space-x-4">
4454
<Link
4555
to="/quiz?language=Chinese"
4656
className="inline-block bg-red-600 text-white px-6 py-3 rounded-full font-semibold text-center hover:bg-red-800 shadow-lg">
4757
🐉 Start Chinese Quiz and Begin Your Journey!
4858
</Link>
59+
<Link
60+
to="/video/Chinese"
61+
className="inline-block bg-red-400 text-white px-6 py-3 rounded-full font-semibold text-center hover:bg-red-600 shadow-lg">
62+
🎥 Watch Chinese Videos
63+
</Link>
4964
</div>
5065
</section>
5166

5267
{/* Footer Section */}
53-
<footer className="text-center text-gray-600 mt-12">
68+
<footer className="text-center text-gray-600 mt-16">
5469
<p className="text-lg">Happy learning! Stay consistent, stay curious. 🚀 Let every quiz be a new adventure!</p>
5570
</footer>
5671
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import React, { useState, useRef } from 'react';
2+
import { useParams } from 'react-router-dom';
3+
4+
type VideoData = {
5+
[key: string]: { title: string; url: string }[];
6+
};
7+
8+
function Video() {
9+
const { language } = useParams<{ language: string }>();
10+
const [currentIndex, setCurrentIndex] = useState(0);
11+
const videoRef = useRef<HTMLIFrameElement>(null);
12+
13+
const videoData: VideoData = {
14+
English: [
15+
{
16+
title: 'Gotye - Somebody That I Used To Know (feat. Kimbra)',
17+
url: 'https://www.youtube.com/embed/8UVNT4wvIGY?si=0ZDLyY8p4nvbSpaB&controls=0',
18+
},
19+
{
20+
title: 'MPOSSIBLE! [or NOT?] – Learn English Conversation in 4 Hours',
21+
url: 'https://www.youtube.com/embed/8FzY7cgKOmI?si=uADlutuyhPhXBkSc&controls=0',
22+
},
23+
],
24+
Vietnamese: [
25+
{
26+
title: 'Vietnamese Phrases You Need at the Station',
27+
url: 'https://www.youtube.com/embed/0E50Kk0DNJk?si=U3dGZ77CUHb9VPoJ&controls=0',
28+
},
29+
{
30+
title: 'Learn Vietnamese in 2 Hours - Beginners Guide',
31+
url: 'https://www.youtube.com/embed/UvmzrMWD8_Y?si=e-DJH7gp00bS0yjZ&controls=0',
32+
},
33+
],
34+
Chinese: [
35+
{
36+
title: '340 Chinese Words You\'ll Use Every Day - Basic Vocabulary #74',
37+
url: 'https://www.youtube.com/embed/40UHvFIJU6U?si=71k8LZKXJmu5oJAO&controls=0',
38+
},
39+
{
40+
title: 'Listening Practice - Naming Culture in China',
41+
url: 'https://www.youtube.com/embed/BCqjc388ExM?si=WDi8obbQM_fPEC22&controls=0',
42+
},
43+
],
44+
};
45+
46+
const handlePlay = () => {
47+
if (videoRef.current) {
48+
const iframeWindow = videoRef.current.contentWindow;
49+
iframeWindow?.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
50+
}
51+
};
52+
53+
const handlePause = () => {
54+
if (videoRef.current) {
55+
const iframeWindow = videoRef.current.contentWindow;
56+
iframeWindow?.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
57+
}
58+
};
59+
60+
const handleNext = () => {
61+
setCurrentIndex((prevIndex) => (prevIndex + 1) % videoData[language as string].length);
62+
};
63+
64+
const currentVideo = videoData[language as string]?.[currentIndex];
65+
66+
return (
67+
<div className="w-full p-16 space-y-24 bg-gradient-to-br from-blue-50 to-indigo-100">
68+
{/* Video Section */}
69+
{currentVideo && (
70+
<section className="space-y-6">
71+
<div className="bg-white shadow-xl rounded-lg p-6 transform hover:scale-105 transition-transform duration-300">
72+
<h2 className="text-3xl font-semibold mb-4 text-indigo-700">{currentVideo.title}</h2>
73+
<div className="relative pb-[56.25%]">
74+
<iframe
75+
ref={videoRef}
76+
title={currentVideo.title}
77+
src={`${currentVideo.url}&enablejsapi=1`}
78+
frameBorder="0"
79+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
80+
allowFullScreen
81+
className="absolute top-0 left-0 w-full h-full rounded-lg shadow-md"
82+
></iframe>
83+
</div>
84+
<div className="flex space-x-4 mt-6 justify-center">
85+
<button
86+
onClick={handlePlay}
87+
className="px-6 py-3 bg-indigo-500 text-white font-bold rounded-full shadow-md hover:bg-indigo-600 transform hover:scale-105 transition-transform duration-200"
88+
>
89+
▶ Play
90+
</button>
91+
<button
92+
onClick={handlePause}
93+
className="px-6 py-3 bg-yellow-500 text-white font-bold rounded-full shadow-md hover:bg-yellow-600 transform hover:scale-105 transition-transform duration-200"
94+
>
95+
⏸ Pause
96+
</button>
97+
<button
98+
onClick={handleNext}
99+
className="px-6 py-3 bg-green-500 text-white font-bold rounded-full shadow-md hover:bg-green-600 transform hover:scale-105 transition-transform duration-200"
100+
>
101+
⏭ Next
102+
</button>
103+
</div>
104+
</div>
105+
</section>
106+
)}
107+
</div>
108+
);
109+
}
110+
111+
export default Video;

0 commit comments

Comments
 (0)