|
1 |
| -import './index.less'; |
| 1 | +import type { CSSObject } from '../../_util/cssinjs'; |
| 2 | +import type { FullToken, GenerateStyle } from '../../theme/internal'; |
| 3 | +import { genComponentStyleHook, mergeToken } from '../../theme/internal'; |
| 4 | +import { resetComponent, textEllipsis } from '../../_style'; |
| 5 | +import { operationUnit } from '../../_style'; |
2 | 6 |
|
3 |
| -// style dependencies |
4 |
| -import '../../breadcrumb/style'; |
5 |
| -import '../../avatar/style'; |
6 |
| -import '../../space/style'; |
| 7 | +interface PageHeaderToken extends FullToken<'PageHeader'> { |
| 8 | + pageHeaderPadding: number; |
| 9 | + pageHeaderPaddingVertical: number; |
| 10 | + pageHeaderPaddingBreadcrumb: number; |
| 11 | + pageHeaderGhostBg: string; |
| 12 | + pageHeaderBackColor: string; |
| 13 | + pageHeaderHeadingTitle: number; |
| 14 | + pageHeaderHeadingSubTitle: number; |
| 15 | + pageHeaderContentPaddingVertical: number; |
| 16 | + pageHeaderTabFontSize: number; |
| 17 | +} |
| 18 | + |
| 19 | +const genPageHeaderStyle: GenerateStyle<PageHeaderToken, CSSObject> = token => { |
| 20 | + const { componentCls, antCls } = token; |
| 21 | + |
| 22 | + return { |
| 23 | + [componentCls]: { |
| 24 | + ...resetComponent(token), |
| 25 | + position: 'relative', |
| 26 | + padding: `${token.pageHeaderPaddingVertical}px ${token.pageHeaderPadding}px`, |
| 27 | + backgroundColor: token.colorBgLayout, |
| 28 | + |
| 29 | + [`${componentCls}-ghost`]: { |
| 30 | + backgroundColor: token.pageHeaderGhostBg, |
| 31 | + }, |
| 32 | + |
| 33 | + [`&.has-footer`]: { |
| 34 | + paddingBottom: 0, |
| 35 | + }, |
| 36 | + |
| 37 | + [`${componentCls}-back`]: { |
| 38 | + marginRight: token.marginMD, |
| 39 | + fontZize: token.fontSizeLG, |
| 40 | + lineHeight: 1, |
| 41 | + |
| 42 | + [`&-button`]: { |
| 43 | + ...operationUnit(token), |
| 44 | + color: token.pageHeaderBackColor, |
| 45 | + cursor: 'pointer', |
| 46 | + }, |
| 47 | + }, |
| 48 | + |
| 49 | + [`${antCls}-divider-vertical`]: { |
| 50 | + height: '14px', |
| 51 | + margin: `0 ${token.marginSM}`, |
| 52 | + verticalAlign: 'middle', |
| 53 | + }, |
| 54 | + |
| 55 | + [`${antCls}-breadcrumb + &-heading`]: { |
| 56 | + marginTop: token.marginXS, |
| 57 | + }, |
| 58 | + |
| 59 | + [`${componentCls}-heading`]: { |
| 60 | + display: 'flex', |
| 61 | + justifyContent: 'space-between', |
| 62 | + |
| 63 | + [`&-left`]: { |
| 64 | + display: 'flex', |
| 65 | + alignItems: 'center', |
| 66 | + margin: `${token.marginXS / 2}px 0`, |
| 67 | + overflow: 'hidden', |
| 68 | + }, |
| 69 | + |
| 70 | + [`&-title`]: { |
| 71 | + marginRight: token.marginSM, |
| 72 | + marginBottom: 0, |
| 73 | + color: token.colorTextHeading, |
| 74 | + fontWeight: 600, |
| 75 | + fontSize: token.pageHeaderHeadingTitle, |
| 76 | + lineHeight: `${token.controlHeight}px`, |
| 77 | + ...textEllipsis, |
| 78 | + }, |
| 79 | + |
| 80 | + [`${antCls}-avatar`]: { |
| 81 | + marginRight: token.marginSM, |
| 82 | + }, |
| 83 | + |
| 84 | + [`&-sub-title`]: { |
| 85 | + marginRight: token.marginSM, |
| 86 | + color: token.colorTextDescription, |
| 87 | + fontSize: token.pageHeaderHeadingSubTitle, |
| 88 | + lineHeight: token.lineHeight, |
| 89 | + ...textEllipsis, |
| 90 | + }, |
| 91 | + |
| 92 | + [`&-extra`]: { |
| 93 | + margin: `${token.marginXS / 2}px 0`, |
| 94 | + whiteSpace: 'nowrap', |
| 95 | + |
| 96 | + [`> *`]: { |
| 97 | + marginLeft: token.marginSM, |
| 98 | + whiteSpace: 'unset', |
| 99 | + }, |
| 100 | + |
| 101 | + [`> *:first-child`]: { |
| 102 | + marginLeft: 0, |
| 103 | + }, |
| 104 | + }, |
| 105 | + }, |
| 106 | + |
| 107 | + [`${componentCls}-content`]: { |
| 108 | + paddingTop: token.pageHeaderContentPaddingVertical, |
| 109 | + }, |
| 110 | + |
| 111 | + [`${componentCls}-footer`]: { |
| 112 | + marginTop: token.marginMD, |
| 113 | + [`${antCls}-tabs`]: { |
| 114 | + [`> ${antCls}-tabs-nav`]: { |
| 115 | + margin: 0, |
| 116 | + |
| 117 | + [`&::before`]: { |
| 118 | + border: 'none', |
| 119 | + }, |
| 120 | + }, |
| 121 | + [`${antCls}-tabs-tab`]: { |
| 122 | + paddingTop: token.paddingXS, |
| 123 | + paddingBottom: token.paddingXS, |
| 124 | + fontSize: token.pageHeaderTabFontSize, |
| 125 | + }, |
| 126 | + }, |
| 127 | + }, |
| 128 | + |
| 129 | + [`${componentCls}-compact ${componentCls}-heading`]: { |
| 130 | + flexWrap: 'wrap', |
| 131 | + }, |
| 132 | + |
| 133 | + // rtl style |
| 134 | + [`&${token.componentCls}-rtl`]: { |
| 135 | + direction: 'rtl', |
| 136 | + }, |
| 137 | + }, |
| 138 | + }; |
| 139 | +}; |
| 140 | + |
| 141 | +// ============================== Export ============================== |
| 142 | +export default genComponentStyleHook('PageHeader', token => { |
| 143 | + const PageHeaderToken = mergeToken<PageHeaderToken>(token, { |
| 144 | + pageHeaderPadding: token.paddingLG, |
| 145 | + pageHeaderPaddingVertical: token.paddingMD, |
| 146 | + pageHeaderPaddingBreadcrumb: token.paddingSM, |
| 147 | + pageHeaderContentPaddingVertical: token.paddingSM, |
| 148 | + pageHeaderBackColor: token.colorTextBase, |
| 149 | + pageHeaderGhostBg: 'inherit', |
| 150 | + pageHeaderHeadingTitle: token.fontSizeHeading4, |
| 151 | + pageHeaderHeadingSubTitle: token.fontSize, |
| 152 | + pageHeaderTabFontSize: token.fontSizeLG, |
| 153 | + }); |
| 154 | + |
| 155 | + return [genPageHeaderStyle(PageHeaderToken)]; |
| 156 | +}); |
0 commit comments