ant-design/components/button/style/group.tsx

82 lines
1.9 KiB
TypeScript
Raw Normal View History

2022-04-22 22:36:50 +08:00
import type { ButtonToken } from '.';
import type { GenerateStyle } from '../../theme';
2022-04-22 22:36:50 +08:00
const genButtonBorderStyle = (buttonTypeCls: string, borderColor: string) => ({
// Border
[`> span, > ${buttonTypeCls}`]: {
'&:not(:last-child)': {
[`&, & > ${buttonTypeCls}`]: {
'&:not(:disabled)': {
borderInlineEndColor: borderColor,
},
},
},
'&:not(:first-child)': {
[`&, & > ${buttonTypeCls}`]: {
'&:not(:disabled)': {
borderInlineStartColor: borderColor,
},
},
},
},
});
2022-04-22 22:36:50 +08:00
const genGroupStyle: GenerateStyle<ButtonToken> = token => {
const { componentCls, fontSizeBase, controlLineWidth, colorPrimaryHover, colorErrorHover } =
token;
2022-04-22 22:36:50 +08:00
return {
[`${componentCls}-group`]: [
{
position: 'relative',
display: 'inline-flex',
// Border
[`> span, > ${componentCls}`]: {
'&:not(:last-child)': {
[`&, & > ${componentCls}`]: {
borderStartEndRadius: 0,
borderEndEndRadius: 0,
2022-04-22 22:36:50 +08:00
},
},
'&:not(:first-child)': {
marginInlineStart: -controlLineWidth,
2022-04-22 22:36:50 +08:00
[`&, & > ${componentCls}`]: {
borderStartStartRadius: 0,
borderEndStartRadius: 0,
2022-04-22 22:36:50 +08:00
},
},
},
[componentCls]: {
position: 'relative',
zIndex: 1,
2022-04-22 22:36:50 +08:00
[`&:hover,
2022-04-22 22:36:50 +08:00
&:focus,
&:active`]: {
zIndex: 2,
},
'&[disabled]': {
zIndex: 0,
},
2022-04-22 22:36:50 +08:00
},
[`${componentCls}-icon-only`]: {
fontSize: fontSizeBase,
2022-04-22 22:36:50 +08:00
},
},
// Border Color
genButtonBorderStyle(`${componentCls}-primary`, colorPrimaryHover),
genButtonBorderStyle(`${componentCls}-danger`, colorErrorHover),
],
2022-04-22 22:36:50 +08:00
};
};
export default genGroupStyle;