training_data/apps/web/src/components/models/course/detail/CourseDetailDisplayArea.tsx

55 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-01-08 20:29:07 +08:00
// components/CourseDetailDisplayArea.tsx
2025-01-08 00:56:15 +08:00
import { motion, useScroll, useTransform } from "framer-motion";
import React from "react";
import { VideoPlayer } from "@web/src/components/presentation/video-player/VideoPlayer";
2025-01-08 20:29:07 +08:00
import { CourseDetailDescription } from "./CourseDetailDescription/CourseDetailDescription";
2025-01-08 00:56:15 +08:00
import { Course } from "@nice/common";
2025-01-08 20:29:07 +08:00
interface CourseDetailDisplayAreaProps {
2025-01-08 00:56:15 +08:00
course: Course;
videoSrc?: string;
videoPoster?: string;
isLoading?: boolean;
}
2025-01-08 20:29:07 +08:00
export const CourseDetailDisplayArea: React.FC<
CourseDetailDisplayAreaProps
> = ({ course, videoSrc, videoPoster, isLoading = false }) => {
2025-01-08 00:56:15 +08:00
// 创建滚动动画效果
const { scrollY } = useScroll();
const videoScale = useTransform(scrollY, [0, 200], [1, 0.8]);
const videoOpacity = useTransform(scrollY, [0, 200], [1, 0.8]);
return (
<div className="min-h-screen bg-gray-50">
{/* 固定的视频区域 */}
2025-01-08 20:29:07 +08:00
{/* 移除 sticky 定位,让视频区域随页面滚动 */}
2025-01-08 00:56:15 +08:00
<motion.div
2025-01-08 20:29:07 +08:00
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5 }}
2025-01-08 00:56:15 +08:00
style={{
opacity: videoOpacity,
}}
2025-01-08 20:29:07 +08:00
className="w-full bg-black">
<div className=" w-full ">
2025-01-08 00:56:15 +08:00
<VideoPlayer src={videoSrc} poster={videoPoster} />
</div>
</motion.div>
{/* 课程内容区域 */}
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5, delay: 0.2 }}
2025-01-08 20:29:07 +08:00
className="w-full">
<CourseDetailDescription
course={course}
isLoading={isLoading}
/>
2025-01-08 00:56:15 +08:00
</motion.div>
</div>
);
};
2025-01-08 20:29:07 +08:00
export default CourseDetailDisplayArea;