[5d6f37a] | 1 | // @mui
|
---|
| 2 | import { alpha } from '@mui/material/styles';
|
---|
| 3 | import Stack from '@mui/material/Stack';
|
---|
| 4 | import ButtonBase from '@mui/material/ButtonBase';
|
---|
| 5 | //
|
---|
| 6 | import SvgColor from '../../svg-color';
|
---|
| 7 |
|
---|
| 8 | // ----------------------------------------------------------------------
|
---|
| 9 |
|
---|
| 10 | type Props = {
|
---|
| 11 | icons: string[];
|
---|
| 12 | options: string[];
|
---|
| 13 | value: string;
|
---|
| 14 | onChange: (newValue: string) => void;
|
---|
| 15 | };
|
---|
| 16 |
|
---|
| 17 | export default function BaseOptions({ icons, options, value, onChange }: Props) {
|
---|
| 18 | return (
|
---|
| 19 | <Stack direction="row" spacing={2}>
|
---|
| 20 | {options.map((option, index) => {
|
---|
| 21 | const selected = value === option;
|
---|
| 22 |
|
---|
| 23 | return (
|
---|
| 24 | <ButtonBase
|
---|
| 25 | key={option}
|
---|
| 26 | onClick={() => onChange(option)}
|
---|
| 27 | sx={{
|
---|
| 28 | width: 1,
|
---|
| 29 | height: 80,
|
---|
| 30 | borderRadius: 1,
|
---|
| 31 | border: (theme) => `solid 1px ${alpha(theme.palette.grey[500], 0.08)}`,
|
---|
| 32 | ...(selected && {
|
---|
| 33 | bgcolor: 'background.paper',
|
---|
| 34 | boxShadow: (theme) =>
|
---|
| 35 | `-24px 8px 24px -4px ${alpha(
|
---|
| 36 | theme.palette.mode === 'light'
|
---|
| 37 | ? theme.palette.grey[500]
|
---|
| 38 | : theme.palette.common.black,
|
---|
| 39 | 0.08
|
---|
| 40 | )}`,
|
---|
| 41 | }),
|
---|
| 42 | '& .svg-color': {
|
---|
| 43 | background: (theme) =>
|
---|
| 44 | `linear-gradient(135deg, ${theme.palette.grey[500]} 0%, ${theme.palette.grey[600]} 100%)`,
|
---|
| 45 | ...(selected && {
|
---|
| 46 | background: (theme) =>
|
---|
| 47 | `linear-gradient(135deg, ${theme.palette.primary.light} 0%, ${theme.palette.primary.main} 100%)`,
|
---|
| 48 | }),
|
---|
| 49 | },
|
---|
| 50 | }}
|
---|
| 51 | >
|
---|
| 52 | <SvgColor src={`/assets/icons/setting/ic_${index === 0 ? icons[0] : icons[1]}.svg`} />
|
---|
| 53 | </ButtonBase>
|
---|
| 54 | );
|
---|
| 55 | })}
|
---|
| 56 | </Stack>
|
---|
| 57 | );
|
---|
| 58 | }
|
---|