2022-05-31 10:10:35 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2022-06-27 14:25:59 +08:00
|
|
|
import type { GenerateStyle } from '../../theme';
|
2022-05-31 10:10:35 +08:00
|
|
|
import type { TableToken } from './index';
|
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
const genSorterStyle: GenerateStyle<TableToken, CSSObject> = (token) => {
|
2022-06-02 18:47:14 +08:00
|
|
|
const { componentCls, marginXXS, fontSizeIcon, tableHeaderIconColor, tableHeaderIconColorHover } =
|
|
|
|
token;
|
2022-05-31 10:10:35 +08:00
|
|
|
return {
|
|
|
|
[`${componentCls}-wrapper`]: {
|
|
|
|
[`${componentCls}-thead th${componentCls}-column-has-sorters`]: {
|
|
|
|
outline: 'none',
|
|
|
|
cursor: 'pointer',
|
|
|
|
transition: `all ${token.motionDurationSlow}`,
|
|
|
|
|
|
|
|
'&:hover': {
|
|
|
|
background: token.tableHeaderSortHoverBg,
|
|
|
|
|
|
|
|
'&::before': {
|
|
|
|
backgroundColor: 'transparent !important',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:focus-visible': {
|
|
|
|
color: token.colorPrimary,
|
|
|
|
},
|
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/30969
|
|
|
|
[`
|
|
|
|
&${componentCls}-cell-fix-left:hover,
|
|
|
|
&${componentCls}-cell-fix-right:hover
|
|
|
|
`]: {
|
|
|
|
background: token.tableFixedHeaderSortActiveBg,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-thead th${componentCls}-column-sort`]: {
|
|
|
|
background: token.tableHeaderSortBg,
|
|
|
|
|
|
|
|
'&::before': {
|
|
|
|
backgroundColor: 'transparent !important',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`td${componentCls}-column-sort`]: {
|
|
|
|
background: token.tableBodySortBg,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-column-title`]: {
|
|
|
|
position: 'relative',
|
|
|
|
zIndex: 1,
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-column-sorters`]: {
|
|
|
|
display: 'flex',
|
|
|
|
flex: 'auto',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
|
|
|
'&::after': {
|
|
|
|
position: 'absolute',
|
2022-06-02 18:47:14 +08:00
|
|
|
inset: 0,
|
2022-05-31 10:10:35 +08:00
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
content: '""',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-column-sorter`]: {
|
2022-06-02 18:47:14 +08:00
|
|
|
marginInlineStart: marginXXS,
|
|
|
|
color: tableHeaderIconColor,
|
2022-05-31 10:10:35 +08:00
|
|
|
fontSize: 0,
|
|
|
|
transition: `color ${token.motionDurationSlow}`,
|
|
|
|
|
|
|
|
'&-inner': {
|
|
|
|
display: 'inline-flex',
|
|
|
|
flexDirection: 'column',
|
|
|
|
alignItems: 'center',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-up, &-down': {
|
2022-06-02 18:47:14 +08:00
|
|
|
fontSize: fontSizeIcon,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
|
|
|
'&.active': {
|
|
|
|
color: token.colorPrimary,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-column-sorter-up + ${componentCls}-column-sorter-down`]: {
|
|
|
|
marginTop: '-0.3em',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-column-sorters:hover ${componentCls}-column-sorter`]: {
|
2022-06-02 18:47:14 +08:00
|
|
|
color: tableHeaderIconColorHover,
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default genSorterStyle;
|