|
| 1 | +import type { FullToken, GenerateStyle } from '../../theme/internal'; |
| 2 | +import { genComponentStyleHook, mergeToken } from '../../theme/internal'; |
| 3 | + |
| 4 | +/** Component only token. Which will handle additional calculation of alias token */ |
| 5 | +export interface ComponentToken { |
| 6 | + // Component token here |
| 7 | +} |
| 8 | + |
| 9 | +export interface FieldToken extends FullToken<'Field'> {} |
| 10 | +const genFieldStyle: GenerateStyle<FieldToken> = (token) => { |
| 11 | + const { componentCls } = token; |
| 12 | + |
| 13 | + return [ |
| 14 | + { |
| 15 | + [`${componentCls}-container`]: { |
| 16 | + display: 'flex', |
| 17 | + flexDirection: 'column', |
| 18 | + gap: 8, |
| 19 | + color: token.colorTextTertiary, |
| 20 | + lineHeight: token.lineHeightLG, |
| 21 | + overflow: 'hidden', |
| 22 | + position: 'relative', |
| 23 | + |
| 24 | + [`${componentCls}-wrapper`]: { |
| 25 | + display: 'flex', |
| 26 | + flexDirection: 'row', |
| 27 | + justifyContent: 'space-between', |
| 28 | + alignItems: 'center', |
| 29 | + gap: 8, |
| 30 | + overflow: 'hidden', |
| 31 | + |
| 32 | + [`${componentCls}-content-wrapper`]: { |
| 33 | + overflow: 'hidden', |
| 34 | + flex: 1, |
| 35 | + |
| 36 | + [`${componentCls}-content`]: { |
| 37 | + marginBottom: 0, |
| 38 | + color: token.colorText, |
| 39 | + }, |
| 40 | + }, |
| 41 | + }, |
| 42 | + |
| 43 | + [`&${componentCls}-placeholder`]: { |
| 44 | + [`${componentCls}-wrapper`]: { |
| 45 | + [`${componentCls}-content-wrapper`]: { |
| 46 | + [`${componentCls}-content`]: { |
| 47 | + color: token.colorTextLight4, |
| 48 | + }, |
| 49 | + }, |
| 50 | + }, |
| 51 | + }, |
| 52 | + |
| 53 | + [`${componentCls}-label`]: { |
| 54 | + fontSize: token.fontSizeSM, |
| 55 | + lineHeight: token.lineHeightSM, |
| 56 | + color: token.colorTextLight4, |
| 57 | + paddingLeft: token.paddingSM, |
| 58 | + paddingRight: token.paddingSM, |
| 59 | + paddingTop: token.paddingXXS, |
| 60 | + top: token.paddingXXS, |
| 61 | + whiteSpace: 'nowrap', |
| 62 | + textOverflow: 'ellipsis', |
| 63 | + overflow: 'hidden', |
| 64 | + position: 'relative', |
| 65 | + }, |
| 66 | + |
| 67 | + // Size |
| 68 | + |
| 69 | + [`&${componentCls}-size-small`]: { |
| 70 | + [`${componentCls}-wrapper`]: { |
| 71 | + padding: `${token.paddingContentVerticalSM}px ${token.paddingContentHorizontal}px`, |
| 72 | + }, |
| 73 | + }, |
| 74 | + |
| 75 | + [`&${componentCls}-size-medium`]: { |
| 76 | + [`${componentCls}-wrapper`]: { |
| 77 | + padding: `${token.paddingContentVertical}px ${token.paddingContentHorizontal}px`, |
| 78 | + }, |
| 79 | + }, |
| 80 | + |
| 81 | + [`&${componentCls}-with-label`]: { |
| 82 | + [`${componentCls}-placeholder`]: { |
| 83 | + color: token.colorText, |
| 84 | + }, |
| 85 | + |
| 86 | + [`${componentCls}-wrapper`]: { |
| 87 | + padding: `${token.paddingContentVertical - 2}px ${token.paddingSM}px ${ |
| 88 | + token.paddingContentVertical |
| 89 | + }px`, |
| 90 | + }, |
| 91 | + }, |
| 92 | + |
| 93 | + // Border |
| 94 | + [`&${componentCls}-border-square`]: { |
| 95 | + borderRadius: 0, |
| 96 | + }, |
| 97 | + |
| 98 | + [`&${componentCls}-border-round`]: { |
| 99 | + borderRadius: token.controlHeightLG + token.borderRadiusLG, |
| 100 | + }, |
| 101 | + |
| 102 | + [`&${componentCls}-border-default`]: { |
| 103 | + borderRadius: token.borderRadius, |
| 104 | + }, |
| 105 | + |
| 106 | + // Background |
| 107 | + [`&${componentCls}-bg-default`]: { |
| 108 | + background: token.colorBgSecondary, |
| 109 | + }, |
| 110 | + |
| 111 | + [`&${componentCls}-bg-transparent`]: { |
| 112 | + background: 'transparent', |
| 113 | + }, |
| 114 | + }, |
| 115 | + }, |
| 116 | + ]; |
| 117 | +}; |
| 118 | + |
| 119 | +// ============================== Export ============================== |
| 120 | +export default genComponentStyleHook('Field', (token) => { |
| 121 | + const fieldToken = mergeToken<FieldToken>(token); |
| 122 | + return [genFieldStyle(fieldToken)]; |
| 123 | +}); |
0 commit comments