2022-09-13 10:36:00 +03:00
|
|
|
import { createTheme, adaptV4Theme } from '@mui/material/styles';
|
|
|
|
|
|
|
|
|
|
import { Palette as Palette1, Typography } from '../ui/types';
|
2021-04-29 12:24:39 +03:00
|
|
|
|
2021-05-11 11:01:45 +03:00
|
|
|
import { createColorTokens } from './utils';
|
2021-04-29 12:24:39 +03:00
|
|
|
|
2022-09-13 10:36:00 +03:00
|
|
|
declare module '@mui/material/styles' {
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
|
|
|
interface Palette extends Palette1 {}
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
|
|
|
interface TypographyVariants extends Typography {}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 10:04:23 +03:00
|
|
|
interface ThemeProps {
|
|
|
|
|
breakpoints: Object;
|
|
|
|
|
colorMap: Object;
|
|
|
|
|
colors: Object;
|
|
|
|
|
font: Object;
|
|
|
|
|
shape: Object;
|
|
|
|
|
spacing: Array<number>;
|
|
|
|
|
typography: Object;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 12:24:39 +03:00
|
|
|
/**
|
|
|
|
|
* Creates a MUI theme based on local UI tokens.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} arg - The ui tokens.
|
|
|
|
|
* @returns {Object}
|
|
|
|
|
*/
|
2022-09-13 10:36:00 +03:00
|
|
|
export function createWebTheme({ font, colors, colorMap, shape, spacing, typography, breakpoints }: ThemeProps) {
|
|
|
|
|
return createTheme(adaptV4Theme({
|
|
|
|
|
spacing,
|
2021-04-29 12:24:39 +03:00
|
|
|
palette: createColorTokens(colorMap, colors),
|
|
|
|
|
shape,
|
2022-09-13 10:36:00 +03:00
|
|
|
|
|
|
|
|
// @ts-ignore
|
2021-04-29 12:24:39 +03:00
|
|
|
typography: {
|
2022-09-13 10:36:00 +03:00
|
|
|
// @ts-ignore
|
2021-04-29 12:24:39 +03:00
|
|
|
font,
|
|
|
|
|
...typography
|
2021-11-15 10:37:54 +02:00
|
|
|
},
|
|
|
|
|
breakpoints
|
2022-09-13 10:36:00 +03:00
|
|
|
}));
|
2021-10-08 11:05:16 +03:00
|
|
|
}
|
2021-11-15 10:37:54 +02:00
|
|
|
|