2022-05-31 10:10:35 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2022-11-23 20:22:38 +08:00
|
|
|
import type { GenerateStyle } from '../../theme/internal';
|
2022-05-31 10:10:35 +08:00
|
|
|
import type { TableToken } from './index';
|
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
const genSizeStyle: GenerateStyle<TableToken, CSSObject> = (token) => {
|
2022-05-31 10:10:35 +08:00
|
|
|
const { componentCls } = token;
|
|
|
|
const getSizeStyle = (
|
|
|
|
size: 'small' | 'middle',
|
|
|
|
paddingVertical: number,
|
|
|
|
paddingHorizontal: number,
|
|
|
|
fontSize: number,
|
|
|
|
) => ({
|
|
|
|
[`${componentCls}${componentCls}-${size}`]: {
|
|
|
|
fontSize,
|
|
|
|
[`
|
|
|
|
${componentCls}-title,
|
|
|
|
${componentCls}-footer,
|
|
|
|
${componentCls}-thead > tr > th,
|
2023-03-02 20:51:40 +08:00
|
|
|
${componentCls}-tbody > tr > th,
|
2022-05-31 10:10:35 +08:00
|
|
|
${componentCls}-tbody > tr > td,
|
|
|
|
tfoot > tr > th,
|
|
|
|
tfoot > tr > td
|
|
|
|
`]: {
|
|
|
|
padding: `${paddingVertical}px ${paddingHorizontal}px`,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-filter-trigger`]: {
|
|
|
|
marginInlineEnd: `-${paddingHorizontal / 2}px`,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-expanded-row-fixed`]: {
|
|
|
|
margin: `-${paddingVertical}px -${paddingHorizontal}px`,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-tbody`]: {
|
|
|
|
// ========================= Nest Table ===========================
|
|
|
|
[`${componentCls}-wrapper:only-child ${componentCls}`]: {
|
|
|
|
marginBlock: `-${paddingVertical}px`,
|
2022-06-24 11:32:42 +08:00
|
|
|
marginInline: `${
|
|
|
|
token.tableExpandColumnWidth - paddingHorizontal
|
|
|
|
}px -${paddingHorizontal}px`,
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/35167
|
|
|
|
[`${componentCls}-selection-column`]: {
|
|
|
|
paddingInlineStart: `${paddingHorizontal / 4}px`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
[`${componentCls}-wrapper`]: {
|
|
|
|
...getSizeStyle(
|
|
|
|
'middle',
|
|
|
|
token.tablePaddingVerticalMiddle,
|
|
|
|
token.tablePaddingHorizontalMiddle,
|
2022-06-02 18:47:14 +08:00
|
|
|
token.tableFontSizeMiddle,
|
2022-05-31 10:10:35 +08:00
|
|
|
),
|
|
|
|
...getSizeStyle(
|
|
|
|
'small',
|
|
|
|
token.tablePaddingVerticalSmall,
|
|
|
|
token.tablePaddingHorizontalSmall,
|
2022-06-02 18:47:14 +08:00
|
|
|
token.tableFontSizeSmall,
|
2022-05-31 10:10:35 +08:00
|
|
|
),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default genSizeStyle;
|