veza/apps/web/src/features/player/components/GlobalPlayer.tsx

47 lines
1.7 KiB
TypeScript
Raw Normal View History

import { useState } from 'react';
import { usePlayerStore } from '../store/playerStore';
import { MiniPlayer } from './MiniPlayer';
import { AudioPlayer } from './AudioPlayer';
import { Dialog, DialogContent } from '@/components/ui/dialog';
import { Minimize2 } from 'lucide-react';
import { Button } from '@/components/ui/button';
export function GlobalPlayer() {
const currentTrack = usePlayerStore((state) => state.currentTrack);
const [isExpanded, setIsExpanded] = useState(false);
// Don't render anything if no track is playing (or perform null check inside components)
if (!currentTrack) return null;
return (
<>
<MiniPlayer
isVisible={!isExpanded}
onToggle={() => setIsExpanded(true)}
className="border-t border-white/10 bg-kodo-void/80 backdrop-blur-xl shadow-[0_-4px_30px_rgba(0,0,0,0.5)] z-50"
/>
<Dialog open={isExpanded} onOpenChange={setIsExpanded}>
<DialogContent className="max-w-4xl h-[80vh] p-0 overflow-hidden border-white/10 bg-kodo-void/95 backdrop-blur-2xl shadow-2xl sm:rounded-2xl ring-1 ring-white/10">
<div className="relative w-full h-full bg-gradient-to-b from-kodo-void/50 to-kodo-void rounded-xl overflow-y-auto">
<div className="absolute top-4 right-4 z-50">
<Button
variant="ghost"
size="icon"
onClick={() => setIsExpanded(false)}
className="hover:bg-white/10 text-white"
>
<Minimize2 className="h-5 w-5" />
</Button>
</div>
<AudioPlayer
className="h-full border-none shadow-none"
compact={false}
/>
</div>
</DialogContent>
</Dialog>
</>
);
}