Skip to content

Commit 8cbbc2f

Browse files
FEATURE (videos): Add videos
1 parent 4a1b635 commit 8cbbc2f

File tree

4 files changed

+73
-18
lines changed

4 files changed

+73
-18
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"use client";
2+
3+
import { useState } from "react";
4+
5+
interface LiteYouTubeEmbedProps {
6+
videoId: string;
7+
title: string;
8+
thumbnailSrc: string;
9+
}
10+
11+
export default function LiteYouTubeEmbed({
12+
videoId,
13+
title,
14+
thumbnailSrc,
15+
}: LiteYouTubeEmbedProps) {
16+
const [isIframeLoaded, setIsIframeLoaded] = useState(false);
17+
18+
const handleClick = () => {
19+
setIsIframeLoaded(true);
20+
};
21+
22+
return (
23+
<div
24+
className="relative w-full overflow-hidden rounded-lg shadow-lg"
25+
style={{ paddingBottom: "56.25%" }}
26+
>
27+
{!isIframeLoaded ? (
28+
<>
29+
<img
30+
src={thumbnailSrc}
31+
alt={title}
32+
loading="lazy"
33+
className="absolute left-0 top-0 h-full w-full object-cover"
34+
/>
35+
<button
36+
onClick={handleClick}
37+
className="absolute cursor-pointer left-0 top-0 z-10 flex h-full w-full items-center justify-center transition-all hover:bg-opacity-20"
38+
aria-label={`Play ${title}`}
39+
>
40+
<div className="flex items-center justify-center rounded-xl bg-red-600 px-5 py-2 transition-transform hover:scale-105 sm:px-5 sm:py-2">
41+
<svg
42+
className="h-6 w-6 text-white sm:h-8 sm:w-8"
43+
fill="currentColor"
44+
viewBox="0 0 24 24"
45+
>
46+
<path d="M8 5v14l11-7z" />
47+
</svg>
48+
</div>
49+
</button>
50+
</>
51+
) : (
52+
<iframe
53+
src={`https://www.youtube.com/embed/${videoId}?autoplay=1`}
54+
title={title}
55+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
56+
allowFullScreen
57+
className="absolute left-0 top-0 h-full w-full"
58+
/>
59+
)}
60+
</div>
61+
);
62+
}

app/page.tsx

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Metadata } from "next";
22
import Image from "next/image";
33
import InstallationComponent from "./components/InstallationComponent";
4+
import LiteYouTubeEmbed from "./components/LiteYouTubeEmbed";
45

56
export const metadata: Metadata = {
67
title: "Postgresus | PostgreSQL backup",
@@ -445,15 +446,11 @@ export default function Index() {
445446
{/* Video Section */}
446447
<div className="flex-1">
447448
<div className="">
448-
<div className="relative aspect-video w-full overflow-hidden rounded-lg shadow">
449-
<iframe
450-
src="https://www.youtube.com/embed/1qsAnijJfJE?si=LgbFoNc_Xg5C1saW"
451-
title="How to use Postgresus (overview)?"
452-
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
453-
allowFullScreen
454-
className="absolute inset-0 h-full w-full"
455-
/>
456-
</div>
449+
<LiteYouTubeEmbed
450+
videoId="1qsAnijJfJE"
451+
title="How to use Postgresus (overview)?"
452+
thumbnailSrc="/images/index/how-to-use-preview.png"
453+
/>
457454

458455
<h3 className="mb-1 mt-5 text-xl font-semibold md:text-xl">
459456
How to use Postgresus (overview)?
@@ -881,15 +878,11 @@ export default function Index() {
881878
on VPS (all 3 ways)
882879
</p>
883880
<div className="max-w-[800px]">
884-
<div className="relative aspect-video w-full overflow-hidden rounded-lg shadow-lg">
885-
<iframe
886-
src="https://www.youtube.com/embed/1qsAnijJfJE?si=KCa_IhCtPbOv5XfO"
887-
title="How to install Postgresus on VPS"
888-
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
889-
allowFullScreen
890-
className="absolute inset-0 h-full w-full"
891-
/>
892-
</div>
881+
<LiteYouTubeEmbed
882+
videoId="1qsAnijJfJE"
883+
title="How to install Postgresus on VPS"
884+
thumbnailSrc="/images/index/how-to-install-preview.png"
885+
/>
893886
</div>
894887
</div>
895888
</div>
26.3 KB
Loading
25.5 KB
Loading

0 commit comments

Comments
 (0)