ant-design/components/table/style/expand.tsx
afc163 9b95a30ec9
refactor: Table to CSS-IN-JS (#35584)
* style: add basic styles of table

* style: add basic border styles of table

* style: add more styles of table

* style: add more styles of table

* style: add pagination and summary styles

* add more styles

* style: add cell-ellipsis styles

* style: add Radius style

* style: add basic styles of table

* style: add basic border styles of table

* style: add more styles of table

* style: add more styles of table

* style: add pagination and summary styles

* add more styles

* style: add cell-ellipsis styles

* style: add Radius style

* style: add sorter style

* style: add sorter style

* style: add filter style

* style: add filter style

* style: add filter style

* style: fix filter and sort style

* style: fix bordered style

* style: fix bordered style

* style: fix bordered style

* style: add size style

* style: fix size style

* style: add selection style

* style: format code

* style: add sticky code

* style: add expand code

* style: add expand code

* style: add expand code

* style: add fixed code

* add fixed style

* style: fix diff place

* style: use number as px string

* chore: improve function name

* chore: use token

* style: rtl styles

* chore: fix marigin and padding logical properties

* fix: rtl styles

* fix: table filter dropdown style

* chore: remove useStyle

* chore: revert classNames

* fix: test case

* fix shadow in rtl

* Apply suggestions from code review

* chore: sub filter tree

* style: fix tree dropdown padding

Co-authored-by: zombiej <smith3816@gmail.com>
2022-05-31 10:10:35 +08:00

127 lines
3.5 KiB
TypeScript

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 => {
const { componentCls, antCls } = token;
// FIXME: 需要从 checkbox 那里取
const checkboxSize = token.controlInteractiveSize;
const halfInnerSize = checkboxSize / 2 - 1;
// must be odd number, unless it cannot align centerly
const expandIconSize = halfInnerSize * 2 + token.controlLineWidth * 3;
const tableBorder = `${token.controlLineWidth}px ${token.controlLineType} ${token.tableBorderColor}`;
return {
[`${componentCls}-wrapper`]: {
[`${componentCls}-expand-icon-col`]: {
// FIXME
width: 48,
},
[`${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`,
background: token.tableExpandIconBg,
border: tableBorder,
borderRadius: token.radiusBase,
outline: 'none',
transform: `scale(${checkboxSize / expandIconSize})`,
transition: `all ${token.motionDurationSlow}`,
userSelect: 'none',
[`&:focus, &:hover, &:active`]: {
borderColor: 'currentcolor',
},
[`&::before, &::after`]: {
position: 'absolute',
background: 'currentcolor',
transition: `transform ${token.motionDurationSlow} ease-out`,
content: '""',
},
'&::before': {
top: halfInnerSize,
insetInlineEnd: 3,
insetInlineStart: 3,
height: token.controlLineWidth,
},
'&::after': {
top: 3,
bottom: 3,
insetInlineStart: halfInnerSize,
width: token.controlLineWidth,
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`]: {
marginInlineEnd: token.paddingXS,
},
[`tr${componentCls}-expanded-row`]: {
'&, &:hover': {
'> td': {
background: token.tableExpandedRowBg,
},
},
// 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',
margin: `-${token.tablePaddingVertical}px -${token.tablePaddingHorizontal}px`,
padding: `${token.tablePaddingVertical}px ${token.tablePaddingHorizontal}px`,
},
},
};
};
export default genExpandStyle;