index.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 _style = require("../../style");
  8. var _internal = require("../../theme/internal");
  9. const genBorderedStyle = token => {
  10. const {
  11. componentCls,
  12. labelBg
  13. } = token;
  14. return {
  15. [`&${componentCls}-bordered`]: {
  16. [`> ${componentCls}-view`]: {
  17. border: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${token.colorSplit}`,
  18. '> table': {
  19. tableLayout: 'auto'
  20. },
  21. [`${componentCls}-row`]: {
  22. borderBottom: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${token.colorSplit}`,
  23. '&:first-child': {
  24. '> th:first-child, > td:first-child': {
  25. borderStartStartRadius: token.borderRadiusLG
  26. }
  27. },
  28. '&:last-child': {
  29. borderBottom: 'none',
  30. '> th:first-child, > td:first-child': {
  31. borderEndStartRadius: token.borderRadiusLG
  32. }
  33. },
  34. [`> ${componentCls}-item-label, > ${componentCls}-item-content`]: {
  35. padding: `${(0, _cssinjs.unit)(token.padding)} ${(0, _cssinjs.unit)(token.paddingLG)}`,
  36. borderInlineEnd: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${token.colorSplit}`,
  37. '&:last-child': {
  38. borderInlineEnd: 'none'
  39. }
  40. },
  41. [`> ${componentCls}-item-label`]: {
  42. color: token.colorTextSecondary,
  43. backgroundColor: labelBg,
  44. '&::after': {
  45. display: 'none'
  46. }
  47. }
  48. }
  49. },
  50. [`&${componentCls}-middle`]: {
  51. [`${componentCls}-row`]: {
  52. [`> ${componentCls}-item-label, > ${componentCls}-item-content`]: {
  53. padding: `${(0, _cssinjs.unit)(token.paddingSM)} ${(0, _cssinjs.unit)(token.paddingLG)}`
  54. }
  55. }
  56. },
  57. [`&${componentCls}-small`]: {
  58. [`${componentCls}-row`]: {
  59. [`> ${componentCls}-item-label, > ${componentCls}-item-content`]: {
  60. padding: `${(0, _cssinjs.unit)(token.paddingXS)} ${(0, _cssinjs.unit)(token.padding)}`
  61. }
  62. }
  63. }
  64. }
  65. };
  66. };
  67. const genDescriptionStyles = token => {
  68. const {
  69. componentCls,
  70. extraColor,
  71. itemPaddingBottom,
  72. itemPaddingEnd,
  73. colonMarginRight,
  74. colonMarginLeft,
  75. titleMarginBottom
  76. } = token;
  77. return {
  78. [componentCls]: Object.assign(Object.assign(Object.assign({}, (0, _style.resetComponent)(token)), genBorderedStyle(token)), {
  79. '&-rtl': {
  80. direction: 'rtl'
  81. },
  82. [`${componentCls}-header`]: {
  83. display: 'flex',
  84. alignItems: 'center',
  85. marginBottom: titleMarginBottom
  86. },
  87. [`${componentCls}-title`]: Object.assign(Object.assign({}, _style.textEllipsis), {
  88. flex: 'auto',
  89. color: token.titleColor,
  90. fontWeight: token.fontWeightStrong,
  91. fontSize: token.fontSizeLG,
  92. lineHeight: token.lineHeightLG
  93. }),
  94. [`${componentCls}-extra`]: {
  95. marginInlineStart: 'auto',
  96. color: extraColor,
  97. fontSize: token.fontSize
  98. },
  99. [`${componentCls}-view`]: {
  100. width: '100%',
  101. borderRadius: token.borderRadiusLG,
  102. table: {
  103. width: '100%',
  104. tableLayout: 'fixed',
  105. borderCollapse: 'collapse'
  106. }
  107. },
  108. [`${componentCls}-row`]: {
  109. '> th, > td': {
  110. paddingBottom: itemPaddingBottom,
  111. paddingInlineEnd: itemPaddingEnd
  112. },
  113. '> th:last-child, > td:last-child': {
  114. paddingInlineEnd: 0
  115. },
  116. '&:last-child': {
  117. borderBottom: 'none',
  118. '> th, > td': {
  119. paddingBottom: 0
  120. }
  121. }
  122. },
  123. [`${componentCls}-item-label`]: {
  124. color: token.labelColor,
  125. fontWeight: 'normal',
  126. fontSize: token.fontSize,
  127. lineHeight: token.lineHeight,
  128. textAlign: 'start',
  129. '&::after': {
  130. content: '":"',
  131. position: 'relative',
  132. top: -0.5,
  133. // magic for position
  134. marginInline: `${(0, _cssinjs.unit)(colonMarginLeft)} ${(0, _cssinjs.unit)(colonMarginRight)}`
  135. },
  136. [`&${componentCls}-item-no-colon::after`]: {
  137. content: '""'
  138. }
  139. },
  140. [`${componentCls}-item-no-label`]: {
  141. '&::after': {
  142. margin: 0,
  143. content: '""'
  144. }
  145. },
  146. [`${componentCls}-item-content`]: {
  147. display: 'table-cell',
  148. flex: 1,
  149. color: token.contentColor,
  150. fontSize: token.fontSize,
  151. lineHeight: token.lineHeight,
  152. wordBreak: 'break-word',
  153. overflowWrap: 'break-word'
  154. },
  155. [`${componentCls}-item`]: {
  156. paddingBottom: 0,
  157. verticalAlign: 'top',
  158. '&-container': {
  159. display: 'flex',
  160. [`${componentCls}-item-label`]: {
  161. display: 'inline-flex',
  162. alignItems: 'baseline'
  163. },
  164. [`${componentCls}-item-content`]: {
  165. display: 'inline-flex',
  166. alignItems: 'baseline',
  167. minWidth: '1em'
  168. }
  169. }
  170. },
  171. '&-middle': {
  172. [`${componentCls}-row`]: {
  173. '> th, > td': {
  174. paddingBottom: token.paddingSM
  175. }
  176. }
  177. },
  178. '&-small': {
  179. [`${componentCls}-row`]: {
  180. '> th, > td': {
  181. paddingBottom: token.paddingXS
  182. }
  183. }
  184. }
  185. })
  186. };
  187. };
  188. const prepareComponentToken = token => ({
  189. labelBg: token.colorFillAlter,
  190. labelColor: token.colorTextTertiary,
  191. titleColor: token.colorText,
  192. titleMarginBottom: token.fontSizeSM * token.lineHeightSM,
  193. itemPaddingBottom: token.padding,
  194. itemPaddingEnd: token.padding,
  195. colonMarginRight: token.marginXS,
  196. colonMarginLeft: token.marginXXS / 2,
  197. contentColor: token.colorText,
  198. extraColor: token.colorText
  199. });
  200. // ============================== Export ==============================
  201. exports.prepareComponentToken = prepareComponentToken;
  202. var _default = exports.default = (0, _internal.genStyleHooks)('Descriptions', token => {
  203. const descriptionToken = (0, _internal.mergeToken)(token, {});
  204. return genDescriptionStyles(descriptionToken);
  205. }, prepareComponentToken);