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