Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

functions.web.ts 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { adaptV4Theme, createTheme } from '@mui/material/styles';
  2. import { Palette as Palette1, Typography } from '../ui/types';
  3. import { createColorTokens } from './utils';
  4. declare module '@mui/material/styles' {
  5. // eslint-disable-next-line @typescript-eslint/no-empty-interface
  6. interface Palette extends Palette1 {}
  7. // eslint-disable-next-line @typescript-eslint/no-empty-interface
  8. interface TypographyVariants extends Typography {}
  9. }
  10. interface ThemeProps {
  11. breakpoints: Object;
  12. colorMap: Object;
  13. colors: Object;
  14. font: Object;
  15. shape: Object;
  16. spacing: Array<number>;
  17. typography: Object;
  18. }
  19. /**
  20. * Creates a MUI theme based on local UI tokens.
  21. *
  22. * @param {Object} arg - The ui tokens.
  23. * @returns {Object}
  24. */
  25. export function createWebTheme({ font, colors, colorMap, shape, spacing, typography, breakpoints }: ThemeProps) {
  26. return createTheme(adaptV4Theme({
  27. spacing,
  28. palette: createColorTokens(colorMap, colors),
  29. shape,
  30. // @ts-ignore
  31. typography: {
  32. // @ts-ignore
  33. font,
  34. ...typography
  35. },
  36. breakpoints
  37. }));
  38. }