You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.8 KiB

2 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. Object.defineProperty(exports, "default", {
  6. enumerable: true,
  7. get: ()=>transformThemeValue
  8. });
  9. const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
  10. function _interopRequireDefault(obj) {
  11. return obj && obj.__esModule ? obj : {
  12. default: obj
  13. };
  14. }
  15. function transformThemeValue(themeSection) {
  16. if ([
  17. "fontSize",
  18. "outline"
  19. ].includes(themeSection)) {
  20. return (value)=>{
  21. if (typeof value === "function") value = value({});
  22. if (Array.isArray(value)) value = value[0];
  23. return value;
  24. };
  25. }
  26. if ([
  27. "fontFamily",
  28. "boxShadow",
  29. "transitionProperty",
  30. "transitionDuration",
  31. "transitionDelay",
  32. "transitionTimingFunction",
  33. "backgroundImage",
  34. "backgroundSize",
  35. "backgroundColor",
  36. "cursor",
  37. "animation",
  38. ].includes(themeSection)) {
  39. return (value)=>{
  40. if (typeof value === "function") value = value({});
  41. if (Array.isArray(value)) value = value.join(", ");
  42. return value;
  43. };
  44. }
  45. // For backwards compatibility reasons, before we switched to underscores
  46. // instead of commas for arbitrary values.
  47. if ([
  48. "gridTemplateColumns",
  49. "gridTemplateRows",
  50. "objectPosition"
  51. ].includes(themeSection)) {
  52. return (value)=>{
  53. if (typeof value === "function") value = value({});
  54. if (typeof value === "string") value = _postcss.default.list.comma(value).join(" ");
  55. return value;
  56. };
  57. }
  58. return (value, opts = {})=>{
  59. if (typeof value === "function") {
  60. value = value(opts);
  61. }
  62. return value;
  63. };
  64. }