index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.prepareComponentToken = exports.default = void 0;
  6. var _cssinjs = require("@ant-design/cssinjs");
  7. var _internal = require("../../theme/internal");
  8. // ============================== Styles ==============================
  9. const genBaseStyle = token => {
  10. const {
  11. componentCls,
  12. lineHeightHeading3,
  13. iconCls,
  14. padding,
  15. paddingXL,
  16. paddingXS,
  17. paddingLG,
  18. marginXS,
  19. lineHeight
  20. } = token;
  21. return {
  22. // Result
  23. [componentCls]: {
  24. padding: `${(0, _cssinjs.unit)(token.calc(paddingLG).mul(2).equal())} ${(0, _cssinjs.unit)(paddingXL)}`,
  25. // RTL
  26. '&-rtl': {
  27. direction: 'rtl'
  28. }
  29. },
  30. // Exception Status image
  31. [`${componentCls} ${componentCls}-image`]: {
  32. width: token.imageWidth,
  33. height: token.imageHeight,
  34. margin: 'auto'
  35. },
  36. [`${componentCls} ${componentCls}-icon`]: {
  37. marginBottom: paddingLG,
  38. textAlign: 'center',
  39. [`& > ${iconCls}`]: {
  40. fontSize: token.iconFontSize
  41. }
  42. },
  43. [`${componentCls} ${componentCls}-title`]: {
  44. color: token.colorTextHeading,
  45. fontSize: token.titleFontSize,
  46. lineHeight: lineHeightHeading3,
  47. marginBlock: marginXS,
  48. textAlign: 'center'
  49. },
  50. [`${componentCls} ${componentCls}-subtitle`]: {
  51. color: token.colorTextDescription,
  52. fontSize: token.subtitleFontSize,
  53. lineHeight,
  54. textAlign: 'center'
  55. },
  56. [`${componentCls} ${componentCls}-content`]: {
  57. marginTop: paddingLG,
  58. padding: `${(0, _cssinjs.unit)(paddingLG)} ${(0, _cssinjs.unit)(token.calc(padding).mul(2.5).equal())}`,
  59. backgroundColor: token.colorFillAlter
  60. },
  61. [`${componentCls} ${componentCls}-extra`]: {
  62. margin: token.extraMargin,
  63. textAlign: 'center',
  64. '& > *': {
  65. marginInlineEnd: paddingXS,
  66. '&:last-child': {
  67. marginInlineEnd: 0
  68. }
  69. }
  70. }
  71. };
  72. };
  73. const genStatusIconStyle = token => {
  74. const {
  75. componentCls,
  76. iconCls
  77. } = token;
  78. return {
  79. [`${componentCls}-success ${componentCls}-icon > ${iconCls}`]: {
  80. color: token.resultSuccessIconColor
  81. },
  82. [`${componentCls}-error ${componentCls}-icon > ${iconCls}`]: {
  83. color: token.resultErrorIconColor
  84. },
  85. [`${componentCls}-info ${componentCls}-icon > ${iconCls}`]: {
  86. color: token.resultInfoIconColor
  87. },
  88. [`${componentCls}-warning ${componentCls}-icon > ${iconCls}`]: {
  89. color: token.resultWarningIconColor
  90. }
  91. };
  92. };
  93. const genResultStyle = token => [genBaseStyle(token), genStatusIconStyle(token)];
  94. const getStyle = token => genResultStyle(token);
  95. // ============================== Export ==============================
  96. const prepareComponentToken = token => ({
  97. titleFontSize: token.fontSizeHeading3,
  98. subtitleFontSize: token.fontSize,
  99. iconFontSize: token.fontSizeHeading3 * 3,
  100. extraMargin: `${token.paddingLG}px 0 0 0`
  101. });
  102. exports.prepareComponentToken = prepareComponentToken;
  103. var _default = exports.default = (0, _internal.genStyleHooks)('Result', token => {
  104. const resultInfoIconColor = token.colorInfo;
  105. const resultErrorIconColor = token.colorError;
  106. const resultSuccessIconColor = token.colorSuccess;
  107. const resultWarningIconColor = token.colorWarning;
  108. const resultToken = (0, _internal.mergeToken)(token, {
  109. resultInfoIconColor,
  110. resultErrorIconColor,
  111. resultSuccessIconColor,
  112. resultWarningIconColor,
  113. imageWidth: 250,
  114. imageHeight: 295
  115. });
  116. return [getStyle(resultToken)];
  117. }, prepareComponentToken);