index.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = void 0;
  7. var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  8. var _internal = require("../../theme/internal");
  9. var _style = require("../../style");
  10. const genBorderedStyle = token => {
  11. const {
  12. listBorderedCls,
  13. componentCls,
  14. paddingLG,
  15. margin,
  16. padding,
  17. listItemPaddingSM,
  18. marginLG,
  19. borderRadiusLG
  20. } = token;
  21. return {
  22. [`${listBorderedCls}`]: {
  23. border: `${token.lineWidth}px ${token.lineType} ${token.colorBorder}`,
  24. borderRadius: borderRadiusLG,
  25. [`${componentCls}-header,${componentCls}-footer,${componentCls}-item`]: {
  26. paddingInline: paddingLG
  27. },
  28. [`${componentCls}-pagination`]: {
  29. margin: `${margin}px ${marginLG}px`
  30. }
  31. },
  32. [`${listBorderedCls}${componentCls}-sm`]: {
  33. [`${componentCls}-item,${componentCls}-header,${componentCls}-footer`]: {
  34. padding: listItemPaddingSM
  35. }
  36. },
  37. [`${listBorderedCls}${componentCls}-lg`]: {
  38. [`${componentCls}-item,${componentCls}-header,${componentCls}-footer`]: {
  39. padding: `${padding}px ${paddingLG}px`
  40. }
  41. }
  42. };
  43. };
  44. const genResponsiveStyle = token => {
  45. const {
  46. componentCls,
  47. screenSM,
  48. screenMD,
  49. marginLG,
  50. marginSM,
  51. margin
  52. } = token;
  53. return {
  54. [`@media screen and (max-width:${screenMD})`]: {
  55. [`${componentCls}`]: {
  56. [`${componentCls}-item`]: {
  57. [`${componentCls}-item-action`]: {
  58. marginInlineStart: marginLG
  59. }
  60. }
  61. },
  62. [`${componentCls}-vertical`]: {
  63. [`${componentCls}-item`]: {
  64. [`${componentCls}-item-extra`]: {
  65. marginInlineStart: marginLG
  66. }
  67. }
  68. }
  69. },
  70. [`@media screen and (max-width: ${screenSM})`]: {
  71. [`${componentCls}`]: {
  72. [`${componentCls}-item`]: {
  73. flexWrap: 'wrap',
  74. [`${componentCls}-action`]: {
  75. marginInlineStart: marginSM
  76. }
  77. }
  78. },
  79. [`${componentCls}-vertical`]: {
  80. [`${componentCls}-item`]: {
  81. flexWrap: 'wrap-reverse',
  82. [`${componentCls}-item-main`]: {
  83. minWidth: token.contentWidth
  84. },
  85. [`${componentCls}-item-extra`]: {
  86. margin: `auto auto ${margin}px`
  87. }
  88. }
  89. }
  90. }
  91. };
  92. };
  93. // =============================== Base ===============================
  94. const genBaseStyle = token => {
  95. const {
  96. componentCls,
  97. antCls,
  98. controlHeight,
  99. minHeight,
  100. paddingSM,
  101. marginLG,
  102. padding,
  103. listItemPadding,
  104. colorPrimary,
  105. listItemPaddingSM,
  106. listItemPaddingLG,
  107. paddingXS,
  108. margin,
  109. colorText,
  110. colorTextDescription,
  111. motionDurationSlow,
  112. lineWidth
  113. } = token;
  114. return {
  115. [`${componentCls}`]: (0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetComponent)(token)), {
  116. position: 'relative',
  117. '*': {
  118. outline: 'none'
  119. },
  120. [`${componentCls}-header, ${componentCls}-footer`]: {
  121. background: 'transparent',
  122. paddingBlock: paddingSM
  123. },
  124. [`${componentCls}-pagination`]: {
  125. marginBlockStart: marginLG,
  126. textAlign: 'end',
  127. // https://github.com/ant-design/ant-design/issues/20037
  128. [`${antCls}-pagination-options`]: {
  129. textAlign: 'start'
  130. }
  131. },
  132. [`${componentCls}-spin`]: {
  133. minHeight,
  134. textAlign: 'center'
  135. },
  136. [`${componentCls}-items`]: {
  137. margin: 0,
  138. padding: 0,
  139. listStyle: 'none'
  140. },
  141. [`${componentCls}-item`]: {
  142. display: 'flex',
  143. alignItems: 'center',
  144. justifyContent: 'space-between',
  145. padding: listItemPadding,
  146. color: colorText,
  147. [`${componentCls}-item-meta`]: {
  148. display: 'flex',
  149. flex: 1,
  150. alignItems: 'flex-start',
  151. maxWidth: '100%',
  152. [`${componentCls}-item-meta-avatar`]: {
  153. marginInlineEnd: padding
  154. },
  155. [`${componentCls}-item-meta-content`]: {
  156. flex: '1 0',
  157. width: 0,
  158. color: colorText
  159. },
  160. [`${componentCls}-item-meta-title`]: {
  161. marginBottom: token.marginXXS,
  162. color: colorText,
  163. fontSize: token.fontSize,
  164. lineHeight: token.lineHeight,
  165. '> a': {
  166. color: colorText,
  167. transition: `all ${motionDurationSlow}`,
  168. [`&:hover`]: {
  169. color: colorPrimary
  170. }
  171. }
  172. },
  173. [`${componentCls}-item-meta-description`]: {
  174. color: colorTextDescription,
  175. fontSize: token.fontSize,
  176. lineHeight: token.lineHeight
  177. }
  178. },
  179. [`${componentCls}-item-action`]: {
  180. flex: '0 0 auto',
  181. marginInlineStart: token.marginXXL,
  182. padding: 0,
  183. fontSize: 0,
  184. listStyle: 'none',
  185. [`& > li`]: {
  186. position: 'relative',
  187. display: 'inline-block',
  188. padding: `0 ${paddingXS}px`,
  189. color: colorTextDescription,
  190. fontSize: token.fontSize,
  191. lineHeight: token.lineHeight,
  192. textAlign: 'center',
  193. [`&:first-child`]: {
  194. paddingInlineStart: 0
  195. }
  196. },
  197. [`${componentCls}-item-action-split`]: {
  198. position: 'absolute',
  199. insetBlockStart: '50%',
  200. insetInlineEnd: 0,
  201. width: lineWidth,
  202. height: Math.ceil(token.fontSize * token.lineHeight) - token.marginXXS * 2,
  203. transform: 'translateY(-50%)',
  204. backgroundColor: token.colorSplit
  205. }
  206. }
  207. },
  208. [`${componentCls}-empty`]: {
  209. padding: `${padding}px 0`,
  210. color: colorTextDescription,
  211. fontSize: token.fontSizeSM,
  212. textAlign: 'center'
  213. },
  214. [`${componentCls}-empty-text`]: {
  215. padding,
  216. color: token.colorTextDisabled,
  217. fontSize: token.fontSize,
  218. textAlign: 'center'
  219. },
  220. // ============================ without flex ============================
  221. [`${componentCls}-item-no-flex`]: {
  222. display: 'block'
  223. }
  224. }),
  225. [`${componentCls}-grid ${antCls}-col > ${componentCls}-item`]: {
  226. display: 'block',
  227. maxWidth: '100%',
  228. marginBlockEnd: margin,
  229. paddingBlock: 0,
  230. borderBlockEnd: 'none'
  231. },
  232. [`${componentCls}-vertical ${componentCls}-item`]: {
  233. alignItems: 'initial',
  234. [`${componentCls}-item-main`]: {
  235. display: 'block',
  236. flex: 1
  237. },
  238. [`${componentCls}-item-extra`]: {
  239. marginInlineStart: marginLG
  240. },
  241. [`${componentCls}-item-meta`]: {
  242. marginBlockEnd: padding,
  243. [`${componentCls}-item-meta-title`]: {
  244. marginBlockEnd: paddingSM,
  245. color: colorText,
  246. fontSize: token.fontSizeLG,
  247. lineHeight: token.lineHeightLG
  248. }
  249. },
  250. [`${componentCls}-item-action`]: {
  251. marginBlockStart: padding,
  252. marginInlineStart: 'auto',
  253. '> li': {
  254. padding: `0 ${padding}px`,
  255. [`&:first-child`]: {
  256. paddingInlineStart: 0
  257. }
  258. }
  259. }
  260. },
  261. [`${componentCls}-split ${componentCls}-item`]: {
  262. borderBlockEnd: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`,
  263. [`&:last-child`]: {
  264. borderBlockEnd: 'none'
  265. }
  266. },
  267. [`${componentCls}-split ${componentCls}-header`]: {
  268. borderBlockEnd: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`
  269. },
  270. [`${componentCls}-split${componentCls}-empty ${componentCls}-footer`]: {
  271. borderTop: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`
  272. },
  273. [`${componentCls}-loading ${componentCls}-spin-nested-loading`]: {
  274. minHeight: controlHeight
  275. },
  276. [`${componentCls}-split${componentCls}-something-after-last-item ${antCls}-spin-container > ${componentCls}-items > ${componentCls}-item:last-child`]: {
  277. borderBlockEnd: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`
  278. },
  279. [`${componentCls}-lg ${componentCls}-item`]: {
  280. padding: listItemPaddingLG
  281. },
  282. [`${componentCls}-sm ${componentCls}-item`]: {
  283. padding: listItemPaddingSM
  284. },
  285. // Horizontal
  286. [`${componentCls}:not(${componentCls}-vertical)`]: {
  287. [`${componentCls}-item-no-flex`]: {
  288. [`${componentCls}-item-action`]: {
  289. float: 'right'
  290. }
  291. }
  292. }
  293. };
  294. };
  295. // ============================== Export ==============================
  296. var _default = exports.default = (0, _internal.genComponentStyleHook)('List', token => {
  297. const listToken = (0, _internal.mergeToken)(token, {
  298. listBorderedCls: `${token.componentCls}-bordered`,
  299. minHeight: token.controlHeightLG,
  300. listItemPadding: `${token.paddingContentVertical}px ${token.paddingContentHorizontalLG}px`,
  301. listItemPaddingSM: `${token.paddingContentVerticalSM}px ${token.paddingContentHorizontal}px`,
  302. listItemPaddingLG: `${token.paddingContentVerticalLG}px ${token.paddingContentHorizontalLG}px`
  303. });
  304. return [genBaseStyle(listToken), genBorderedStyle(listToken), genResponsiveStyle(listToken)];
  305. }, {
  306. contentWidth: 220
  307. });