import React, { useMemo } from 'react'; import { Box, Flex, Grid, Image } from '@chakra-ui/react'; import type { FlexProps, GridProps } from '@chakra-ui/react'; import { useTranslation } from 'next-i18next'; import Avatar from '../Avatar'; type Props = Omit & { list: { icon?: string; label: string | React.ReactNode; value: ValueType }[]; value: ValueType; size?: 'sm' | 'md' | 'lg'; inlineStyles?: FlexProps; onChange: (value: ValueType) => void; }; const LightRowTabs = ({ list, size = 'md', value, onChange, inlineStyles, ...props }: Props) => { const { t } = useTranslation(); const sizeMap = useMemo(() => { switch (size) { case 'sm': return { fontSize: 'xs', outP: '3px', inlineP: 1 }; case 'md': return { fontSize: 'sm', outP: '4px', inlineP: 1 }; case 'lg': return { fontSize: ['sm', 'md'], outP: '5px', inlineP: 2 }; } }, [size]); return ( {list.map((item) => ( { if (value === item.value) return; onChange(item.value); }} > {item.icon && ( <> )} {typeof item.label === 'string' ? t(item.label as any) : item.label} ))} ); }; export default LightRowTabs;