| 1 | interface SidebarProps {
|
|---|
| 2 | isOpen: boolean;
|
|---|
| 3 | onClose: () => void;
|
|---|
| 4 | }
|
|---|
| 5 |
|
|---|
| 6 | const Sidebar = ({ isOpen, onClose }: SidebarProps) => {
|
|---|
| 7 | // mock data for recently listened songs
|
|---|
| 8 | const recentlyListened = [
|
|---|
| 9 | { id: 1, title: "Song One", artist: "Artist A", cover: "/favicon.png" },
|
|---|
| 10 | { id: 2, title: "Song Two", artist: "Artist B", cover: "/favicon.png" },
|
|---|
| 11 | { id: 3, title: "Song Three", artist: "Artist C", cover: "/favicon.png" },
|
|---|
| 12 | { id: 4, title: "Song Four", artist: "Artist D", cover: "/favicon.png" },
|
|---|
| 13 | { id: 5, title: "Song Five", artist: "Artist E", cover: "/favicon.png" },
|
|---|
| 14 | ];
|
|---|
| 15 |
|
|---|
| 16 | // mock data for my playlists
|
|---|
| 17 | const playlists = [
|
|---|
| 18 | { id: 1, name: "My Favorites", songCount: 25 },
|
|---|
| 19 | { id: 2, name: "Workout Mix", songCount: 18 },
|
|---|
| 20 | { id: 3, name: "Chill Vibes", songCount: 32 },
|
|---|
| 21 | { id: 4, name: "Party Hits", songCount: 45 },
|
|---|
| 22 | ];
|
|---|
| 23 |
|
|---|
| 24 | return (
|
|---|
| 25 | <div
|
|---|
| 26 | className={`fixed left-0 top-0 h-full bg-[#121212] border-r border-white/10 transition-transform duration-300 ease-in-out z-40 ${
|
|---|
| 27 | isOpen ? "translate-x-0" : "-translate-x-full"
|
|---|
| 28 | } w-64 overflow-y-auto`}
|
|---|
| 29 | >
|
|---|
| 30 | <div className="p-6">
|
|---|
| 31 | {/* Sidebar Header */}
|
|---|
| 32 | <div className="flex justify-between items-center mb-6 pt-2">
|
|---|
| 33 | <h2 className="text-xl font-bold text-white">Library</h2>
|
|---|
| 34 | <button
|
|---|
| 35 | onClick={onClose}
|
|---|
| 36 | className="text-gray-400 hover:text-white transition-colors"
|
|---|
| 37 | aria-label="Close sidebar"
|
|---|
| 38 | >
|
|---|
| 39 | <svg
|
|---|
| 40 | className="w-6 h-6"
|
|---|
| 41 | fill="none"
|
|---|
| 42 | stroke="currentColor"
|
|---|
| 43 | viewBox="0 0 24 24"
|
|---|
| 44 | >
|
|---|
| 45 | <path
|
|---|
| 46 | strokeLinecap="round"
|
|---|
| 47 | strokeLinejoin="round"
|
|---|
| 48 | strokeWidth={2}
|
|---|
| 49 | d="M6 18L18 6M6 6l12 12"
|
|---|
| 50 | />
|
|---|
| 51 | </svg>
|
|---|
| 52 | </button>
|
|---|
| 53 | </div>
|
|---|
| 54 |
|
|---|
| 55 | {/* Recently Listened */}
|
|---|
| 56 | <div className="mb-8">
|
|---|
| 57 | <h3 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mb-4">
|
|---|
| 58 | Recently Played
|
|---|
| 59 | </h3>
|
|---|
| 60 | <div className="space-y-3">
|
|---|
| 61 | {recentlyListened.map((song) => (
|
|---|
| 62 | <div
|
|---|
| 63 | key={song.id}
|
|---|
| 64 | className="flex items-center gap-3 p-2 rounded-lg hover:bg-white/5 cursor-pointer transition-colors"
|
|---|
| 65 | >
|
|---|
| 66 | <img
|
|---|
| 67 | src={song.cover}
|
|---|
| 68 | alt={song.title}
|
|---|
| 69 | className="w-10 h-10 rounded object-cover"
|
|---|
| 70 | />
|
|---|
| 71 | <div className="flex-1 min-w-0">
|
|---|
| 72 | <p className="text-sm font-medium text-white truncate">
|
|---|
| 73 | {song.title}
|
|---|
| 74 | </p>
|
|---|
| 75 | <p className="text-xs text-gray-400 truncate">
|
|---|
| 76 | {song.artist}
|
|---|
| 77 | </p>
|
|---|
| 78 | </div>
|
|---|
| 79 | </div>
|
|---|
| 80 | ))}
|
|---|
| 81 | </div>
|
|---|
| 82 | </div>
|
|---|
| 83 |
|
|---|
| 84 | {/* Playlists */}
|
|---|
| 85 | <div>
|
|---|
| 86 | <h3 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mb-4">
|
|---|
| 87 | Your Playlists
|
|---|
| 88 | </h3>
|
|---|
| 89 | <div className="space-y-2">
|
|---|
| 90 | {playlists.map((playlist) => (
|
|---|
| 91 | <div
|
|---|
| 92 | key={playlist.id}
|
|---|
| 93 | className="flex items-center justify-between p-3 rounded-lg hover:bg-white/5 cursor-pointer transition-colors"
|
|---|
| 94 | >
|
|---|
| 95 | <div className="flex items-center gap-3">
|
|---|
| 96 | <div className="w-10 h-10 bg-linear-to-br from-purple-500 to-pink-500 rounded flex items-center justify-center">
|
|---|
| 97 | <svg
|
|---|
| 98 | className="w-5 h-5 text-white"
|
|---|
| 99 | fill="currentColor"
|
|---|
| 100 | viewBox="0 0 20 20"
|
|---|
| 101 | >
|
|---|
| 102 | <path d="M18 3a1 1 0 00-1.196-.98l-10 2A1 1 0 006 5v9.114A4.369 4.369 0 005 14c-1.657 0-3 .895-3 2s1.343 2 3 2 3-.895 3-2V7.82l8-1.6v5.894A4.37 4.37 0 0015 12c-1.657 0-3 .895-3 2s1.343 2 3 2 3-.895 3-2V3z" />
|
|---|
| 103 | </svg>
|
|---|
| 104 | </div>
|
|---|
| 105 | <div>
|
|---|
| 106 | <p className="text-sm font-medium text-white">
|
|---|
| 107 | {playlist.name}
|
|---|
| 108 | </p>
|
|---|
| 109 | <p className="text-xs text-gray-400">
|
|---|
| 110 | {playlist.songCount} songs
|
|---|
| 111 | </p>
|
|---|
| 112 | </div>
|
|---|
| 113 | </div>
|
|---|
| 114 | </div>
|
|---|
| 115 | ))}
|
|---|
| 116 | </div>
|
|---|
| 117 | </div>
|
|---|
| 118 | </div>
|
|---|
| 119 | </div>
|
|---|
| 120 | );
|
|---|
| 121 | };
|
|---|
| 122 |
|
|---|
| 123 | export default Sidebar;
|
|---|