import { getColors } from '@/themes/getColors'; import { Box } from '@mui/material'; function getColorStyle({ color, theme }: { color: 'primary' | 'secondary' | 'error' | 'warning' | 'info' | 'success'; theme: any; }): any { const colors = getColors(theme, color); // @ts-ignore const { lighter, main, dark } = colors; return { '& .dot': { backgroundColor: main }, '&:hover': { backgroundColor: lighter }, '&.Mui-focusVisible': { outline: `2px solid ${dark}`, outlineOffset: -4 } }; } function getSizeStyle(size: 'small' | 'medium' | 'large') { switch (size) { case 'small': return { size: 16, dotSize: 8, position: 3 }; case 'large': return { size: 24, dotSize: 12, position: 5 }; case 'medium': default: return { size: 20, dotSize: 10, position: 4 }; } } function radioStyle(size: 'small' | 'medium' | 'large') { const sizes = getSizeStyle(size); return { '& .icon': { width: sizes.size, height: sizes.size, '& .dot': { width: sizes.dotSize, height: sizes.dotSize, top: sizes.position, left: sizes.position } } }; } function Radio(theme: any): any { const { palette } = theme; return { MuiRadio: { defaultProps: { className: 'size-small', icon: ( ), checkedIcon: ( ) }, styleOverrides: { root: { color: palette.secondary[300], '&.size-small': { ...radioStyle('small') }, '&.size-medium': { ...radioStyle('medium') }, '&.size-large': { ...radioStyle('large') } }, colorPrimary: getColorStyle({ color: 'primary', theme }), colorSecondary: getColorStyle({ color: 'secondary', theme }), colorSuccess: getColorStyle({ color: 'success', theme }), colorWarning: getColorStyle({ color: 'warning', theme }), colorInfo: getColorStyle({ color: 'info', theme }), colorError: getColorStyle({ color: 'error', theme }) } } }; } export { Radio };