[5d6f37a] | 1 | // @mui
|
---|
| 2 | import { alpha } from '@mui/material/styles';
|
---|
| 3 | //
|
---|
| 4 | import { palette as themePalette } from './palette';
|
---|
| 5 |
|
---|
| 6 | // ----------------------------------------------------------------------
|
---|
| 7 |
|
---|
| 8 | interface CustomShadowOptions {
|
---|
| 9 | z1: string;
|
---|
| 10 | z4: string;
|
---|
| 11 | z8: string;
|
---|
| 12 | z12: string;
|
---|
| 13 | z16: string;
|
---|
| 14 | z20: string;
|
---|
| 15 | z24: string;
|
---|
| 16 | //
|
---|
| 17 | primary: string;
|
---|
| 18 | secondary: string;
|
---|
| 19 | info: string;
|
---|
| 20 | success: string;
|
---|
| 21 | warning: string;
|
---|
| 22 | error: string;
|
---|
| 23 | //
|
---|
| 24 | card: string;
|
---|
| 25 | dialog: string;
|
---|
| 26 | dropdown: string;
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | declare module '@mui/material/styles' {
|
---|
| 30 | interface Theme {
|
---|
| 31 | customShadows: CustomShadowOptions;
|
---|
| 32 | }
|
---|
| 33 | interface ThemeOptions {
|
---|
| 34 | customShadows?: CustomShadowOptions;
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | // ----------------------------------------------------------------------
|
---|
| 39 |
|
---|
| 40 | const palette = themePalette('light');
|
---|
| 41 |
|
---|
| 42 | const LIGHT_MODE = palette.grey[500];
|
---|
| 43 |
|
---|
| 44 | const DARK_MODE = palette.common.black;
|
---|
| 45 |
|
---|
| 46 | function createShadow(color: string) {
|
---|
| 47 | const transparent = alpha(color, 0.16);
|
---|
| 48 | return {
|
---|
| 49 | z1: `0 1px 2px 0 ${transparent}`,
|
---|
| 50 | z4: `0 4px 8px 0 ${transparent}`,
|
---|
| 51 | z8: `0 8px 16px 0 ${transparent}`,
|
---|
| 52 | z12: `0 12px 24px -4px ${transparent}`,
|
---|
| 53 | z16: `0 16px 32px -4px ${transparent}`,
|
---|
| 54 | z20: `0 20px 40px -4px ${transparent}`,
|
---|
| 55 | z24: `0 24px 48px 0 ${transparent}`,
|
---|
| 56 | //
|
---|
| 57 | card: `0 0 2px 0 ${alpha(color, 0.2)}, 0 12px 24px -4px ${alpha(color, 0.12)}`,
|
---|
| 58 | dropdown: `0 0 2px 0 ${alpha(color, 0.24)}, -20px 20px 40px -4px ${alpha(color, 0.24)}`,
|
---|
| 59 | dialog: `-40px 40px 80px -8px ${alpha(palette.common.black, 0.24)}`,
|
---|
| 60 | //
|
---|
| 61 | primary: `0 8px 16px 0 ${alpha(palette.primary.main, 0.24)}`,
|
---|
| 62 | info: `0 8px 16px 0 ${alpha(palette.info.main, 0.24)}`,
|
---|
| 63 | secondary: `0 8px 16px 0 ${alpha(palette.secondary.main, 0.24)}`,
|
---|
| 64 | success: `0 8px 16px 0 ${alpha(palette.success.main, 0.24)}`,
|
---|
| 65 | warning: `0 8px 16px 0 ${alpha(palette.warning.main, 0.24)}`,
|
---|
| 66 | error: `0 8px 16px 0 ${alpha(palette.error.main, 0.24)}`,
|
---|
| 67 | };
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | export function customShadows(mode: 'light' | 'dark') {
|
---|
| 71 | return mode === 'light' ? createShadow(LIGHT_MODE) : createShadow(DARK_MODE);
|
---|
| 72 | }
|
---|