Skip to content

Commit 2cb44b3

Browse files
authored
1071 video player page for courses (#1176)
add video player, mocks and FT
1 parent 517763f commit 2cb44b3

File tree

4 files changed

+275
-0
lines changed

4 files changed

+275
-0
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
"use client";
2+
import { FEATURE_FLAGS, isFlagEnabled } from "@/utils/flags";
3+
import { CircleCheck, SquarePlay } from "lucide-react";
4+
import { type Session } from "next-auth";
5+
import { notFound } from "next/navigation";
6+
import { mockContentList } from "../../mock";
7+
8+
interface ContentProps {
9+
session: Session | null;
10+
}
11+
12+
const Content = ({ session }: ContentProps) => {
13+
const flagEnabled = isFlagEnabled(FEATURE_FLAGS.COURSE_VIDEO);
14+
15+
if (!flagEnabled) {
16+
notFound();
17+
}
18+
19+
return (
20+
<div className="overflow-auto">
21+
<div className="w-full divide-x divide-gray-700 lg:grid lg:grid-cols-12">
22+
<VideoPlayer />
23+
<Sidebar contentList={mockContentList} />
24+
</div>
25+
<div className="mx-auto max-w-5xl">
26+
<ContentList contentList={mockContentList} />
27+
</div>
28+
</div>
29+
);
30+
};
31+
32+
const VideoPlayer = () => (
33+
<div className="col-span-9">
34+
<div className="mx-auto w-full max-w-7xl bg-black">
35+
<iframe
36+
className="aspect-video w-full"
37+
src="https://www.youtube.com/embed/oKKG-CpDjrI"
38+
title="YouTube video"
39+
></iframe>
40+
</div>
41+
</div>
42+
);
43+
44+
interface SidebarProps {
45+
contentList: typeof mockContentList;
46+
}
47+
48+
const Sidebar = ({ contentList }: SidebarProps) => (
49+
<div className="col-span-3 flex w-full flex-col overflow-auto">
50+
<ul className="divide-y divide-gray-700">
51+
{contentList && contentList.length > 0 ? (
52+
contentList.map((item, index) => (
53+
<SidebarItem key={index} item={item} />
54+
))
55+
) : (
56+
<li className="text-center text-gray-500">No content available</li>
57+
)}
58+
</ul>
59+
</div>
60+
);
61+
62+
interface SidebarItemProps {
63+
item: (typeof mockContentList)[0];
64+
}
65+
66+
const SidebarItem = ({ item }: SidebarItemProps) => (
67+
<li className="flex flex-row items-center justify-between px-2 py-2">
68+
<div className="flex flex-row items-center">
69+
<SquarePlay
70+
className="mr-4 h-5 w-5 text-white group-hover:text-white"
71+
aria-hidden="true"
72+
/>
73+
<p>{item.title}</p>
74+
</div>
75+
<CircleCheck
76+
className={`h-6 w-6 ${
77+
item.watched ? "mr-2 h-5 w-5 text-pink-600" : "mr-2 h-5 w-5 text-white"
78+
}`}
79+
aria-hidden="true"
80+
/>
81+
</li>
82+
);
83+
84+
interface ContentListProps {
85+
contentList: typeof mockContentList;
86+
}
87+
88+
const ContentList = ({ contentList }: ContentListProps) => {
89+
return (
90+
<>
91+
{contentList.map(
92+
({
93+
id,
94+
title,
95+
longDescription,
96+
description,
97+
publishedDate,
98+
author,
99+
imageLink,
100+
}) => (
101+
<div key={id} className="mx-auto w-full max-w-7xl py-8">
102+
<h2 className="text-3xl font-extrabold tracking-tight text-neutral-800 dark:text-white">
103+
{title}
104+
</h2>
105+
<li key={author} className="flex justify-between gap-x-6 py-5">
106+
<div className="flex min-w-0 gap-x-4">
107+
<img
108+
alt=""
109+
src={imageLink}
110+
className="h-12 w-12 flex-none rounded-full bg-gray-50"
111+
/>
112+
<div className="min-w-0 flex-auto">
113+
<p className="text-sm font-semibold leading-6 text-neutral-800 dark:text-white">
114+
{author}
115+
</p>
116+
<p className="mt-1 truncate text-xs leading-5 text-gray-500">
117+
{publishedDate}
118+
</p>
119+
</div>
120+
</div>
121+
</li>
122+
<div>{description}</div>
123+
<div>{longDescription}</div>
124+
</div>
125+
),
126+
)}
127+
</>
128+
);
129+
};
130+
131+
export default Content;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { getServerAuthSession } from "@/server/auth";
2+
import Content from "./_client";
3+
4+
export const metadata = {
5+
title: "Video Course",
6+
};
7+
8+
export default async function Page() {
9+
// Example of grabbing session in case it is needed
10+
const session = await getServerAuthSession();
11+
12+
return <Content session={session} />;
13+
}

app/(app)/courses/mock.ts

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
// Mock video source (this would typically be a path to a video file)
2+
const mockVideoSrc = "https://youtu.be/Ln4KSN0rchI?t=12";
3+
4+
// Mock content list
5+
const mockContentList = [
6+
{
7+
id: 1,
8+
title: "Introduction to React",
9+
longDescription:
10+
"In this video, we will explore the fundamentals of React, including its component-based architecture, virtual DOM, and how to get started with your first React application. This tutorial guides you through the installation and configuration of essential tools like Node.js, npm, and create-react-app to set up your React development environment.",
11+
description: "Learn the basics of React and its core concepts",
12+
watched: false,
13+
publishedDate: "2023-01-15",
14+
author: "John Doe",
15+
imageLink: "https://example.com/images/react-introduction.jpg",
16+
},
17+
{
18+
id: 2,
19+
title: "Setting Up Your Development Environment",
20+
longDescription:
21+
"This tutorial guides you through the installation and configuration of essential tools like Node.js, npm, and create-react-app to set up your React development environment.",
22+
description:
23+
"Install and configure the necessary tools for React development",
24+
watched: true,
25+
publishedDate: "2023-01-22",
26+
author: "Jane Smith",
27+
},
28+
{
29+
id: 3,
30+
title: "Components and Props",
31+
longDescription:
32+
"Dive deep into React's core concepts of components and props. Learn how to create reusable components and pass data between them using props.",
33+
description: "Understand the building blocks of React applications",
34+
watched: true,
35+
publishedDate: "2023-01-29",
36+
author: "John Doe",
37+
},
38+
{
39+
id: 4,
40+
title: "State and Lifecycle",
41+
longDescription:
42+
"Explore how to manage component state and lifecycle methods to build dynamic and interactive applications with React.",
43+
description: "Manage component state and lifecycle methods",
44+
watched: true,
45+
publishedDate: "2023-02-05",
46+
author: "Jane Smith",
47+
},
48+
{
49+
id: 5,
50+
title: "Handling Events",
51+
longDescription:
52+
"Learn how to handle user interactions in React, including events like clicks, form submissions, and more.",
53+
description: "Learn how to handle user interactions in React",
54+
watched: true,
55+
publishedDate: "2023-02-12",
56+
author: "John Doe",
57+
},
58+
{
59+
id: 6,
60+
title: "Conditional Rendering",
61+
longDescription:
62+
"Discover how to display different UI elements based on specific conditions in your React applications.",
63+
description: "Display different UI based on conditions",
64+
watched: false,
65+
publishedDate: "2023-02-19",
66+
author: "Jane Smith",
67+
},
68+
{
69+
id: 7,
70+
title: "Lists and Keys",
71+
longDescription:
72+
"Learn the best practices for rendering lists of components in React and how to efficiently manage them with unique keys.",
73+
description: "Render multiple components efficiently",
74+
watched: false,
75+
publishedDate: "2023-02-26",
76+
author: "John Doe",
77+
},
78+
{
79+
id: 8,
80+
title: "Forms in React",
81+
longDescription:
82+
"This video covers how to create and manage forms in React applications, including controlled and uncontrolled components.",
83+
description: "Create and handle form inputs in React applications",
84+
watched: false,
85+
publishedDate: "2023-03-05",
86+
author: "Jane Smith",
87+
},
88+
{
89+
id: 9,
90+
title: "Hooks: useState and useEffect",
91+
longDescription:
92+
"An introduction to React Hooks, focusing on useState and useEffect to manage state and side effects in functional components.",
93+
description: "Understand and use basic React Hooks",
94+
watched: false,
95+
publishedDate: "2023-03-12",
96+
author: "John Doe",
97+
},
98+
{
99+
id: 10,
100+
title: "Custom Hooks",
101+
longDescription:
102+
"Learn how to create custom hooks in React to encapsulate and reuse logic across components.",
103+
description: "Create reusable logic with custom Hooks",
104+
watched: false,
105+
publishedDate: "2023-03-19",
106+
author: "Jane Smith",
107+
},
108+
{
109+
id: 11,
110+
title: "Context API",
111+
longDescription:
112+
"Explore the Context API to manage global state in your React applications without the need for prop drilling.",
113+
description: "Manage global state in your React application",
114+
watched: false,
115+
publishedDate: "2023-03-26",
116+
author: "John Doe",
117+
},
118+
{
119+
id: 12,
120+
title: "React Router",
121+
longDescription:
122+
"Learn how to implement navigation in your single-page applications using React Router, including dynamic routing and nested routes.",
123+
description: "Implement navigation in your single-page application",
124+
watched: false,
125+
publishedDate: "2023-04-02",
126+
author: "Jane Smith",
127+
},
128+
];
129+
130+
export { mockVideoSrc, mockContentList };

utils/flags.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { posthog } from "posthog-js";
22

33
export const FEATURE_FLAGS = {
44
FEATURE_FLAG_TEST: "feature-flag-test",
5+
COURSE_VIDEO: "course-video",
56
JOBS: "jobs",
67
// Add more feature flags as needed
78
} as const;

0 commit comments

Comments
 (0)