index.js 3.2 KB

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