import React from "react"; import { Accordion, AccordionSummary, AccordionDetails, Typography } from "@mui/material"; import { Achievement } from "./Achievements"; interface IProps { title: string; achievements: { achievement: Achievement }[]; allAchievements?: { achievement: Achievement }[]; usePadding?: boolean; } function steamCount(achievements: { achievement: Achievement }[]): number { return achievements.filter((entry) => !entry.achievement.NotInSteam).length; } export function AchievementCategory({ title, achievements, allAchievements, usePadding, children, }: React.PropsWithChildren): JSX.Element { /** * For each achievement, we need to display the icon and the detail on the same "row" (icon on the left and detail on * the right). When the viewport is to small, the detail part of some achievements is "moved" to a separate "row". It * looks like this: * * * * * * * * * * * * * Using "minWidth" fixes this issue by setting a min value for the width of each row */ return ( {allAchievements ? ( {title} ({achievements.length}/{allAchievements.length}, {steamCount(achievements)}/ {steamCount(allAchievements)} for Steam) ) : ( {title} ({achievements.length} remaining, {steamCount(achievements)} for Steam) )} {children} ); }