You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
166 lines
4.3 KiB
166 lines
4.3 KiB
3 years ago
|
import type { CSSObject } from '@ant-design/cssinjs';
|
||
2 years ago
|
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
||
|
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
|
||
2 years ago
|
import { resetComponent } from '../../style';
|
||
3 years ago
|
|
||
3 years ago
|
/** Component only token. Which will handle additional calculation of alias token */
|
||
|
export interface ComponentToken {
|
||
|
sizePaddingEdgeHorizontal: number;
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
interface DividerToken extends FullToken<'Divider'> {
|
||
3 years ago
|
dividerVerticalGutterMargin: number;
|
||
|
dividerHorizontalWithTextGutterMargin: number;
|
||
|
dividerHorizontalGutterMargin: number;
|
||
|
}
|
||
|
|
||
|
// ============================== Shared ==============================
|
||
3 years ago
|
const genSharedDividerStyle: GenerateStyle<DividerToken> = (token): CSSObject => {
|
||
2 years ago
|
const { componentCls, sizePaddingEdgeHorizontal, colorSplit, lineWidth } = token;
|
||
3 years ago
|
|
||
3 years ago
|
return {
|
||
3 years ago
|
[componentCls]: {
|
||
3 years ago
|
...resetComponent(token),
|
||
2 years ago
|
borderBlockStart: `${lineWidth}px solid ${colorSplit}`,
|
||
3 years ago
|
|
||
3 years ago
|
// vertical
|
||
|
'&-vertical': {
|
||
3 years ago
|
position: 'relative',
|
||
3 years ago
|
top: '-0.06em',
|
||
|
display: 'inline-block',
|
||
|
height: '0.9em',
|
||
|
margin: `0 ${token.dividerVerticalGutterMargin}px`,
|
||
|
verticalAlign: 'middle',
|
||
|
borderTop: 0,
|
||
2 years ago
|
borderInlineStart: `${lineWidth}px solid ${colorSplit}`,
|
||
3 years ago
|
},
|
||
|
|
||
3 years ago
|
'&-horizontal': {
|
||
|
display: 'flex',
|
||
|
clear: 'both',
|
||
|
width: '100%',
|
||
|
minWidth: '100%', // Fix https://github.com/ant-design/ant-design/issues/10914
|
||
|
margin: `${token.dividerHorizontalGutterMargin}px 0`,
|
||
3 years ago
|
},
|
||
|
|
||
3 years ago
|
'&-horizontal&-with-text': {
|
||
|
display: 'flex',
|
||
2 years ago
|
alignItems: 'center',
|
||
3 years ago
|
margin: `${token.dividerHorizontalWithTextGutterMargin}px 0`,
|
||
3 years ago
|
color: token.colorTextHeading,
|
||
3 years ago
|
fontWeight: 500,
|
||
|
fontSize: token.fontSizeLG,
|
||
|
whiteSpace: 'nowrap',
|
||
|
textAlign: 'center',
|
||
3 years ago
|
borderBlockStart: `0 ${colorSplit}`,
|
||
3 years ago
|
|
||
|
'&::before, &::after': {
|
||
|
position: 'relative',
|
||
|
width: '50%',
|
||
2 years ago
|
borderBlockStart: `${lineWidth}px solid transparent`,
|
||
3 years ago
|
// Chrome not accept `inherit` in `border-top`
|
||
|
borderBlockStartColor: 'inherit',
|
||
|
borderBlockEnd: 0,
|
||
|
transform: 'translateY(50%)',
|
||
|
content: "''",
|
||
|
},
|
||
3 years ago
|
},
|
||
|
|
||
3 years ago
|
'&-horizontal&-with-text-left': {
|
||
|
'&::before': {
|
||
|
width: '5%',
|
||
|
},
|
||
|
|
||
|
'&::after': {
|
||
|
width: '95%',
|
||
|
},
|
||
|
},
|
||
|
|
||
3 years ago
|
'&-horizontal&-with-text-right': {
|
||
|
'&::before': {
|
||
|
width: '95%',
|
||
|
},
|
||
3 years ago
|
|
||
3 years ago
|
'&::after': {
|
||
|
width: '5%',
|
||
|
},
|
||
3 years ago
|
},
|
||
|
|
||
3 years ago
|
[`${componentCls}-inner-text`]: {
|
||
3 years ago
|
display: 'inline-block',
|
||
|
padding: '0 1em',
|
||
|
},
|
||
3 years ago
|
|
||
3 years ago
|
'&-dashed': {
|
||
|
background: 'none',
|
||
3 years ago
|
borderColor: colorSplit,
|
||
3 years ago
|
borderStyle: 'dashed',
|
||
2 years ago
|
borderWidth: `${lineWidth}px 0 0`,
|
||
3 years ago
|
},
|
||
|
|
||
3 years ago
|
'&-horizontal&-with-text&-dashed': {
|
||
|
'&::before, &::after': {
|
||
|
borderStyle: 'dashed none none',
|
||
|
},
|
||
3 years ago
|
},
|
||
|
|
||
3 years ago
|
'&-vertical&-dashed': {
|
||
2 years ago
|
borderInlineStart: lineWidth,
|
||
3 years ago
|
borderInlineEnd: 0,
|
||
|
borderBlockStart: 0,
|
||
|
borderBlockEnd: 0,
|
||
3 years ago
|
},
|
||
|
|
||
3 years ago
|
'&-plain&-with-text': {
|
||
3 years ago
|
color: token.colorText,
|
||
3 years ago
|
fontWeight: 'normal',
|
||
|
fontSize: token.fontSize,
|
||
3 years ago
|
},
|
||
|
|
||
3 years ago
|
'&-horizontal&-with-text-left&-no-default-orientation-margin-left': {
|
||
|
'&::before': {
|
||
|
width: 0,
|
||
|
},
|
||
|
|
||
|
'&::after': {
|
||
|
width: '100%',
|
||
|
},
|
||
|
|
||
3 years ago
|
[`${componentCls}-inner-text`]: {
|
||
3 years ago
|
paddingInlineStart: sizePaddingEdgeHorizontal,
|
||
3 years ago
|
},
|
||
3 years ago
|
},
|
||
|
|
||
3 years ago
|
'&-horizontal&-with-text-right&-no-default-orientation-margin-right': {
|
||
|
'&::before': {
|
||
|
width: '100%',
|
||
|
},
|
||
|
|
||
|
'&::after': {
|
||
|
width: 0,
|
||
|
},
|
||
|
|
||
3 years ago
|
[`${componentCls}-inner-text`]: {
|
||
3 years ago
|
paddingInlineEnd: sizePaddingEdgeHorizontal,
|
||
3 years ago
|
},
|
||
3 years ago
|
},
|
||
|
},
|
||
3 years ago
|
};
|
||
|
};
|
||
3 years ago
|
|
||
|
// ============================== Export ==============================
|
||
3 years ago
|
export default genComponentStyleHook(
|
||
|
'Divider',
|
||
2 years ago
|
(token) => {
|
||
3 years ago
|
const dividerToken = mergeToken<DividerToken>(token, {
|
||
3 years ago
|
dividerVerticalGutterMargin: token.marginXS,
|
||
3 years ago
|
dividerHorizontalWithTextGutterMargin: token.margin,
|
||
|
dividerHorizontalGutterMargin: token.marginLG,
|
||
3 years ago
|
});
|
||
3 years ago
|
return [genSharedDividerStyle(dividerToken)];
|
||
|
},
|
||
|
{
|
||
|
sizePaddingEdgeHorizontal: 0,
|
||
|
},
|
||
|
);
|