|
1 |
| -import '../../style/index.less'; |
2 |
| -import './index.less'; |
| 1 | +import type { FullToken, GenerateStyle } from '../../theme/internal'; |
| 2 | +import { genComponentStyleHook, mergeToken } from '../../theme/internal'; |
| 3 | + |
| 4 | +export interface ComponentToken {} |
| 5 | + |
| 6 | +type CommentToken = FullToken<'Comment'> & { |
| 7 | + commentBg: string; |
| 8 | + commentPaddingBase: string; |
| 9 | + commentNestIndent: string; |
| 10 | + commentFontSizeBase: number; |
| 11 | + commentFontSizeSm: number; |
| 12 | + commentAuthorNameColor: string; |
| 13 | + commentAuthorTimeColor: string; |
| 14 | + commentActionColor: string; |
| 15 | + commentActionHoverColor: string; |
| 16 | + commentActionsMarginBottom: string; |
| 17 | + commentActionsMarginTop: number; |
| 18 | + commentContentDetailPMarginBottom: string; |
| 19 | +}; |
| 20 | + |
| 21 | +const genBaseStyle: GenerateStyle<CommentToken> = token => { |
| 22 | + const { |
| 23 | + componentCls, |
| 24 | + commentBg, |
| 25 | + commentPaddingBase, |
| 26 | + commentNestIndent, |
| 27 | + commentFontSizeBase, |
| 28 | + commentFontSizeSm, |
| 29 | + commentAuthorNameColor, |
| 30 | + commentAuthorTimeColor, |
| 31 | + commentActionColor, |
| 32 | + commentActionHoverColor, |
| 33 | + commentActionsMarginBottom, |
| 34 | + commentActionsMarginTop, |
| 35 | + commentContentDetailPMarginBottom, |
| 36 | + } = token; |
| 37 | + |
| 38 | + return { |
| 39 | + [componentCls]: { |
| 40 | + position: 'relative', |
| 41 | + backgroundColor: commentBg, |
| 42 | + |
| 43 | + [`${componentCls}-inner`]: { |
| 44 | + display: 'flex', |
| 45 | + padding: commentPaddingBase, |
| 46 | + }, |
| 47 | + |
| 48 | + [`${componentCls}-avatar`]: { |
| 49 | + position: 'relative', |
| 50 | + flexShrink: 0, |
| 51 | + marginRight: token.marginSM, |
| 52 | + cursor: 'pointer', |
| 53 | + |
| 54 | + [`img`]: { |
| 55 | + width: '32px', |
| 56 | + height: '32px', |
| 57 | + borderRadius: '50%', |
| 58 | + }, |
| 59 | + }, |
| 60 | + |
| 61 | + [`${componentCls}-content`]: { |
| 62 | + position: 'relative', |
| 63 | + flex: `1 1 auto`, |
| 64 | + minWidth: `1px`, |
| 65 | + fontSize: commentFontSizeBase, |
| 66 | + wordWrap: 'break-word', |
| 67 | + |
| 68 | + [`&-author`]: { |
| 69 | + display: 'flex', |
| 70 | + flexWrap: 'wrap', |
| 71 | + justifyContent: 'flex-start', |
| 72 | + marginBottom: token.marginXXS, |
| 73 | + fontSize: commentFontSizeBase, |
| 74 | + |
| 75 | + [`& > a,& > span`]: { |
| 76 | + paddingRight: token.paddingXS, |
| 77 | + fontSize: commentFontSizeSm, |
| 78 | + lineHeight: `18px`, |
| 79 | + }, |
| 80 | + |
| 81 | + [`&-name`]: { |
| 82 | + color: commentAuthorNameColor, |
| 83 | + fontSize: commentFontSizeBase, |
| 84 | + transition: `color ${token.motionDurationSlow}`, |
| 85 | + |
| 86 | + [`> *`]: { |
| 87 | + color: commentAuthorNameColor, |
| 88 | + |
| 89 | + [`&:hover`]: { |
| 90 | + color: commentAuthorNameColor, |
| 91 | + }, |
| 92 | + }, |
| 93 | + }, |
| 94 | + |
| 95 | + [`&-time`]: { |
| 96 | + color: commentAuthorTimeColor, |
| 97 | + whiteSpace: 'nowrap', |
| 98 | + cursor: 'auto', |
| 99 | + }, |
| 100 | + }, |
| 101 | + |
| 102 | + [`&-detail p`]: { |
| 103 | + marginBottom: commentContentDetailPMarginBottom, |
| 104 | + whiteSpace: 'pre-wrap', |
| 105 | + }, |
| 106 | + }, |
| 107 | + |
| 108 | + [`${componentCls}-actions`]: { |
| 109 | + marginTop: commentActionsMarginTop, |
| 110 | + marginBottom: commentActionsMarginBottom, |
| 111 | + paddingLeft: 0, |
| 112 | + |
| 113 | + [`> li`]: { |
| 114 | + display: 'inline-block', |
| 115 | + color: commentActionColor, |
| 116 | + |
| 117 | + [`> span`]: { |
| 118 | + marginRight: '10px', |
| 119 | + color: commentActionColor, |
| 120 | + fontSize: commentFontSizeSm, |
| 121 | + cursor: 'pointer', |
| 122 | + transition: `color ${token.motionDurationSlow}`, |
| 123 | + userSelect: 'none', |
| 124 | + |
| 125 | + [`&:hover`]: { |
| 126 | + color: commentActionHoverColor, |
| 127 | + }, |
| 128 | + }, |
| 129 | + }, |
| 130 | + }, |
| 131 | + |
| 132 | + [`${componentCls}-nested`]: { |
| 133 | + marginLeft: commentNestIndent, |
| 134 | + }, |
| 135 | + |
| 136 | + '&-rtl': { |
| 137 | + direction: 'rtl', |
| 138 | + }, |
| 139 | + }, |
| 140 | + }; |
| 141 | +}; |
| 142 | + |
| 143 | +export default genComponentStyleHook('Comment', token => { |
| 144 | + console.log(token); |
| 145 | + const commentToken = mergeToken<CommentToken>(token, { |
| 146 | + commentBg: 'inherit', |
| 147 | + commentPaddingBase: `${token.paddingMD}px 0`, |
| 148 | + commentNestIndent: `44px`, |
| 149 | + commentFontSizeBase: token.fontSize, |
| 150 | + commentFontSizeSm: token.fontSizeSM, |
| 151 | + commentAuthorNameColor: token.colorTextTertiary, |
| 152 | + commentAuthorTimeColor: token.colorTextPlaceholder, |
| 153 | + commentActionColor: token.colorTextTertiary, |
| 154 | + commentActionHoverColor: token.colorTextSecondary, |
| 155 | + commentActionsMarginBottom: 'inherit', |
| 156 | + commentActionsMarginTop: token.marginSM, |
| 157 | + commentContentDetailPMarginBottom: 'inherit', |
| 158 | + }); |
| 159 | + |
| 160 | + return [genBaseStyle(commentToken)]; |
| 161 | +}); |
0 commit comments