From 22aac877b93edb3b3903fbdea0f8419aba27a030 Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Thu, 28 Aug 2025 20:24:30 +0000 Subject: [PATCH] Add video navigation and translate UI elements to Slovenian Introduce left/right arrow navigation for videos and translate several UI strings to Slovenian. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 2eb1084e-b728-4449-9231-f1665924c8d5 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/2eb1084e-b728-4449-9231-f1665924c8d5/14Urb47 --- client/src/components/bunny-video-modal.tsx | 179 ++++++-------------- client/src/components/video-grid.tsx | 9 +- client/src/pages/VideoPage.tsx | 2 +- 3 files changed, 58 insertions(+), 132 deletions(-) diff --git a/client/src/components/bunny-video-modal.tsx b/client/src/components/bunny-video-modal.tsx index a3b17bf..31e199c 100644 --- a/client/src/components/bunny-video-modal.tsx +++ b/client/src/components/bunny-video-modal.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from "react"; -import { X, Share2, Edit3 } from "lucide-react"; +import { X, Share2, Edit3, ChevronLeft, ChevronRight } from "lucide-react"; import { type Video } from "@shared/schema"; import { Button } from "@/components/ui/button"; import { apiRequest } from "@/lib/queryClient"; @@ -53,9 +53,29 @@ function formatDate(date: Date | string): string { export default function BunnyVideoModal({ video, isOpen, onClose, onEdit, videos = [], onVideoChange }: BunnyVideoModalProps) { const [showShareMenu, setShowShareMenu] = useState(false); - const [isDragging, setIsDragging] = useState(false); - const [dragStart, setDragStart] = useState({ x: 0, y: 0 }); - const [dragOffset, setDragOffset] = useState(0); + + // Navigation functions + const getCurrentVideoIndex = () => { + if (!video || !videos.length) return -1; + return videos.findIndex((v: Video) => v.id === video.id); + }; + + const navigateToVideo = (direction: 'next' | 'prev') => { + const currentIndex = getCurrentVideoIndex(); + if (currentIndex === -1 || !onVideoChange) return; + + let newIndex; + if (direction === 'next') { + newIndex = currentIndex + 1 >= videos.length ? 0 : currentIndex + 1; + } else { + newIndex = currentIndex - 1 < 0 ? videos.length - 1 : currentIndex - 1; + } + + const newVideo = videos[newIndex]; + if (newVideo) { + onVideoChange(newVideo); + } + }; useEffect(() => { const handleEscape = (e: KeyboardEvent) => { @@ -142,99 +162,6 @@ export default function BunnyVideoModal({ video, isOpen, onClose, onEdit, videos setShowShareMenu(false); }; - // Navigation functions - const getCurrentVideoIndex = () => { - if (!video || !videos.length) return -1; - return videos.findIndex(v => v.id === video.id); - }; - - const navigateToVideo = (direction: 'next' | 'prev') => { - const currentIndex = getCurrentVideoIndex(); - if (currentIndex === -1) return; - - let newIndex; - if (direction === 'next') { - newIndex = currentIndex + 1 >= videos.length ? 0 : currentIndex + 1; - } else { - newIndex = currentIndex - 1 < 0 ? videos.length - 1 : currentIndex - 1; - } - - const newVideo = videos[newIndex]; - if (newVideo && onVideoChange) { - onVideoChange(newVideo); - } - }; - - // Touch and mouse drag handlers - const handleDragStart = (clientX: number, clientY: number) => { - setIsDragging(true); - setDragStart({ x: clientX, y: clientY }); - setDragOffset(0); - }; - - const handleDragMove = (clientX: number, clientY: number) => { - if (!isDragging) return; - - const deltaX = clientX - dragStart.x; - const deltaY = Math.abs(clientY - dragStart.y); - - // Only allow horizontal drag if it's more horizontal than vertical - if (deltaY < Math.abs(deltaX)) { - setDragOffset(deltaX); - } - }; - - const handleDragEnd = () => { - if (!isDragging) return; - - const threshold = 100; // minimum drag distance to trigger navigation - - if (Math.abs(dragOffset) > threshold && videos.length > 1) { - if (dragOffset > 0) { - navigateToVideo('prev'); // drag right = previous video - } else { - navigateToVideo('next'); // drag left = next video - } - } - - setIsDragging(false); - setDragOffset(0); - }; - - // Mouse events - const handleMouseDown = (e: React.MouseEvent) => { - if (e.target === e.currentTarget) return; // only on video area - handleDragStart(e.clientX, e.clientY); - }; - - const handleMouseMove = (e: React.MouseEvent) => { - handleDragMove(e.clientX, e.clientY); - }; - - const handleMouseUp = () => { - handleDragEnd(); - }; - - // Touch events - const handleTouchStart = (e: React.TouchEvent) => { - if (e.touches.length !== 1) return; - const touch = e.touches[0]; - handleDragStart(touch.clientX, touch.clientY); - e.preventDefault(); - }; - - const handleTouchMove = (e: React.TouchEvent) => { - if (e.touches.length !== 1) return; - if (!isDragging) return; - const touch = e.touches[0]; - handleDragMove(touch.clientX, touch.clientY); - e.preventDefault(); - }; - - const handleTouchEnd = (e: React.TouchEvent) => { - handleDragEnd(); - e.preventDefault(); - }; if (!isOpen || !video) return null; @@ -330,17 +257,7 @@ export default function BunnyVideoModal({ video, isOpen, onClose, onEdit, videos
{/* Main video player */}
-
+
{video.videoUrlIframe ? (