import { createStyles, UnstyledButton, Group, ThemeIcon, Collapse, Box, Text, useMantineColorScheme, } from '@mantine/core'; import { type ReactNode, useState } from 'react'; import { VscChevronDown } from 'react-icons/vsc'; const useStyles = createStyles((theme, { opened }: { opened: boolean }) => ({ control: { display: 'block', width: '100%', padding: theme.spacing.xs, color: theme.colorScheme === 'dark' ? theme.colors.dark![0] : theme.black, backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark![7] : 'transparent', borderRadius: theme.radius.xs, '&:hover': { backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark![5] : theme.colors.gray![2], color: theme.colorScheme === 'dark' ? theme.white : theme.black, }, }, icon: { transition: 'transform 150ms ease', transform: opened ? 'rotate(180deg)' : 'rotate(0deg)', }, })); export function Section({ title, icon, padded = false, dense = false, defaultClosed = false, children, }: { title: string; icon?: JSX.Element; padded?: boolean; dense?: boolean; defaultClosed?: boolean; children: ReactNode; }) { const [opened, setOpened] = useState(!defaultClosed); const { colorScheme } = useMantineColorScheme(); const { classes } = useStyles({ opened }); return ( setOpened((o) => !o)}> {icon ? ( {icon} ) : null} {title} {padded ? ( {children} ) : ( children )} ); }