您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions.web.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // @flow
  2. import { createMuiTheme } from '@material-ui/core/styles';
  3. import { createColorTokens } from './utils';
  4. /**
  5. * Creates a MUI theme based on local UI tokens.
  6. *
  7. * @param {Object} arg - The ui tokens.
  8. * @returns {Object}
  9. */
  10. export function createWebTheme({ font, colors, colorMap, shape, spacing, typography, breakpoints }: Object) {
  11. return createMuiTheme({
  12. props: {
  13. // disable ripple effect on buttons globally
  14. MuiButtonBase: {
  15. disableRipple: true
  16. }
  17. },
  18. // use token spacing array
  19. spacing
  20. }, {
  21. palette: createColorTokens(colorMap, colors),
  22. shape,
  23. typography: {
  24. font,
  25. ...typography
  26. },
  27. breakpoints
  28. });
  29. }
  30. /**
  31. * Formats the common styles object to be interpreted as proper CSS.
  32. *
  33. * @param {Object} stylesObj - The styles object.
  34. * @returns {Object}
  35. */
  36. export function formatCommonClasses(stylesObj: Object) {
  37. const formatted = {};
  38. for (const [ key, value ] of Object.entries(stylesObj)) {
  39. formatted[`.${key}`] = value;
  40. }
  41. return formatted;
  42. }