2022-03-10 13:59:49 +08:00
|
|
|
// deps-lint-skip-all
|
|
|
|
import { CSSObject } from '@ant-design/cssinjs';
|
2022-04-11 16:04:00 +08:00
|
|
|
import {
|
|
|
|
resetComponent,
|
|
|
|
GenerateStyle,
|
|
|
|
genComponentStyleHook,
|
|
|
|
FullToken,
|
|
|
|
mergeToken,
|
|
|
|
} from '../../_util/theme';
|
2022-03-10 13:59:49 +08:00
|
|
|
|
2022-03-25 17:54:57 +08:00
|
|
|
/** Component only token. Which will handle additional calculation of alias token */
|
|
|
|
export interface ComponentToken {
|
|
|
|
sizePaddingEdgeHorizontal: number;
|
|
|
|
}
|
2022-03-10 13:59:49 +08:00
|
|
|
|
2022-04-07 14:53:33 +08:00
|
|
|
interface DividerToken extends FullToken<'Divider'> {
|
2022-03-10 13:59:49 +08:00
|
|
|
dividerVerticalGutterMargin: number;
|
|
|
|
dividerHorizontalWithTextGutterMargin: number;
|
|
|
|
dividerHorizontalGutterMargin: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ============================== Shared ==============================
|
2022-03-11 14:29:29 +08:00
|
|
|
const genSharedDividerStyle: GenerateStyle<DividerToken> = (token): CSSObject => {
|
2022-04-07 14:53:33 +08:00
|
|
|
const { componentCls, sizePaddingEdgeHorizontal, colorSplit, controlLineWidth } = token;
|
2022-03-10 13:59:49 +08:00
|
|
|
|
2022-03-11 14:29:29 +08:00
|
|
|
return {
|
2022-04-07 14:53:33 +08:00
|
|
|
[componentCls]: {
|
2022-03-11 14:29:29 +08:00
|
|
|
...resetComponent(token),
|
2022-03-25 17:54:57 +08:00
|
|
|
borderBlockStart: `${controlLineWidth}px solid ${colorSplit}`,
|
2022-03-10 13:59:49 +08:00
|
|
|
|
2022-03-11 14:29:29 +08:00
|
|
|
// vertical
|
|
|
|
'&-vertical': {
|
2022-03-10 13:59:49 +08:00
|
|
|
position: 'relative',
|
2022-03-11 14:29:29 +08:00
|
|
|
top: '-0.06em',
|
|
|
|
display: 'inline-block',
|
|
|
|
height: '0.9em',
|
|
|
|
margin: `0 ${token.dividerVerticalGutterMargin}px`,
|
|
|
|
verticalAlign: 'middle',
|
|
|
|
borderTop: 0,
|
2022-03-25 17:54:57 +08:00
|
|
|
borderInlineStart: `${controlLineWidth}px solid ${colorSplit}`,
|
2022-03-10 13:59:49 +08:00
|
|
|
},
|
|
|
|
|
2022-03-11 14:29:29 +08:00
|
|
|
'&-horizontal': {
|
|
|
|
display: 'flex',
|
|
|
|
clear: 'both',
|
|
|
|
width: '100%',
|
|
|
|
minWidth: '100%', // Fix https://github.com/ant-design/ant-design/issues/10914
|
|
|
|
margin: `${token.dividerHorizontalGutterMargin}px 0`,
|
2022-03-10 13:59:49 +08:00
|
|
|
},
|
|
|
|
|
2022-03-11 14:29:29 +08:00
|
|
|
'&-horizontal&-with-text': {
|
|
|
|
display: 'flex',
|
|
|
|
margin: `${token.dividerHorizontalWithTextGutterMargin}px 0`,
|
2022-03-22 20:02:04 +08:00
|
|
|
color: token.colorTextHeading,
|
2022-03-11 14:29:29 +08:00
|
|
|
fontWeight: 500,
|
|
|
|
fontSize: token.fontSizeLG,
|
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
textAlign: 'center',
|
2022-03-25 17:54:57 +08:00
|
|
|
borderBlockStart: `0 ${colorSplit}`,
|
2022-03-11 14:29:29 +08:00
|
|
|
|
|
|
|
'&::before, &::after': {
|
|
|
|
position: 'relative',
|
|
|
|
top: '50%',
|
|
|
|
width: '50%',
|
2022-03-25 17:54:57 +08:00
|
|
|
borderBlockStart: `${controlLineWidth}px solid transparent`,
|
2022-03-11 14:29:29 +08:00
|
|
|
// Chrome not accept `inherit` in `border-top`
|
|
|
|
borderBlockStartColor: 'inherit',
|
|
|
|
borderBlockEnd: 0,
|
|
|
|
transform: 'translateY(50%)',
|
|
|
|
content: "''",
|
|
|
|
},
|
2022-03-10 13:59:49 +08:00
|
|
|
},
|
|
|
|
|
2022-03-17 16:57:20 +08:00
|
|
|
'&-horizontal&-with-text-left': {
|
|
|
|
'&::before': {
|
|
|
|
top: '50%',
|
|
|
|
width: '5%',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&::after': {
|
|
|
|
top: '50%',
|
|
|
|
width: '95%',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-03-11 14:29:29 +08:00
|
|
|
'&-horizontal&-with-text-right': {
|
|
|
|
'&::before': {
|
|
|
|
top: '50%',
|
|
|
|
width: '95%',
|
|
|
|
},
|
2022-03-10 13:59:49 +08:00
|
|
|
|
2022-03-11 14:29:29 +08:00
|
|
|
'&::after': {
|
|
|
|
top: '50%',
|
|
|
|
width: '5%',
|
|
|
|
},
|
2022-03-10 13:59:49 +08:00
|
|
|
},
|
|
|
|
|
2022-04-07 14:53:33 +08:00
|
|
|
[`${componentCls}-inner-text`]: {
|
2022-03-11 14:29:29 +08:00
|
|
|
display: 'inline-block',
|
|
|
|
padding: '0 1em',
|
|
|
|
},
|
2022-03-10 13:59:49 +08:00
|
|
|
|
2022-03-11 14:29:29 +08:00
|
|
|
'&-dashed': {
|
|
|
|
background: 'none',
|
2022-03-25 17:54:57 +08:00
|
|
|
borderColor: colorSplit,
|
2022-03-11 14:29:29 +08:00
|
|
|
borderStyle: 'dashed',
|
|
|
|
borderWidth: 0,
|
2022-03-25 17:54:57 +08:00
|
|
|
borderBlockStart: `${controlLineWidth}px`,
|
2022-03-10 13:59:49 +08:00
|
|
|
},
|
|
|
|
|
2022-03-11 14:29:29 +08:00
|
|
|
'&-horizontal&-with-text&-dashed': {
|
|
|
|
'&::before, &::after': {
|
|
|
|
borderStyle: 'dashed none none',
|
|
|
|
},
|
2022-03-10 13:59:49 +08:00
|
|
|
},
|
|
|
|
|
2022-03-11 14:29:29 +08:00
|
|
|
'&-vertical&-dashed': {
|
2022-03-25 17:54:57 +08:00
|
|
|
borderWidth: `0 0 0 ${controlLineWidth}px`,
|
2022-03-10 13:59:49 +08:00
|
|
|
},
|
|
|
|
|
2022-03-11 14:29:29 +08:00
|
|
|
'&-plain&-with-text': {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: token.colorText,
|
2022-03-11 14:29:29 +08:00
|
|
|
fontWeight: 'normal',
|
|
|
|
fontSize: token.fontSize,
|
2022-03-10 13:59:49 +08:00
|
|
|
},
|
|
|
|
|
2022-03-11 14:29:29 +08:00
|
|
|
'&-horizontal&-with-text-left&-no-default-orientation-margin-left': {
|
|
|
|
'&::before': {
|
|
|
|
width: 0,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&::after': {
|
|
|
|
width: '100%',
|
|
|
|
},
|
|
|
|
|
2022-04-07 14:53:33 +08:00
|
|
|
[`${componentCls}-inner-text`]: {
|
2022-03-25 17:54:57 +08:00
|
|
|
paddingInlineStart: sizePaddingEdgeHorizontal,
|
2022-03-11 14:29:29 +08:00
|
|
|
},
|
2022-03-10 13:59:49 +08:00
|
|
|
},
|
|
|
|
|
2022-03-11 14:29:29 +08:00
|
|
|
'&-horizontal&-with-text-right&-no-default-orientation-margin-right': {
|
|
|
|
'&::before': {
|
|
|
|
width: '100%',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&::after': {
|
|
|
|
width: 0,
|
|
|
|
},
|
|
|
|
|
2022-04-07 14:53:33 +08:00
|
|
|
[`${componentCls}-inner-text`]: {
|
2022-03-25 17:54:57 +08:00
|
|
|
paddingInlineEnd: sizePaddingEdgeHorizontal,
|
2022-03-11 14:29:29 +08:00
|
|
|
},
|
2022-03-10 13:59:49 +08:00
|
|
|
},
|
|
|
|
},
|
2022-03-11 14:29:29 +08:00
|
|
|
};
|
|
|
|
};
|
2022-03-10 13:59:49 +08:00
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2022-04-07 14:53:33 +08:00
|
|
|
export default genComponentStyleHook(
|
|
|
|
'Divider',
|
|
|
|
token => {
|
2022-04-11 16:04:00 +08:00
|
|
|
const dividerToken = mergeToken<DividerToken>(token, {
|
2022-04-07 14:53:33 +08:00
|
|
|
dividerVerticalGutterMargin: token.marginSM,
|
|
|
|
dividerHorizontalWithTextGutterMargin: token.margin,
|
|
|
|
dividerHorizontalGutterMargin: token.marginLG,
|
2022-04-11 16:04:00 +08:00
|
|
|
});
|
2022-04-07 14:53:33 +08:00
|
|
|
return [genSharedDividerStyle(dividerToken)];
|
|
|
|
},
|
|
|
|
{
|
|
|
|
sizePaddingEdgeHorizontal: 0,
|
|
|
|
},
|
|
|
|
);
|