main
Last change
on this file since 5d6f37a was 5d6f37a, checked in by Naum Shapkarovski <naumshapkarovski@…>, 7 weeks ago |
add customer
|
-
Property mode
set to
100644
|
File size:
1.7 KB
|
Line | |
---|
1 | // @mui
|
---|
2 | import { alpha } from '@mui/material/styles';
|
---|
3 | import Box from '@mui/material/Box';
|
---|
4 | import ButtonBase from '@mui/material/ButtonBase';
|
---|
5 | // theme
|
---|
6 | import { primaryPresets } from 'src/theme/options/presets';
|
---|
7 |
|
---|
8 | // ----------------------------------------------------------------------
|
---|
9 |
|
---|
10 | type PresetsOptionsProps = {
|
---|
11 | value: string;
|
---|
12 | onChange: (newValue: string) => void;
|
---|
13 | };
|
---|
14 |
|
---|
15 | export default function PresetsOptions({ value, onChange }: PresetsOptionsProps) {
|
---|
16 | const options = primaryPresets.map((color) => ({
|
---|
17 | name: color.name,
|
---|
18 | value: color.main,
|
---|
19 | }));
|
---|
20 |
|
---|
21 | return (
|
---|
22 | <Box columnGap={2} rowGap={1.5} display="grid" gridTemplateColumns="repeat(3, 1fr)">
|
---|
23 | {options.map((option) => {
|
---|
24 | const selected = value === option.name;
|
---|
25 |
|
---|
26 | return (
|
---|
27 | <ButtonBase
|
---|
28 | key={option.name}
|
---|
29 | onClick={() => onChange(option.name)}
|
---|
30 | sx={{
|
---|
31 | height: 56,
|
---|
32 | borderRadius: 1,
|
---|
33 | border: (theme) => `solid 1px ${alpha(theme.palette.grey[500], 0.08)}`,
|
---|
34 | ...(selected && {
|
---|
35 | borderColor: 'transparent',
|
---|
36 | bgcolor: alpha(option.value, 0.08),
|
---|
37 | }),
|
---|
38 | }}
|
---|
39 | >
|
---|
40 | <Box
|
---|
41 | sx={{
|
---|
42 | width: 12,
|
---|
43 | height: 12,
|
---|
44 | borderRadius: '50%',
|
---|
45 | bgcolor: option.value,
|
---|
46 | transition: (theme) =>
|
---|
47 | theme.transitions.create(['transform'], {
|
---|
48 | duration: theme.transitions.duration.shorter,
|
---|
49 | }),
|
---|
50 | ...(selected && {
|
---|
51 | transform: 'scale(2)',
|
---|
52 | }),
|
---|
53 | }}
|
---|
54 | />
|
---|
55 | </ButtonBase>
|
---|
56 | );
|
---|
57 | })}
|
---|
58 | </Box>
|
---|
59 | );
|
---|
60 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.