Changeset cb4a1da for frontend/src/components
- Timestamp:
- 02/05/26 20:52:11 (5 months ago)
- Branches:
- main
- Children:
- 2ce7c1e
- Parents:
- 694fc25
- Location:
- frontend/src/components
- Files:
-
- 4 added
- 1 edited
-
Sidebar.tsx (added)
-
search/AlbumResult.tsx (added)
-
search/SongResult.tsx (added)
-
search/UserResult.tsx (added)
-
userProfile/UserListModal.tsx (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/components/userProfile/UserListModal.tsx
r694fc25 rcb4a1da 3 3 4 4 interface ModalProps { 5 title: string;6 users: BaseNonAdminUser[];7 onClose: () => void;8 onFollowToggle: (targetUsername: string) => Promise<void>;5 title: string; 6 users: BaseNonAdminUser[]; 7 onClose: () => void; 8 onFollowToggle: (targetUsername: string) => Promise<void>; 9 9 } 10 10 11 11 const UserListModal = ({ 12 title,13 users,14 onClose,15 onFollowToggle,12 title, 13 users, 14 onClose, 15 onFollowToggle, 16 16 }: ModalProps) => { 17 const navigate = useNavigate();18 const baseURL = import.meta.env.VITE_API_BASE_URL;17 const navigate = useNavigate(); 18 const baseURL = import.meta.env.VITE_API_BASE_URL; 19 19 20 return (21 <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm">22 <div className="bg-white rounded-xl shadow-2xl w-full max-w-md max-h-[70vh] flex flex-col">23 <div className="p-4 border-b flex justify-between items-center">24 <h2 className="text-xl font-bold">{title}</h2>25 <button26 onClick={onClose}27 className="text-gray-500 hover:text-black text-2xl cursor-pointer"28 >29 ×30 </button>31 </div>20 return ( 21 <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm"> 22 <div className="bg-white rounded-xl shadow-2xl w-full max-w-md max-h-[70vh] flex flex-col"> 23 <div className="p-4 border-b flex justify-between items-center"> 24 <h2 className="text-xl font-bold">{title}</h2> 25 <button 26 onClick={onClose} 27 className="text-gray-500 hover:text-black text-2xl cursor-pointer" 28 > 29 × 30 </button> 31 </div> 32 32 33 <div className="overflow-y-auto p-4 flex-1">34 {users.length === 0 ? (35 <p className="text-center text-gray-500 py-8">No users found.</p>36 ) : (37 users.map((u) => (38 <div39 key={u.username}40 className="flex items-center justify-between p-3 hover:bg-gray-50 rounded-lg transition-colors"41 >42 <div43 className="flex items-center gap-4 cursor-pointer flex-1"44 onClick={() => {45 onClose();46 navigate(`/users/${u.username}`);47 }}48 >49 <div className="w-10 h-10 rounded-full bg-blue-100 overflow-hidden shrink-0 flex items-center justify-center">50 {u.profilePhoto ? (51 <img52 src={`${baseURL}/${u.profilePhoto}`}53 className="w-full h-full object-cover"54 alt=""55 />56 ) : (57 <span className="text-blue-600 font-bold">58 {u.fullName.charAt(0)}59 </span>60 )}61 </div>62 <p className="font-semibold text-gray-900">{u.fullName}</p>63 </div>33 <div className="overflow-y-auto p-4 flex-1"> 34 {users.length === 0 ? ( 35 <p className="text-center text-gray-500 py-8">No users found.</p> 36 ) : ( 37 users.map((u) => ( 38 <div 39 key={u.username} 40 className="flex items-center justify-between p-3 hover:bg-gray-50 rounded-lg transition-colors" 41 > 42 <div 43 className="flex items-center gap-4 cursor-pointer flex-1" 44 onClick={() => { 45 onClose(); 46 navigate(`/users/${u.username}`); 47 }} 48 > 49 <div className="w-10 h-10 rounded-full bg-blue-100 overflow-hidden shrink-0 flex items-center justify-center"> 50 {u.profilePhoto ? ( 51 <img 52 src={`${baseURL}/${u.profilePhoto}`} 53 className="w-full h-full object-cover" 54 alt="" 55 /> 56 ) : ( 57 <span className="text-blue-600 font-bold"> 58 {u.fullName.charAt(0)} 59 </span> 60 )} 61 </div> 62 <p className="font-semibold text-gray-900">{u.fullName}</p> 63 </div> 64 64 65 <button66 onClick={() => onFollowToggle(u.username)}67 className={`px-4 py-1 text-sm font-medium rounded-md transition-colors cursor-pointer ${68 u.isFollowedByCurrentUser69 ? "bg-gray-200 text-gray-700 hover:bg-gray-300"70 : "bg-blue-500 text-white hover:bg-blue-600"71 }`}72 >73 {u.isFollowedByCurrentUser ? "Unfollow" : "Follow"}74 </button>75 </div>76 ))77 )}78 </div>79 </div>80 <div className="absolute inset-0 -z-10" onClick={onClose}></div>81 </div>82 );65 <button 66 onClick={() => onFollowToggle(u.username)} 67 className={`px-4 py-1 text-sm font-medium rounded-md transition-colors cursor-pointer ${ 68 u.isFollowedByCurrentUser 69 ? "bg-gray-200 text-gray-700 hover:bg-gray-300" 70 : "bg-blue-500 text-white hover:bg-blue-600" 71 }`} 72 > 73 {u.isFollowedByCurrentUser ? "Unfollow" : "Follow"} 74 </button> 75 </div> 76 )) 77 )} 78 </div> 79 </div> 80 <div className="absolute inset-0 -z-10" onClick={onClose}></div> 81 </div> 82 ); 83 83 }; 84 84
Note:
See TracChangeset
for help on using the changeset viewer.
