2022-05-31 10:10:35 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
|
|
|
import type { GenerateStyle } from '../../_util/theme';
|
|
|
|
import { operationUnit } from '../../_util/theme';
|
|
|
|
import type { TableToken } from './index';
|
|
|
|
|
|
|
|
const genExpandStyle: GenerateStyle<TableToken, CSSObject> = token => {
|
2022-06-02 18:47:14 +08:00
|
|
|
const {
|
|
|
|
componentCls,
|
|
|
|
antCls,
|
|
|
|
controlInteractiveSize: checkboxSize,
|
|
|
|
motionDurationSlow,
|
|
|
|
controlLineWidth,
|
|
|
|
paddingXXS,
|
|
|
|
paddingXS,
|
|
|
|
controlLineType,
|
|
|
|
tableBorderColor,
|
|
|
|
tableExpandIconBg,
|
2022-06-24 11:32:42 +08:00
|
|
|
tableExpandColumnWidth,
|
2022-06-02 18:47:14 +08:00
|
|
|
radiusBase,
|
|
|
|
tablePaddingVertical,
|
|
|
|
tablePaddingHorizontal,
|
|
|
|
tableExpandedRowBg,
|
|
|
|
} = token;
|
|
|
|
const halfInnerSize = checkboxSize / 2 - controlLineWidth;
|
|
|
|
// must be odd number, unless it cannot align center
|
|
|
|
const expandIconSize = halfInnerSize * 2 + controlLineWidth * 3;
|
|
|
|
const tableBorder = `${controlLineWidth}px ${controlLineType} ${tableBorderColor}`;
|
|
|
|
const expandIconLineOffset = paddingXXS - controlLineWidth;
|
|
|
|
|
2022-05-31 10:10:35 +08:00
|
|
|
return {
|
|
|
|
[`${componentCls}-wrapper`]: {
|
|
|
|
[`${componentCls}-expand-icon-col`]: {
|
2022-06-24 11:32:42 +08:00
|
|
|
width: tableExpandColumnWidth,
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-row-expand-icon-cell`]: {
|
|
|
|
textAlign: 'center',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-row-indent`]: {
|
|
|
|
height: 1,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-row-expand-icon`]: {
|
|
|
|
...operationUnit(token),
|
|
|
|
position: 'relative',
|
|
|
|
display: 'inline-flex',
|
|
|
|
verticalAlign: 'text-top',
|
|
|
|
boxSizing: 'border-box',
|
|
|
|
width: expandIconSize,
|
|
|
|
height: expandIconSize,
|
|
|
|
padding: 0,
|
|
|
|
color: 'inherit',
|
|
|
|
lineHeight: `${expandIconSize}px`,
|
2022-06-02 18:47:14 +08:00
|
|
|
background: tableExpandIconBg,
|
2022-05-31 10:10:35 +08:00
|
|
|
border: tableBorder,
|
2022-06-02 18:47:14 +08:00
|
|
|
borderRadius: radiusBase,
|
2022-05-31 10:10:35 +08:00
|
|
|
outline: 'none',
|
|
|
|
transform: `scale(${checkboxSize / expandIconSize})`,
|
2022-06-02 18:47:14 +08:00
|
|
|
transition: `all ${motionDurationSlow}`,
|
2022-05-31 10:10:35 +08:00
|
|
|
userSelect: 'none',
|
|
|
|
|
|
|
|
[`&:focus, &:hover, &:active`]: {
|
|
|
|
borderColor: 'currentcolor',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&::before, &::after`]: {
|
|
|
|
position: 'absolute',
|
|
|
|
background: 'currentcolor',
|
2022-06-02 18:47:14 +08:00
|
|
|
transition: `transform ${motionDurationSlow} ease-out`,
|
2022-05-31 10:10:35 +08:00
|
|
|
content: '""',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&::before': {
|
|
|
|
top: halfInnerSize,
|
2022-06-02 18:47:14 +08:00
|
|
|
insetInlineEnd: expandIconLineOffset,
|
|
|
|
insetInlineStart: expandIconLineOffset,
|
|
|
|
height: controlLineWidth,
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&::after': {
|
2022-06-02 18:47:14 +08:00
|
|
|
top: expandIconLineOffset,
|
|
|
|
bottom: expandIconLineOffset,
|
2022-05-31 10:10:35 +08:00
|
|
|
insetInlineStart: halfInnerSize,
|
2022-06-02 18:47:14 +08:00
|
|
|
width: controlLineWidth,
|
2022-05-31 10:10:35 +08:00
|
|
|
transform: 'rotate(90deg)',
|
|
|
|
},
|
|
|
|
|
|
|
|
// Motion effect
|
|
|
|
'&-collapsed::before': {
|
|
|
|
transform: 'rotate(-180deg)',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-collapsed::after': {
|
|
|
|
transform: 'rotate(0deg)',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-spaced': {
|
|
|
|
'&::before, &::after': {
|
|
|
|
display: 'none',
|
|
|
|
content: 'none',
|
|
|
|
},
|
|
|
|
background: 'transparent',
|
|
|
|
border: 0,
|
|
|
|
visibility: 'hidden',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-row-indent + ${componentCls}-row-expand-icon`]: {
|
2022-06-02 18:47:14 +08:00
|
|
|
marginInlineEnd: paddingXS,
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`tr${componentCls}-expanded-row`]: {
|
|
|
|
'&, &:hover': {
|
|
|
|
'> td': {
|
2022-06-02 18:47:14 +08:00
|
|
|
background: tableExpandedRowBg,
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/25573
|
|
|
|
[`${antCls}-descriptions-view`]: {
|
|
|
|
display: 'flex',
|
|
|
|
|
|
|
|
table: {
|
|
|
|
flex: 'auto',
|
|
|
|
width: 'auto',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// With fixed
|
|
|
|
[`${componentCls}-expanded-row-fixed`]: {
|
|
|
|
position: 'relative',
|
2022-06-02 18:47:14 +08:00
|
|
|
margin: `-${tablePaddingVertical}px -${tablePaddingHorizontal}px`,
|
|
|
|
padding: `${tablePaddingVertical}px ${tablePaddingHorizontal}px`,
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default genExpandStyle;
|