1
1
mirror of https://github.com/neosubhamoy/neodlp.git synced 2026-03-23 03:05:49 +05:30

refactor: migrated to react-resizable-panels v4

This commit is contained in:
2026-02-12 23:11:34 +05:30
Verified
parent 27031b05d8
commit 6afc8c4ada
5 changed files with 62 additions and 47 deletions

12
package-lock.json generated
View File

@@ -66,7 +66,7 @@
"react-day-picker": "^9.13.2", "react-day-picker": "^9.13.2",
"react-dom": "^19.2.4", "react-dom": "^19.2.4",
"react-hook-form": "^7.71.1", "react-hook-form": "^7.71.1",
"react-resizable-panels": "^3.0.6", "react-resizable-panels": "^4.6.2",
"react-router-dom": "^7.13.0", "react-router-dom": "^7.13.0",
"recharts": "^3.7.0", "recharts": "^3.7.0",
"sonner": "^2.0.7", "sonner": "^2.0.7",
@@ -5154,13 +5154,13 @@
} }
}, },
"node_modules/react-resizable-panels": { "node_modules/react-resizable-panels": {
"version": "3.0.6", "version": "4.6.2",
"resolved": "https://registry.npmjs.org/react-resizable-panels/-/react-resizable-panels-3.0.6.tgz", "resolved": "https://registry.npmjs.org/react-resizable-panels/-/react-resizable-panels-4.6.2.tgz",
"integrity": "sha512-b3qKHQ3MLqOgSS+FRYKapNkJZf5EQzuf6+RLiq1/IlTHw99YrZ2NJZLk4hQIzTnnIkRg2LUqyVinu6YWWpUYew==", "integrity": "sha512-d6hyD6s7ewNAI+oINrZznR/08GUyAszrowXouUDztePEn/tQ2z/LEI2qRvrizYBe3TpgBi0cCjc10pXTTOc4jw==",
"license": "MIT", "license": "MIT",
"peerDependencies": { "peerDependencies": {
"react": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc", "react": "^18.0.0 || ^19.0.0",
"react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" "react-dom": "^18.0.0 || ^19.0.0"
} }
}, },
"node_modules/react-router": { "node_modules/react-router": {

View File

@@ -78,7 +78,7 @@
"react-day-picker": "^9.13.2", "react-day-picker": "^9.13.2",
"react-dom": "^19.2.4", "react-dom": "^19.2.4",
"react-hook-form": "^7.71.1", "react-hook-form": "^7.71.1",
"react-resizable-panels": "^3.0.6", "react-resizable-panels": "^4.6.2",
"react-router-dom": "^7.13.0", "react-router-dom": "^7.13.0",
"recharts": "^3.7.0", "recharts": "^3.7.0",
"sonner": "^2.0.7", "sonner": "^2.0.7",

View File

@@ -10,6 +10,7 @@ import { PlaylistToggleGroup, PlaylistToggleGroupItem } from "@/components/custo
import { getMergedBestFormat } from "@/utils"; import { getMergedBestFormat } from "@/utils";
import { Switch } from "@/components/ui/switch"; import { Switch } from "@/components/ui/switch";
import { FormatToggleGroup, FormatToggleGroupItem } from "@/components/custom/formatToggleGroup"; import { FormatToggleGroup, FormatToggleGroupItem } from "@/components/custom/formatToggleGroup";
import { Layout } from "react-resizable-panels";
interface PlaylistPreviewSelectionProps { interface PlaylistPreviewSelectionProps {
videoMetadata: RawVideoInfo; videoMetadata: RawVideoInfo;
@@ -348,18 +349,22 @@ export function PlaylistDownloader({ videoMetadata, audioOnlyFormats, videoOnlyF
return ( return (
<div className="flex"> <div className="flex">
<ResizablePanelGroup <ResizablePanelGroup
direction="horizontal" orientation="horizontal"
className="w-full" className="w-full"
onLayout={(sizes) => setPlaylistPanelSizes(sizes)} onLayoutChanged={(layout: Layout) => {
const firstPanelSize = layout[Object.keys(layout)[0]];
const secondPanelSize = layout[Object.keys(layout)[1]];
setPlaylistPanelSizes([firstPanelSize, secondPanelSize]);
}}
> >
<ResizablePanel <ResizablePanel
defaultSize={playlistPanelSizes[0]} defaultSize={`${playlistPanelSizes[0]}%`}
> >
<PlaylistPreviewSelection videoMetadata={videoMetadata} /> <PlaylistPreviewSelection videoMetadata={videoMetadata} />
</ResizablePanel> </ResizablePanel>
<ResizableHandle /> <ResizableHandle withHandle />
<ResizablePanel <ResizablePanel
defaultSize={playlistPanelSizes[1]} defaultSize={`${playlistPanelSizes[1]}%`}
> >
<div className="flex flex-col w-full pl-4"> <div className="flex flex-col w-full pl-4">
<Tabs <Tabs

View File

@@ -12,6 +12,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/components/ui/resizable"; import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/components/ui/resizable";
import { FormatToggleGroup, FormatToggleGroupItem } from "@/components/custom/formatToggleGroup"; import { FormatToggleGroup, FormatToggleGroupItem } from "@/components/custom/formatToggleGroup";
import { Layout } from "react-resizable-panels";
interface VideoPreviewProps { interface VideoPreviewProps {
videoMetadata: RawVideoInfo; videoMetadata: RawVideoInfo;
@@ -325,18 +326,22 @@ export function VideoDownloader({ videoMetadata, audioOnlyFormats, videoOnlyForm
return ( return (
<div className="flex"> <div className="flex">
<ResizablePanelGroup <ResizablePanelGroup
direction="horizontal" orientation="horizontal"
className="w-full" className="w-full"
onLayout={(sizes) => setVideoPanelSizes(sizes)} onLayoutChanged={(layout: Layout) => {
const firstPanelSize = layout[Object.keys(layout)[0]];
const secondPanelSize = layout[Object.keys(layout)[1]];
setVideoPanelSizes([firstPanelSize, secondPanelSize]);
}}
> >
<ResizablePanel <ResizablePanel
defaultSize={videoPanelSizes[0]} defaultSize={`${videoPanelSizes[0]}%`}
> >
<VideoPreview videoMetadata={videoMetadata} /> <VideoPreview videoMetadata={videoMetadata} />
</ResizablePanel> </ResizablePanel>
<ResizableHandle /> <ResizableHandle withHandle />
<ResizablePanel <ResizablePanel
defaultSize={videoPanelSizes[1]} defaultSize={`${videoPanelSizes[1]}%`}
> >
<div className="flex flex-col w-full pl-4"> <div className="flex flex-col w-full pl-4">
<Tabs <Tabs

View File

@@ -1,45 +1,50 @@
"use client" "use client"
import { GripVertical } from "lucide-react"
import * as ResizablePrimitive from "react-resizable-panels" import * as ResizablePrimitive from "react-resizable-panels"
import { cn } from "@/lib/utils" import { cn } from "@/lib/utils"
const ResizablePanelGroup = ({ function ResizablePanelGroup({
className, className,
...props ...props
}: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => ( }: ResizablePrimitive.GroupProps) {
<ResizablePrimitive.PanelGroup return (
<ResizablePrimitive.Group
data-slot="resizable-panel-group"
className={cn( className={cn(
"flex h-full w-full data-[panel-group-direction=vertical]:flex-col", "flex h-full w-full aria-[orientation=vertical]:flex-col",
className className
)} )}
{...props} {...props}
/> />
) )
}
const ResizablePanel = ResizablePrimitive.Panel function ResizablePanel({ ...props }: ResizablePrimitive.PanelProps) {
return <ResizablePrimitive.Panel data-slot="resizable-panel" {...props} />
}
const ResizableHandle = ({ function ResizableHandle({
withHandle, withHandle,
className, className,
...props ...props
}: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & { }: ResizablePrimitive.SeparatorProps & {
withHandle?: boolean withHandle?: boolean
}) => ( }) {
<ResizablePrimitive.PanelResizeHandle return (
<ResizablePrimitive.Separator
data-slot="resizable-handle"
className={cn( className={cn(
"relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90", "bg-border focus-visible:ring-ring ring-offset-background relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",
className className
)} )}
{...props} {...props}
> >
{withHandle && ( {withHandle && (
<div className="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border"> <div className="bg-border h-6 w-1 rounded-lg z-10 flex shrink-0" />
<GripVertical className="h-2.5 w-2.5" />
</div>
)} )}
</ResizablePrimitive.PanelResizeHandle> </ResizablePrimitive.Separator>
) )
}
export { ResizablePanelGroup, ResizablePanel, ResizableHandle } export { ResizableHandle, ResizablePanel, ResizablePanelGroup }