fix(media): add inline podcast player, video buffering track, click-outside speed menu and safe product edit trim
Deploy Canina / deploy (push) Has been cancelled

This commit is contained in:
parsa aghaei committed 2026-08-18 15:43:45 +03:30
1 parent 95d79518e7
commit 36e382cf16
17 files changed
+12496 -11618

No files matched your search

@@ -38,6 +38,7 @@ const WAVEFORM_BAR_COUNT = 48;
export default function PodcastPlayerModal({ isOpen, onClose, podcast }: PodcastPlayerModalProps) {
const audioRef = useRef<HTMLAudioElement>(null);
const waveformRef = useRef<HTMLDivElement>(null);
const rateMenuRef = useRef<HTMLDivElement>(null);
const [isPlaying, setIsPlaying] = useState(false);
const [currentTime, setCurrentTime] = useState(0);
@@ -49,6 +50,21 @@ export default function PodcastPlayerModal({ isOpen, onClose, podcast }: Podcast
const [isBuffering, setIsBuffering] = useState(false);
const [isCopied, setIsCopied] = useState(false);
// Close rate menu on outside click
useEffect(() => {
function handleClickOutside(e: MouseEvent) {
if (rateMenuRef.current && !rateMenuRef.current.contains(e.target as Node)) {
setShowRateMenu(false);
}
}
if (showRateMenu) {
document.addEventListener("mousedown", handleClickOutside);
}
return () => {
document.removeEventListener("mousedown", handleClickOutside);
};
}, [showRateMenu]);
// Deterministic heights for waveform visualization
const waveformHeights = useMemo(() => {
const seed = (podcast?.title || "canina").split("").reduce((acc, char) => acc + char.charCodeAt(0), 0);
@@ -204,8 +220,8 @@ export default function PodcastPlayerModal({ isOpen, onClose, podcast }: Podcast
>
{/* Top Bar (Header + Close) */}
<div className="w-full flex items-center justify-between mb-4">
<div className="flex items-center gap-2.5 text-xs font-black text-purple-400 bg-purple-500/10 px-3.5 py-1.5 rounded-full border border-purple-500/20">
<Headphones className="w-4 h-4 animate-pulse" />
<div className="flex items-center gap-2.5 text-xs font-black text-canina-blue bg-canina-blue/10 px-3.5 py-1.5 rounded-full border border-canina-blue/20">
<Headphones className="w-4 h-4 animate-pulse text-canina-blue" />
<span>پادکست و تحلیل صوتی بالینی</span>
</div>
@@ -285,8 +301,8 @@ export default function PodcastPlayerModal({ isOpen, onClose, podcast }: Podcast
{podcast.title || "بررسی بالینی و نحوه مصرف مکمل"}
</h3>
{podcast.productName && (
<p className="text-purple-400 text-xs font-bold flex items-center justify-center gap-1">
<Sparkles className="w-3.5 h-3.5" />
<p className="text-canina-blue text-xs font-bold flex items-center justify-center gap-1">
<Sparkles className="w-3.5 h-3.5 text-canina-gold" />
<span>محصول: {podcast.productName}</span>
</p>
)}
@@ -317,7 +333,7 @@ export default function PodcastPlayerModal({ isOpen, onClose, podcast }: Podcast
<div
className={`w-full rounded-full transition-all duration-150 ${
isPassed
? "bg-gradient-to-t from-purple-500 to-canina-blue shadow-xs"
? "bg-gradient-to-t from-canina-blue to-cyan-400 shadow-xs"
: "bg-white/20 group-hover/wave:bg-white/30"
} ${isPlaying && isPassed ? "opacity-100" : "opacity-85"}`}
style={{
@@ -340,7 +356,7 @@ export default function PodcastPlayerModal({ isOpen, onClose, podcast }: Podcast
{/* Main Controls Row */}
<div className="w-full flex items-center justify-between pt-2">
{/* Speed Selector Button */}
<div className="relative">
<div className="relative" ref={rateMenuRef}>
<button
type="button"
onClick={() => setShowRateMenu(!showRateMenu)}
@@ -359,7 +375,7 @@ export default function PodcastPlayerModal({ isOpen, onClose, podcast }: Podcast
onClick={() => handleRateChange(rate)}
className={`px-3 py-1 text-xs font-mono font-bold rounded-xl text-center transition-colors cursor-pointer ${
playbackRate === rate
? "bg-purple-600 text-white"
? "bg-canina-blue text-white"
: "text-white/70 hover:bg-white/10 hover:text-white"
}`}
>
@@ -376,7 +392,7 @@ export default function PodcastPlayerModal({ isOpen, onClose, podcast }: Podcast
<button
type="button"
onClick={togglePlay}
className="w-12 h-12 rounded-full bg-purple-600 hover:bg-purple-500 text-white flex items-center justify-center transition-transform hover:scale-105 active:scale-95 cursor-pointer shadow-xl shadow-purple-600/40 border border-white/20"
className="w-12 h-12 rounded-full bg-canina-blue hover:bg-canina-blue/90 text-white flex items-center justify-center transition-transform hover:scale-105 active:scale-95 cursor-pointer shadow-xl shadow-canina-blue/40 border border-white/20"
title={isPlaying ? "توقف" : "پخش"}
>
{isPlaying ? <Pause className="w-5 h-5 fill-white" /> : <Play className="w-5 h-5 fill-white ml-0.5" />}
@@ -410,7 +426,7 @@ export default function PodcastPlayerModal({ isOpen, onClose, podcast }: Podcast
<div className="relative w-16 hidden sm:flex items-center h-4">
<div className="absolute inset-x-0 h-1.5 bg-white/20 rounded-lg overflow-hidden pointer-events-none">
<div
className="h-full bg-purple-500 transition-all"
className="h-full bg-canina-blue transition-all"
style={{ width: `${volumePercent}%` }}
/>
</div>