mira, tengo esto: // Importaciones necesarias import { useState, useEffect } from…
- User
mira, tengo esto:
// Importaciones necesarias import { useState, useEffect } from "react"; import { Play, SkipBack, SkipForward, Shuffle, Repeat, Laptop2, Volume1, Maximize2, Home, Search, Library, Menu, // Nuevo X, // Nuevo } from "lucide-react"; import { Button } from "./components/ui/button";
// Interfaz para las canciones interface Song { title: string; artist: string; album: string; added: string; duration: string; albumCover?: string; // URL opcional de la imagen del álbum }
// Lista de canciones const songs: Song[] = [ { title: "Las Piponas (Remix)", artist: "Kris R., Blessed", album: "Las Piponas (Remix)", added: "hace 2 horas", duration: "4:04", albumCover: "https://i.postimg.cc/y8KhsW1p/imagen-blessd.jpg", }, { title: "La Nueva Gerencia", artist: "Arcángel, Farruko", album: "Arca (The Mixtape)", added: "hace 1 día", duration: "4:36", albumCover: "https://i.postimg.cc/y8KhsW1p/imagen-blessd.jpg", }, { title: "Secretos", artist: "C.R.O, Kidd Keo", album: "Secretos", added: "hace 1 día", duration: "2:41", // Sin albumCover para demostrar el placeholder }, { title: "Lo Siento", artist: "Saigo", album: "Lo Siento", added: "hace 1 día", duration: "3:13", // Sin albumCover para demostrar el placeholder }, // Puedes agregar más canciones aquí ];
const SpotifyClone = () => { // Estados para la canción actual y el estado de reproducción const [currentSong, setCurrentSong] = useState(songs[0]); const [isPlaying, setIsPlaying] = useState(false);
// Estado para el sidebar const [isSidebarOpen, setIsSidebarOpen] = useState(true); // Visible por defecto
// Manejadores de eventos const handlePlayPause = () => { setIsPlaying(!isPlaying); };
const handleNextSong = () => { const currentIndex = songs.indexOf(currentSong); const nextIndex = (currentIndex + 1) % songs.length; setCurrentSong(songs[nextIndex]); setIsPlaying(true); // Iniciar reproducción automáticamente };
const handlePreviousSong = () => { const currentIndex = songs.indexOf(currentSong); const previousIndex = (currentIndex - 1 + songs.length) % songs.length; setCurrentSong(songs[previousIndex]); setIsPlaying(true); // Iniciar reproducción automáticamente };
// Opcional: Cerrar el sidebar automáticamente en pantallas pequeñas al cambiar el tamaño useEffect(() => { const handleResize = () => { if (window.innerWidth < 1024) { // lg breakpoint de TailwindCSS es 1024px setIsSidebarOpen(false); } else { setIsSidebarOpen(true); // Mostrar Sidebar en pantallas grandes } };
code// Ejecutar al montar el componente handleResize(); window.addEventListener("resize", handleResize); return () => window.removeEventListener("resize", handleResize); - Assistant