import React, { useState } from "react"; import { Typography, Grid, Box, Button, Collapse } from "@mui/material"; import { alpha } from "@mui/material/styles"; import LeaderboardCard from "./LeaderboardCard"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; import ExpandLessIcon from "@mui/icons-material/ExpandLess"; const ITEMS_PER_PAGE = 3; const LeaderboardSection = ({ title, leaderboards }) => { const [showAll, setShowAll] = useState(false); const [expanded, setExpanded] = useState(false); if (!leaderboards || leaderboards.length === 0) return null; const displayedLeaderboards = showAll ? leaderboards : leaderboards.slice(0, ITEMS_PER_PAGE); const toggleExpanded = () => { setShowAll(!showAll); setExpanded(!expanded); }; return ( {title} ({ width: "4px", height: "4px", borderRadius: "100%", backgroundColor: alpha( theme.palette.text.primary, theme.palette.mode === "dark" ? 0.2 : 0.15 ), })} /> {leaderboards.length} {leaderboards.length > ITEMS_PER_PAGE && ( )} {leaderboards.slice(0, ITEMS_PER_PAGE).map((leaderboard, index) => ( ))} {leaderboards.slice(ITEMS_PER_PAGE).map((leaderboard, index) => ( ))} ); }; export default LeaderboardSection;