2024-04-08 14:04:08 +08:00
|
|
|
import { unit } from '@ant-design/cssinjs';
|
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2023-11-17 13:46:41 +08:00
|
|
|
|
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) => {
|
2023-11-17 13:46:41 +08:00
|
|
|
const { componentCls, tableExpandColumnWidth, calc } = token;
|
2022-05-31 10:10:35 +08:00
|
|
|
const getSizeStyle = (
|
|
|
|
size: 'small' | 'middle',
|
|
|
|
paddingVertical: number,
|
|
|
|
paddingHorizontal: number,
|
|
|
|
fontSize: number,
|
|
|
|
) => ({
|
|
|
|
[`${componentCls}${componentCls}-${size}`]: {
|
|
|
|
fontSize,
|
|
|
|
[`
|
|
|
|
${componentCls}-title,
|
|
|
|
${componentCls}-footer,
|
2023-08-28 17:36:23 +08:00
|
|
|
${componentCls}-cell,
|
2022-05-31 10:10:35 +08:00
|
|
|
${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
|
|
|
|
`]: {
|
2023-11-17 13:46:41 +08:00
|
|
|
padding: `${unit(paddingVertical)} ${unit(paddingHorizontal)}`,
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-filter-trigger`]: {
|
2023-11-17 13:46:41 +08:00
|
|
|
marginInlineEnd: unit(calc(paddingHorizontal).div(2).mul(-1).equal()),
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-expanded-row-fixed`]: {
|
2023-11-17 13:46:41 +08:00
|
|
|
margin: `${unit(calc(paddingVertical).mul(-1).equal())} ${unit(
|
|
|
|
calc(paddingHorizontal).mul(-1).equal(),
|
|
|
|
)}`,
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-tbody`]: {
|
|
|
|
// ========================= Nest Table ===========================
|
|
|
|
[`${componentCls}-wrapper:only-child ${componentCls}`]: {
|
2023-11-17 13:46:41 +08:00
|
|
|
marginBlock: unit(calc(paddingVertical).mul(-1).equal()),
|
|
|
|
marginInline: `${unit(
|
|
|
|
calc(tableExpandColumnWidth).sub(paddingHorizontal).equal(),
|
|
|
|
)} ${unit(calc(paddingHorizontal).mul(-1).equal())}`,
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/35167
|
2023-09-18 14:06:06 +08:00
|
|
|
[`${componentCls}-selection-extra`]: {
|
2023-11-17 13:46:41 +08:00
|
|
|
paddingInlineStart: unit(calc(paddingHorizontal).div(4).equal()),
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
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;
|