index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import { genComponentStyleHook, mergeToken } from '../../theme/internal';
  2. const genBaseStyle = token => {
  3. const {
  4. componentCls,
  5. commentBg,
  6. commentPaddingBase,
  7. commentNestIndent,
  8. commentFontSizeBase,
  9. commentFontSizeSm,
  10. commentAuthorNameColor,
  11. commentAuthorTimeColor,
  12. commentActionColor,
  13. commentActionHoverColor,
  14. commentActionsMarginBottom,
  15. commentActionsMarginTop,
  16. commentContentDetailPMarginBottom
  17. } = token;
  18. return {
  19. [componentCls]: {
  20. position: 'relative',
  21. backgroundColor: commentBg,
  22. [`${componentCls}-inner`]: {
  23. display: 'flex',
  24. padding: commentPaddingBase
  25. },
  26. [`${componentCls}-avatar`]: {
  27. position: 'relative',
  28. flexShrink: 0,
  29. marginRight: token.marginSM,
  30. cursor: 'pointer',
  31. [`img`]: {
  32. width: '32px',
  33. height: '32px',
  34. borderRadius: '50%'
  35. }
  36. },
  37. [`${componentCls}-content`]: {
  38. position: 'relative',
  39. flex: `1 1 auto`,
  40. minWidth: `1px`,
  41. fontSize: commentFontSizeBase,
  42. wordWrap: 'break-word',
  43. [`&-author`]: {
  44. display: 'flex',
  45. flexWrap: 'wrap',
  46. justifyContent: 'flex-start',
  47. marginBottom: token.marginXXS,
  48. fontSize: commentFontSizeBase,
  49. [`& > a,& > span`]: {
  50. paddingRight: token.paddingXS,
  51. fontSize: commentFontSizeSm,
  52. lineHeight: `18px`
  53. },
  54. [`&-name`]: {
  55. color: commentAuthorNameColor,
  56. fontSize: commentFontSizeBase,
  57. transition: `color ${token.motionDurationSlow}`,
  58. [`> *`]: {
  59. color: commentAuthorNameColor,
  60. [`&:hover`]: {
  61. color: commentAuthorNameColor
  62. }
  63. }
  64. },
  65. [`&-time`]: {
  66. color: commentAuthorTimeColor,
  67. whiteSpace: 'nowrap',
  68. cursor: 'auto'
  69. }
  70. },
  71. [`&-detail p`]: {
  72. marginBottom: commentContentDetailPMarginBottom,
  73. whiteSpace: 'pre-wrap'
  74. }
  75. },
  76. [`${componentCls}-actions`]: {
  77. marginTop: commentActionsMarginTop,
  78. marginBottom: commentActionsMarginBottom,
  79. paddingLeft: 0,
  80. [`> li`]: {
  81. display: 'inline-block',
  82. color: commentActionColor,
  83. [`> span`]: {
  84. marginRight: '10px',
  85. color: commentActionColor,
  86. fontSize: commentFontSizeSm,
  87. cursor: 'pointer',
  88. transition: `color ${token.motionDurationSlow}`,
  89. userSelect: 'none',
  90. [`&:hover`]: {
  91. color: commentActionHoverColor
  92. }
  93. }
  94. }
  95. },
  96. [`${componentCls}-nested`]: {
  97. marginLeft: commentNestIndent
  98. },
  99. '&-rtl': {
  100. direction: 'rtl'
  101. }
  102. }
  103. };
  104. };
  105. export default genComponentStyleHook('Comment', token => {
  106. const commentToken = mergeToken(token, {
  107. commentBg: 'inherit',
  108. commentPaddingBase: `${token.paddingMD}px 0`,
  109. commentNestIndent: `44px`,
  110. commentFontSizeBase: token.fontSize,
  111. commentFontSizeSm: token.fontSizeSM,
  112. commentAuthorNameColor: token.colorTextTertiary,
  113. commentAuthorTimeColor: token.colorTextPlaceholder,
  114. commentActionColor: token.colorTextTertiary,
  115. commentActionHoverColor: token.colorTextSecondary,
  116. commentActionsMarginBottom: 'inherit',
  117. commentActionsMarginTop: token.marginSM,
  118. commentContentDetailPMarginBottom: 'inherit'
  119. });
  120. return [genBaseStyle(commentToken)];
  121. });