2025-12-03 21:56:50 +00:00
|
|
|
/**
|
|
|
|
|
* Composant MiniPlayer
|
|
|
|
|
* Version compacte du player avec position fixe et toggle
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { ChevronUp, X } from 'lucide-react';
|
|
|
|
|
import { cn } from '@/lib/utils';
|
|
|
|
|
import { usePlayer } from '../hooks/usePlayer';
|
|
|
|
|
import { TrackInfo } from './TrackInfo';
|
|
|
|
|
import { PlayPauseButton } from './PlayPauseButton';
|
|
|
|
|
import { NextPreviousButtons } from './NextPreviousButtons';
|
|
|
|
|
import { ProgressBar } from './ProgressBar';
|
|
|
|
|
import { VolumeControl } from './VolumeControl';
|
|
|
|
|
|
|
|
|
|
export interface MiniPlayerProps {
|
|
|
|
|
isVisible: boolean;
|
|
|
|
|
onToggle: () => void;
|
|
|
|
|
onClose?: () => void;
|
|
|
|
|
className?: string;
|
|
|
|
|
position?: 'bottom' | 'top';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function MiniPlayer({
|
|
|
|
|
isVisible,
|
|
|
|
|
onToggle,
|
|
|
|
|
onClose,
|
|
|
|
|
className,
|
|
|
|
|
position = 'bottom',
|
|
|
|
|
}: MiniPlayerProps) {
|
|
|
|
|
const player = usePlayer();
|
|
|
|
|
|
|
|
|
|
if (!isVisible || !player.currentTrack) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handlePlayPause = () => {
|
|
|
|
|
if (player.isPlaying) {
|
|
|
|
|
player.pause();
|
|
|
|
|
} else {
|
|
|
|
|
player.resume();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-13 02:34:34 +00:00
|
|
|
const canGoNext =
|
|
|
|
|
player.queue.length > 0 && player.currentIndex < player.queue.length - 1;
|
2025-12-03 21:56:50 +00:00
|
|
|
const canGoPrevious = player.queue.length > 0 && player.currentIndex > 0;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className={cn(
|
2026-01-16 00:56:54 +00:00
|
|
|
'fixed left-0 right-0 z-50 bg-white dark:bg-kodo-ink border-t border-kodo-steel dark:border-kodo-steel shadow-lg',
|
2025-12-03 21:56:50 +00:00
|
|
|
'transition-transform duration-300 ease-in-out',
|
|
|
|
|
position === 'bottom' ? 'bottom-0' : 'top-0',
|
2025-12-13 02:34:34 +00:00
|
|
|
className,
|
2025-12-03 21:56:50 +00:00
|
|
|
)}
|
|
|
|
|
role="region"
|
|
|
|
|
aria-label="Mini lecteur audio"
|
|
|
|
|
>
|
|
|
|
|
<div className="container mx-auto px-4 py-2">
|
aesthetic-improvements: align spacing to 8px grid (Action 11.2.1.3)
- Created automated script (scripts/align-8px-grid.py) to align all spacing to 8px grid
- Replaced non-8px-aligned spacing: gap-3/p-3/m-3 (12px) → gap-4/p-4/m-4 (16px), gap-5/p-5/m-5 (20px) → gap-6/p-6/m-6 (24px), gap-10/p-10/m-10 (40px) → gap-12/p-12/m-12 (48px), gap-20/p-20/m-20 (80px) → gap-24/p-24/m-24 (96px)
- Preserved: 4px values (gap-1, p-1, m-1) as they may be intentional fine-tuning, responsive breakpoints (sm:, md:, lg:), test files, documentation
- Modified files across all components to ensure consistent 8px grid alignment
- Action 11.2.1.3: Align all elements to 8px grid - COMPLETE
2026-01-16 10:50:46 +00:00
|
|
|
<div className="flex items-center gap-4">
|
2025-12-03 21:56:50 +00:00
|
|
|
{/* Track Info - Compact */}
|
|
|
|
|
<div className="flex-1 min-w-0">
|
|
|
|
|
<TrackInfo
|
|
|
|
|
track={player.currentTrack}
|
|
|
|
|
showCover={true}
|
|
|
|
|
coverSize="sm"
|
|
|
|
|
showMetadata={false}
|
|
|
|
|
className="p-0"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Progress Bar - Compact */}
|
|
|
|
|
<div className="hidden md:flex flex-1 max-w-xs">
|
|
|
|
|
<ProgressBar
|
|
|
|
|
currentTime={player.currentTime}
|
|
|
|
|
duration={player.duration}
|
|
|
|
|
onSeek={player.seek}
|
|
|
|
|
className="h-1"
|
|
|
|
|
showTooltip={false}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Controls */}
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<NextPreviousButtons
|
|
|
|
|
onNext={player.next}
|
|
|
|
|
onPrevious={player.previous}
|
|
|
|
|
canGoNext={canGoNext}
|
|
|
|
|
canGoPrevious={canGoPrevious}
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
disabled={!player.currentTrack}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<PlayPauseButton
|
|
|
|
|
isPlaying={player.isPlaying}
|
|
|
|
|
onClick={handlePlayPause}
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="default"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div className="hidden sm:block">
|
|
|
|
|
<VolumeControl
|
|
|
|
|
volume={player.volume}
|
|
|
|
|
muted={player.muted}
|
|
|
|
|
onVolumeChange={player.setVolume}
|
|
|
|
|
onMuteToggle={player.toggleMute}
|
|
|
|
|
showValue={false}
|
|
|
|
|
showSlider={true}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Toggle Button */}
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={onToggle}
|
|
|
|
|
className={cn(
|
2026-01-16 00:56:54 +00:00
|
|
|
'p-2 rounded-lg text-kodo-content-dim dark:text-kodo-content-dim',
|
|
|
|
|
'hover:bg-kodo-void dark:hover:bg-kodo-graphite',
|
2025-12-03 21:56:50 +00:00
|
|
|
'focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2',
|
2025-12-13 02:34:34 +00:00
|
|
|
'transition-colors',
|
2025-12-03 21:56:50 +00:00
|
|
|
)}
|
|
|
|
|
aria-label="Agrandir le lecteur"
|
|
|
|
|
title="Agrandir le lecteur"
|
|
|
|
|
>
|
|
|
|
|
<ChevronUp className="h-5 w-5" aria-hidden="true" />
|
|
|
|
|
<span className="sr-only">Agrandir le lecteur</span>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
{/* Close Button (optional) */}
|
|
|
|
|
{onClose && (
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={onClose}
|
|
|
|
|
className={cn(
|
2026-01-16 00:56:54 +00:00
|
|
|
'p-2 rounded-lg text-kodo-content-dim dark:text-kodo-content-dim',
|
|
|
|
|
'hover:bg-kodo-void dark:hover:bg-kodo-graphite',
|
2025-12-03 21:56:50 +00:00
|
|
|
'focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2',
|
2025-12-13 02:34:34 +00:00
|
|
|
'transition-colors',
|
2025-12-03 21:56:50 +00:00
|
|
|
)}
|
|
|
|
|
aria-label="Fermer le mini lecteur"
|
|
|
|
|
title="Fermer le mini lecteur"
|
|
|
|
|
>
|
|
|
|
|
<X className="h-5 w-5" aria-hidden="true" />
|
|
|
|
|
<span className="sr-only">Fermer le mini lecteur</span>
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default MiniPlayer;
|