From b9533ea7ec91fc8bc29738b7caea74b2444b130a Mon Sep 17 00:00:00 2001 From: G-nizam-A Date: Sun, 24 Mar 2024 17:44:49 +0530 Subject: [PATCH 1/2] Feat: Embed video trailer youtube #12 Fixes #12 --- package.json | 4 +- src/components/Dailog.tsx | 122 ++++++++++++++++++++++++++++++++++++++ src/pages/Show/Movie.tsx | 28 +++++---- src/pages/Show/Tv.tsx | 28 +++++---- 4 files changed, 161 insertions(+), 21 deletions(-) create mode 100644 src/components/Dailog.tsx diff --git a/package.json b/package.json index 4f60f2e..30e3bec 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,8 @@ "preview": "vite preview" }, "dependencies": { + "@radix-ui/react-dialog": "^1.0.5", + "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-select": "^2.0.0", "@radix-ui/react-slot": "^1.0.2", "class-variance-authority": "^0.7.0", @@ -41,4 +43,4 @@ "typescript": "^5.2.2", "vite": "^5.1.6" } -} \ No newline at end of file +} diff --git a/src/components/Dailog.tsx b/src/components/Dailog.tsx new file mode 100644 index 0000000..95b0d38 --- /dev/null +++ b/src/components/Dailog.tsx @@ -0,0 +1,122 @@ +"use client" + +import * as React from "react" +import * as DialogPrimitive from "@radix-ui/react-dialog" +import { Cross2Icon } from "@radix-ui/react-icons" + +import { cn } from "@/lib/utils" + +const Dialog = DialogPrimitive.Root + +const DialogTrigger = DialogPrimitive.Trigger + +const DialogPortal = DialogPrimitive.Portal + +const DialogClose = DialogPrimitive.Close + +const DialogOverlay = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName + +const DialogContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + + + {children} + + + Close + + + +)) +DialogContent.displayName = DialogPrimitive.Content.displayName + +const DialogHeader = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +DialogHeader.displayName = "DialogHeader" + +const DialogFooter = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +DialogFooter.displayName = "DialogFooter" + +const DialogTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogTitle.displayName = DialogPrimitive.Title.displayName + +const DialogDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogDescription.displayName = DialogPrimitive.Description.displayName + +export { + Dialog, + DialogPortal, + DialogOverlay, + DialogTrigger, + DialogClose, + DialogContent, + DialogHeader, + DialogFooter, + DialogTitle, + DialogDescription, +} diff --git a/src/pages/Show/Movie.tsx b/src/pages/Show/Movie.tsx index 849cfe7..3eb67b0 100644 --- a/src/pages/Show/Movie.tsx +++ b/src/pages/Show/Movie.tsx @@ -1,4 +1,4 @@ -import { Link, useParams } from "react-router-dom"; +import { useParams } from "react-router-dom"; import useFetch from "@/hooks/useFetch"; import type { Movie as MovieType } from "@/types/movie"; import type { Images, Media, Video } from "@/types/media"; @@ -18,6 +18,7 @@ import { } from "@/components/ui/carousel"; import SimilarCardItem from "@/components/SimilarCardItem"; import WatchProviderContainer from "@/components/WatchProviderContainer"; +import { Dialog, DialogContent, DialogTrigger, } from "@/components/Dailog"; export default function Movie() { const params = useParams(); @@ -106,15 +107,22 @@ export default function Movie() { )} {!!videos?.results.length && ( - - Watch Trailer - + + +
Watch Trailer
+
+ +