list.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import { clearFix, textEllipsis } from '../../style';
  3. const genListStyle = token => {
  4. const {
  5. componentCls,
  6. antCls,
  7. iconCls,
  8. fontSize,
  9. lineHeight
  10. } = token;
  11. const itemCls = `${componentCls}-list-item`;
  12. const actionsCls = `${itemCls}-actions`;
  13. const actionCls = `${itemCls}-action`;
  14. const listItemHeightSM = Math.round(fontSize * lineHeight);
  15. return {
  16. [`${componentCls}-wrapper`]: {
  17. [`${componentCls}-list`]: _extends(_extends({}, clearFix()), {
  18. lineHeight: token.lineHeight,
  19. [itemCls]: {
  20. position: 'relative',
  21. height: token.lineHeight * fontSize,
  22. marginTop: token.marginXS,
  23. fontSize,
  24. display: 'flex',
  25. alignItems: 'center',
  26. transition: `background-color ${token.motionDurationSlow}`,
  27. '&:hover': {
  28. backgroundColor: token.controlItemBgHover
  29. },
  30. [`${itemCls}-name`]: _extends(_extends({}, textEllipsis), {
  31. padding: `0 ${token.paddingXS}px`,
  32. lineHeight,
  33. flex: 'auto',
  34. transition: `all ${token.motionDurationSlow}`
  35. }),
  36. [actionsCls]: {
  37. [actionCls]: {
  38. opacity: 0
  39. },
  40. [`${actionCls}${antCls}-btn-sm`]: {
  41. height: listItemHeightSM,
  42. border: 0,
  43. lineHeight: 1,
  44. // FIXME: should not override small button
  45. '> span': {
  46. transform: 'scale(1)'
  47. }
  48. },
  49. [`
  50. ${actionCls}:focus,
  51. &.picture ${actionCls}
  52. `]: {
  53. opacity: 1
  54. },
  55. [iconCls]: {
  56. color: token.colorTextDescription,
  57. transition: `all ${token.motionDurationSlow}`
  58. },
  59. [`&:hover ${iconCls}`]: {
  60. color: token.colorText
  61. }
  62. },
  63. [`${componentCls}-icon ${iconCls}`]: {
  64. color: token.colorTextDescription,
  65. fontSize
  66. },
  67. [`${itemCls}-progress`]: {
  68. position: 'absolute',
  69. bottom: -token.uploadProgressOffset,
  70. width: '100%',
  71. paddingInlineStart: fontSize + token.paddingXS,
  72. fontSize,
  73. lineHeight: 0,
  74. pointerEvents: 'none',
  75. '> div': {
  76. margin: 0
  77. }
  78. }
  79. },
  80. [`${itemCls}:hover ${actionCls}`]: {
  81. opacity: 1,
  82. color: token.colorText
  83. },
  84. [`${itemCls}-error`]: {
  85. color: token.colorError,
  86. [`${itemCls}-name, ${componentCls}-icon ${iconCls}`]: {
  87. color: token.colorError
  88. },
  89. [actionsCls]: {
  90. [`${iconCls}, ${iconCls}:hover`]: {
  91. color: token.colorError
  92. },
  93. [actionCls]: {
  94. opacity: 1
  95. }
  96. }
  97. },
  98. [`${componentCls}-list-item-container`]: {
  99. transition: `opacity ${token.motionDurationSlow}, height ${token.motionDurationSlow}`,
  100. // For smooth removing animation
  101. '&::before': {
  102. display: 'table',
  103. width: 0,
  104. height: 0,
  105. content: '""'
  106. }
  107. }
  108. })
  109. }
  110. };
  111. };
  112. export default genListStyle;