2022-05-09 22:20:07 +08:00
|
|
|
import { Keyframes } from '@ant-design/cssinjs';
|
2022-06-27 14:25:59 +08:00
|
|
|
import type { FullToken, GenerateStyle } from '../../theme';
|
2022-07-11 15:35:58 +08:00
|
|
|
import { genComponentStyleHook, mergeToken } from '../../theme';
|
|
|
|
import { resetComponent } from '../../style';
|
2022-04-14 19:14:54 +08:00
|
|
|
|
|
|
|
// ============================== Tokens ==============================
|
2022-06-01 10:14:57 +08:00
|
|
|
export interface ComponentToken {}
|
|
|
|
|
|
|
|
interface RadioToken extends FullToken<'Radio'> {
|
2022-04-14 19:14:54 +08:00
|
|
|
radioFocusShadow: string;
|
|
|
|
radioButtonFocusShadow: string;
|
|
|
|
|
|
|
|
radioSize: number;
|
2022-06-01 10:14:57 +08:00
|
|
|
radioTop: number;
|
2022-04-14 19:14:54 +08:00
|
|
|
radioDotSize: number;
|
|
|
|
radioDotColor: string;
|
|
|
|
radioDotDisabledColor: string;
|
|
|
|
radioSolidCheckedColor: string;
|
|
|
|
|
|
|
|
radioButtonBg: string;
|
|
|
|
radioButtonCheckedBg: string;
|
|
|
|
radioButtonColor: string;
|
|
|
|
radioButtonHoverColor: string;
|
|
|
|
radioButtonActiveColor: string;
|
|
|
|
radioButtonPaddingHorizontal: number;
|
|
|
|
radioDisabledButtonCheckedBg: string;
|
|
|
|
radioDisabledButtonCheckedColor: string;
|
|
|
|
radioWrapperMarginRight: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ============================== Styles ==============================
|
|
|
|
const antRadioEffect = new Keyframes('antRadioEffect', {
|
|
|
|
'0%': { transform: 'scale(1)', opacity: 0.5 },
|
|
|
|
'100%': { transform: 'scale(1.6)', opacity: 0 },
|
|
|
|
});
|
|
|
|
|
|
|
|
// styles from RadioGroup only
|
2022-06-01 10:14:57 +08:00
|
|
|
const getGroupRadioStyle: GenerateStyle<RadioToken> = token => {
|
|
|
|
const { componentCls, antCls } = token;
|
|
|
|
const groupPrefixCls = `${componentCls}-group`;
|
2022-04-14 19:14:54 +08:00
|
|
|
|
|
|
|
return {
|
2022-06-01 10:14:57 +08:00
|
|
|
[groupPrefixCls]: {
|
2022-04-14 19:14:54 +08:00
|
|
|
...resetComponent(token),
|
|
|
|
display: 'inline-block',
|
|
|
|
fontSize: 0,
|
|
|
|
|
|
|
|
// RTL
|
|
|
|
'&&-rtl': {
|
|
|
|
direction: 'rtl',
|
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${antCls}-badge ${antCls}-badge-count`]: {
|
2022-04-14 19:14:54 +08:00
|
|
|
zIndex: 1,
|
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[`> ${antCls}-badge:not(:first-child) > ${antCls}-button-wrapper`]: {
|
2022-04-14 19:14:54 +08:00
|
|
|
borderInlineStart: 'none',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2022-06-01 10:14:57 +08:00
|
|
|
};
|
2022-04-14 19:14:54 +08:00
|
|
|
|
|
|
|
// Styles from radio-wrapper
|
2022-06-01 10:14:57 +08:00
|
|
|
const getRadioBasicStyle: GenerateStyle<RadioToken> = token => {
|
|
|
|
const {
|
|
|
|
componentCls,
|
|
|
|
radioWrapperMarginRight,
|
|
|
|
radioDotColor,
|
|
|
|
radioTop,
|
|
|
|
radioFocusShadow,
|
|
|
|
radioSize,
|
|
|
|
motionDurationSlow,
|
2022-09-07 14:08:14 +08:00
|
|
|
motionDurationFast,
|
2022-06-01 10:14:57 +08:00
|
|
|
motionEaseInOut,
|
|
|
|
motionEaseInOutCirc,
|
|
|
|
radioButtonBg,
|
|
|
|
colorBorder,
|
|
|
|
controlLineWidth,
|
|
|
|
radioDotSize,
|
2022-06-28 20:33:01 +08:00
|
|
|
colorBgContainerDisabled,
|
2022-06-01 10:14:57 +08:00
|
|
|
colorTextDisabled,
|
|
|
|
paddingXS,
|
|
|
|
radioDotDisabledColor,
|
|
|
|
controlLineType,
|
|
|
|
} = token;
|
|
|
|
const radioInnerPrefixCls = `${componentCls}-inner`;
|
2022-04-14 19:14:54 +08:00
|
|
|
|
|
|
|
return {
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${componentCls}-wrapper`]: {
|
2022-04-14 19:14:54 +08:00
|
|
|
...resetComponent(token),
|
|
|
|
position: 'relative',
|
|
|
|
display: 'inline-flex',
|
|
|
|
alignItems: 'baseline',
|
|
|
|
marginInlineStart: 0,
|
2022-06-01 10:14:57 +08:00
|
|
|
marginInlineEnd: radioWrapperMarginRight,
|
2022-04-14 19:14:54 +08:00
|
|
|
cursor: 'pointer',
|
|
|
|
|
|
|
|
// RTL
|
|
|
|
'&&-rtl': {
|
|
|
|
direction: 'rtl',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-disabled': {
|
|
|
|
cursor: 'not-allowed',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&::after': {
|
|
|
|
display: 'inline-block',
|
|
|
|
width: 0,
|
|
|
|
overflow: 'hidden',
|
|
|
|
content: '"\\a0"',
|
|
|
|
},
|
|
|
|
|
|
|
|
// hashId 在 wrapper 上,只能铺平
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${componentCls}-checked::after`]: {
|
2022-04-14 19:14:54 +08:00
|
|
|
position: 'absolute',
|
|
|
|
insetBlockStart: 0,
|
|
|
|
insetInlineStart: 0,
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
2022-06-01 10:14:57 +08:00
|
|
|
border: `${controlLineWidth}px ${controlLineType} ${radioDotColor}`,
|
2022-04-14 19:14:54 +08:00
|
|
|
borderRadius: '50%',
|
|
|
|
visibility: 'hidden',
|
2022-04-21 02:06:22 +08:00
|
|
|
animationName: antRadioEffect,
|
2022-06-01 10:14:57 +08:00
|
|
|
animationDuration: motionDurationSlow,
|
|
|
|
animationTimingFunction: motionEaseInOut,
|
2022-04-14 19:14:54 +08:00
|
|
|
animationFillMode: 'both',
|
|
|
|
content: '""',
|
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[componentCls]: {
|
2022-04-14 19:14:54 +08:00
|
|
|
...resetComponent(token),
|
|
|
|
position: 'relative',
|
2022-06-01 10:14:57 +08:00
|
|
|
insetBlockStart: radioTop,
|
2022-04-14 19:14:54 +08:00
|
|
|
display: 'inline-block',
|
|
|
|
outline: 'none',
|
|
|
|
cursor: 'pointer',
|
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${componentCls}-wrapper:hover &,
|
|
|
|
&:hover ${radioInnerPrefixCls},
|
|
|
|
&-input:focus + ${radioInnerPrefixCls}`]: {
|
|
|
|
borderColor: radioDotColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${componentCls}-input:focus + ${radioInnerPrefixCls}`]: {
|
|
|
|
boxShadow: radioFocusShadow,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${componentCls}:hover::after, ${componentCls}-wrapper:hover &::after`]: {
|
2022-04-14 19:14:54 +08:00
|
|
|
visibility: 'visible',
|
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${componentCls}-inner`]: {
|
2022-04-14 19:14:54 +08:00
|
|
|
'&::after': {
|
|
|
|
position: 'absolute',
|
|
|
|
insetBlockStart: '50%',
|
|
|
|
insetInlineStart: '50%',
|
|
|
|
display: 'block',
|
2022-06-01 10:14:57 +08:00
|
|
|
width: radioSize,
|
|
|
|
height: radioSize,
|
|
|
|
marginBlockStart: radioSize / -2,
|
|
|
|
marginInlineStart: radioSize / -2,
|
2022-09-08 09:55:10 +08:00
|
|
|
backgroundColor: radioButtonBg,
|
2022-04-14 19:14:54 +08:00
|
|
|
borderBlockStart: 0,
|
|
|
|
borderInlineStart: 0,
|
2022-06-01 10:14:57 +08:00
|
|
|
borderRadius: radioSize,
|
2022-04-14 19:14:54 +08:00
|
|
|
transform: 'scale(0)',
|
|
|
|
opacity: 0,
|
2022-06-01 10:14:57 +08:00
|
|
|
transition: `all ${motionDurationSlow} ${motionEaseInOutCirc}`,
|
2022-04-14 19:14:54 +08:00
|
|
|
content: '""',
|
|
|
|
},
|
|
|
|
|
|
|
|
position: 'relative',
|
|
|
|
insetBlockStart: 0,
|
|
|
|
insetInlineStart: 0,
|
|
|
|
display: 'block',
|
2022-06-01 10:14:57 +08:00
|
|
|
width: radioSize,
|
|
|
|
height: radioSize,
|
|
|
|
backgroundColor: radioButtonBg,
|
|
|
|
borderColor: colorBorder,
|
2022-04-14 19:14:54 +08:00
|
|
|
borderStyle: 'solid',
|
2022-06-01 10:14:57 +08:00
|
|
|
borderWidth: controlLineWidth,
|
2022-04-14 19:14:54 +08:00
|
|
|
borderRadius: '50%',
|
2022-09-07 14:08:14 +08:00
|
|
|
transition: `all ${motionDurationFast}`,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${componentCls}-input`]: {
|
2022-04-14 19:14:54 +08:00
|
|
|
position: 'absolute',
|
|
|
|
insetBlockStart: 0,
|
|
|
|
insetInlineEnd: 0,
|
|
|
|
insetBlockEnd: 0,
|
|
|
|
insetInlineStart: 0,
|
|
|
|
zIndex: 1,
|
|
|
|
cursor: 'pointer',
|
|
|
|
opacity: 0,
|
|
|
|
},
|
|
|
|
|
|
|
|
// 选中状态
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${componentCls}-checked`]: {
|
|
|
|
[radioInnerPrefixCls]: {
|
|
|
|
borderColor: radioDotColor,
|
2022-09-08 09:55:10 +08:00
|
|
|
backgroundColor: radioDotColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
|
|
|
|
'&::after': {
|
2022-06-01 10:14:57 +08:00
|
|
|
transform: `scale(${radioDotSize / radioSize})`,
|
2022-04-14 19:14:54 +08:00
|
|
|
opacity: 1,
|
2022-06-01 10:14:57 +08:00
|
|
|
transition: `all ${motionDurationSlow} ${motionEaseInOutCirc}`,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${componentCls}-disabled`]: {
|
2022-04-14 19:14:54 +08:00
|
|
|
cursor: 'not-allowed',
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[radioInnerPrefixCls]: {
|
2022-06-28 20:33:01 +08:00
|
|
|
backgroundColor: colorBgContainerDisabled,
|
2022-06-07 21:13:52 +08:00
|
|
|
borderColor: colorBorder,
|
2022-04-14 19:14:54 +08:00
|
|
|
cursor: 'not-allowed',
|
|
|
|
|
|
|
|
'&::after': {
|
2022-06-01 10:14:57 +08:00
|
|
|
backgroundColor: radioDotDisabledColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-input': {
|
|
|
|
cursor: 'not-allowed',
|
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${componentCls}-disabled + span`]: {
|
|
|
|
color: colorTextDisabled,
|
2022-04-14 19:14:54 +08:00
|
|
|
cursor: 'not-allowed',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[`span${componentCls} + *`]: {
|
|
|
|
paddingInlineStart: paddingXS,
|
|
|
|
paddingInlineEnd: paddingXS,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2022-06-01 10:14:57 +08:00
|
|
|
};
|
2022-04-14 19:14:54 +08:00
|
|
|
|
|
|
|
// Styles from radio-button
|
2022-06-01 10:14:57 +08:00
|
|
|
const getRadioButtonStyle: GenerateStyle<RadioToken> = token => {
|
|
|
|
const {
|
|
|
|
radioButtonColor,
|
|
|
|
controlHeight,
|
|
|
|
componentCls,
|
|
|
|
controlLineWidth,
|
|
|
|
controlLineType,
|
|
|
|
colorBorder,
|
|
|
|
motionDurationSlow,
|
2022-09-07 14:08:14 +08:00
|
|
|
motionDurationFast,
|
2022-06-01 10:14:57 +08:00
|
|
|
radioButtonPaddingHorizontal,
|
|
|
|
fontSize,
|
|
|
|
radioButtonBg,
|
|
|
|
fontSizeLG,
|
|
|
|
controlHeightLG,
|
|
|
|
controlHeightSM,
|
|
|
|
paddingXS,
|
|
|
|
controlRadius,
|
2022-08-19 10:10:51 +08:00
|
|
|
controlRadiusSM,
|
|
|
|
controlRadiusLG,
|
2022-06-01 10:14:57 +08:00
|
|
|
radioDotColor,
|
|
|
|
radioButtonFocusShadow,
|
|
|
|
radioButtonCheckedBg,
|
|
|
|
radioButtonHoverColor,
|
|
|
|
radioButtonActiveColor,
|
|
|
|
radioSolidCheckedColor,
|
|
|
|
colorTextDisabled,
|
2022-06-28 20:33:01 +08:00
|
|
|
colorBgContainerDisabled,
|
2022-06-01 10:14:57 +08:00
|
|
|
radioDisabledButtonCheckedColor,
|
|
|
|
radioDisabledButtonCheckedBg,
|
|
|
|
} = token;
|
2022-04-14 19:14:54 +08:00
|
|
|
return {
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${componentCls}-button-wrapper`]: {
|
2022-04-14 19:14:54 +08:00
|
|
|
position: 'relative',
|
|
|
|
display: 'inline-block',
|
2022-06-01 10:14:57 +08:00
|
|
|
height: controlHeight,
|
2022-04-14 19:14:54 +08:00
|
|
|
margin: 0,
|
2022-06-01 10:14:57 +08:00
|
|
|
paddingInline: radioButtonPaddingHorizontal,
|
2022-04-14 19:14:54 +08:00
|
|
|
paddingBlock: 0,
|
2022-06-01 10:14:57 +08:00
|
|
|
color: radioButtonColor,
|
|
|
|
fontSize,
|
|
|
|
lineHeight: `${controlHeight - controlLineWidth * 2}px`,
|
|
|
|
background: radioButtonBg,
|
|
|
|
border: `${controlLineWidth}px ${controlLineType} ${colorBorder}`,
|
2022-04-14 19:14:54 +08:00
|
|
|
// strange align fix for chrome but works
|
|
|
|
// https://gw.alipayobjects.com/zos/rmsportal/VFTfKXJuogBAXcvfAUWJ.gif
|
2022-06-01 10:14:57 +08:00
|
|
|
borderBlockStartWidth: controlLineWidth + 0.02,
|
2022-04-14 19:14:54 +08:00
|
|
|
borderInlineStartWidth: 0,
|
2022-06-01 10:14:57 +08:00
|
|
|
borderInlineEndWidth: controlLineWidth,
|
2022-04-14 19:14:54 +08:00
|
|
|
cursor: 'pointer',
|
2022-06-01 10:14:57 +08:00
|
|
|
transition: [
|
2022-09-07 14:08:14 +08:00
|
|
|
`color ${motionDurationFast}`,
|
|
|
|
`background ${motionDurationFast}`,
|
|
|
|
`border-color ${motionDurationFast}`,
|
|
|
|
`box-shadow ${motionDurationFast}`,
|
2022-06-01 10:14:57 +08:00
|
|
|
].join(','),
|
2022-04-14 19:14:54 +08:00
|
|
|
|
|
|
|
a: {
|
2022-06-01 10:14:57 +08:00
|
|
|
color: radioButtonColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[`> ${componentCls}-button`]: {
|
2022-04-14 19:14:54 +08:00
|
|
|
position: 'absolute',
|
|
|
|
insetBlockStart: 0,
|
|
|
|
insetInlineStart: 0,
|
|
|
|
zIndex: -1,
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:not(:first-child)': {
|
|
|
|
'&::before': {
|
|
|
|
position: 'absolute',
|
2022-06-01 10:14:57 +08:00
|
|
|
insetBlockStart: -controlLineWidth,
|
|
|
|
insetInlineStart: -controlLineWidth,
|
2022-04-14 19:14:54 +08:00
|
|
|
display: 'block',
|
|
|
|
boxSizing: 'content-box',
|
|
|
|
width: 1,
|
|
|
|
height: '100%',
|
2022-06-01 10:14:57 +08:00
|
|
|
paddingBlock: controlLineWidth,
|
2022-04-14 19:14:54 +08:00
|
|
|
paddingInline: 0,
|
2022-06-01 10:14:57 +08:00
|
|
|
backgroundColor: colorBorder,
|
|
|
|
transition: `background-color ${motionDurationSlow}`,
|
2022-04-14 19:14:54 +08:00
|
|
|
content: '""',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:first-child': {
|
2022-06-01 10:14:57 +08:00
|
|
|
borderInlineStart: `${controlLineWidth}px ${controlLineType} ${colorBorder}`,
|
|
|
|
borderStartStartRadius: controlRadius,
|
|
|
|
borderEndStartRadius: controlRadius,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&:last-child': {
|
2022-06-01 10:14:57 +08:00
|
|
|
borderStartEndRadius: controlRadius,
|
|
|
|
borderEndEndRadius: controlRadius,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&:first-child:last-child': {
|
2022-06-01 10:14:57 +08:00
|
|
|
borderRadius: controlRadius,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
|
2022-08-19 10:10:51 +08:00
|
|
|
[`${componentCls}-group-large &`]: {
|
|
|
|
height: controlHeightLG,
|
|
|
|
fontSize: fontSizeLG,
|
|
|
|
lineHeight: `${controlHeightLG - controlLineWidth * 2}px`,
|
|
|
|
|
|
|
|
'&:first-child': {
|
|
|
|
borderStartStartRadius: controlRadiusLG,
|
|
|
|
borderEndStartRadius: controlRadiusLG,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:last-child': {
|
|
|
|
borderStartEndRadius: controlRadiusLG,
|
|
|
|
borderEndEndRadius: controlRadiusLG,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-group-small &`]: {
|
|
|
|
height: controlHeightSM,
|
|
|
|
paddingInline: paddingXS - controlLineWidth,
|
|
|
|
paddingBlock: 0,
|
|
|
|
lineHeight: `${controlHeightSM - controlLineWidth * 2}px`,
|
|
|
|
|
|
|
|
'&:first-child': {
|
|
|
|
borderStartStartRadius: controlRadiusSM,
|
|
|
|
borderEndStartRadius: controlRadiusSM,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:last-child': {
|
|
|
|
borderStartEndRadius: controlRadiusSM,
|
|
|
|
borderEndEndRadius: controlRadiusSM,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-14 19:14:54 +08:00
|
|
|
'&:hover': {
|
|
|
|
position: 'relative',
|
2022-06-01 10:14:57 +08:00
|
|
|
color: radioDotColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&:focus-within': {
|
2022-06-01 10:14:57 +08:00
|
|
|
boxShadow: radioButtonFocusShadow,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${componentCls}-inner, input[type='checkbox'], input[type='radio']`]: {
|
2022-04-14 19:14:54 +08:00
|
|
|
width: 0,
|
|
|
|
height: 0,
|
|
|
|
opacity: 0,
|
|
|
|
pointerEvents: 'none',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-checked:not(&-disabled)': {
|
|
|
|
zIndex: 1,
|
2022-06-01 10:14:57 +08:00
|
|
|
color: radioDotColor,
|
|
|
|
background: radioButtonCheckedBg,
|
|
|
|
borderColor: radioDotColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
|
|
|
|
'&::before': {
|
2022-06-01 10:14:57 +08:00
|
|
|
backgroundColor: radioDotColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&:first-child': {
|
2022-06-01 10:14:57 +08:00
|
|
|
borderColor: radioDotColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&:hover': {
|
2022-06-01 10:14:57 +08:00
|
|
|
color: radioButtonHoverColor,
|
|
|
|
borderColor: radioButtonHoverColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
|
|
|
|
'&::before': {
|
2022-06-01 10:14:57 +08:00
|
|
|
backgroundColor: radioButtonHoverColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:active': {
|
2022-06-01 10:14:57 +08:00
|
|
|
color: radioButtonActiveColor,
|
|
|
|
borderColor: radioButtonActiveColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
|
|
|
|
'&::before': {
|
2022-06-01 10:14:57 +08:00
|
|
|
backgroundColor: radioButtonActiveColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:focus-within': {
|
2022-06-01 10:14:57 +08:00
|
|
|
boxShadow: radioButtonFocusShadow,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-06-01 10:14:57 +08:00
|
|
|
[`${componentCls}-group-solid &-checked:not(&-disabled)`]: {
|
|
|
|
color: radioSolidCheckedColor,
|
|
|
|
background: radioDotColor,
|
|
|
|
borderColor: radioDotColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
|
|
|
|
'&:hover': {
|
2022-06-01 10:14:57 +08:00
|
|
|
color: radioSolidCheckedColor,
|
|
|
|
background: radioButtonHoverColor,
|
|
|
|
borderColor: radioButtonHoverColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&:active': {
|
2022-06-01 10:14:57 +08:00
|
|
|
color: radioSolidCheckedColor,
|
|
|
|
background: radioButtonActiveColor,
|
|
|
|
borderColor: radioButtonActiveColor,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&:focus-within': {
|
2022-06-01 10:14:57 +08:00
|
|
|
boxShadow: radioButtonFocusShadow,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-disabled': {
|
2022-06-01 10:14:57 +08:00
|
|
|
color: colorTextDisabled,
|
2022-06-28 20:33:01 +08:00
|
|
|
backgroundColor: colorBgContainerDisabled,
|
2022-06-01 10:14:57 +08:00
|
|
|
borderColor: colorBorder,
|
2022-04-14 19:14:54 +08:00
|
|
|
cursor: 'not-allowed',
|
|
|
|
|
|
|
|
'&:first-child, &:hover': {
|
2022-06-01 10:14:57 +08:00
|
|
|
color: colorTextDisabled,
|
2022-06-28 20:33:01 +08:00
|
|
|
backgroundColor: colorBgContainerDisabled,
|
2022-06-01 10:14:57 +08:00
|
|
|
borderColor: colorBorder,
|
2022-04-14 19:14:54 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-disabled&-checked': {
|
2022-06-01 10:14:57 +08:00
|
|
|
color: radioDisabledButtonCheckedColor,
|
|
|
|
backgroundColor: radioDisabledButtonCheckedBg,
|
|
|
|
borderColor: colorBorder,
|
2022-04-14 19:14:54 +08:00
|
|
|
boxShadow: 'none',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2022-06-01 10:14:57 +08:00
|
|
|
};
|
2022-04-14 19:14:54 +08:00
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2022-06-01 10:14:57 +08:00
|
|
|
export default genComponentStyleHook('Radio', token => {
|
|
|
|
const {
|
|
|
|
padding,
|
|
|
|
controlLineWidth,
|
2022-06-28 20:33:01 +08:00
|
|
|
colorBgContainerDisabled,
|
2022-06-01 10:14:57 +08:00
|
|
|
colorTextDisabled,
|
2022-06-28 20:33:01 +08:00
|
|
|
colorBgContainer,
|
2022-06-01 10:14:57 +08:00
|
|
|
fontSize,
|
|
|
|
lineHeight,
|
|
|
|
fontSizeLG,
|
2022-07-21 17:00:42 +08:00
|
|
|
controlOutline,
|
2022-06-01 10:14:57 +08:00
|
|
|
colorPrimaryHover,
|
|
|
|
colorPrimaryActive,
|
|
|
|
colorText,
|
|
|
|
colorPrimary,
|
|
|
|
marginXS,
|
|
|
|
controlOutlineWidth,
|
2022-09-08 09:55:10 +08:00
|
|
|
fontSizeIcon,
|
2022-06-01 10:14:57 +08:00
|
|
|
} = token;
|
|
|
|
|
|
|
|
// Radio
|
2022-07-21 17:00:42 +08:00
|
|
|
const radioFocusShadow = `0 0 0 ${controlOutlineWidth}px ${controlOutline}`;
|
2022-06-01 10:14:57 +08:00
|
|
|
const radioButtonFocusShadow = radioFocusShadow;
|
|
|
|
|
|
|
|
const radioSize = fontSizeLG;
|
|
|
|
const radioTop = (Math.round(fontSize * lineHeight) - radioSize) / 2;
|
2022-09-08 09:55:10 +08:00
|
|
|
const radioDotSize = fontSizeIcon / 2;
|
2022-06-01 10:14:57 +08:00
|
|
|
const radioDotColor = colorPrimary;
|
|
|
|
|
|
|
|
// Radio buttons
|
|
|
|
const radioButtonColor = colorText;
|
|
|
|
const radioButtonHoverColor = colorPrimaryHover;
|
|
|
|
const radioButtonActiveColor = colorPrimaryActive;
|
|
|
|
const radioButtonPaddingHorizontal = padding - controlLineWidth;
|
|
|
|
const radioDisabledButtonCheckedColor = colorTextDisabled;
|
|
|
|
const radioWrapperMarginRight = marginXS;
|
|
|
|
|
|
|
|
const radioToken = mergeToken<RadioToken>(token, {
|
|
|
|
radioFocusShadow,
|
|
|
|
radioButtonFocusShadow,
|
|
|
|
radioSize,
|
|
|
|
radioTop,
|
|
|
|
radioDotSize,
|
|
|
|
radioDotColor,
|
|
|
|
radioDotDisabledColor: colorTextDisabled,
|
2022-06-28 20:33:01 +08:00
|
|
|
radioSolidCheckedColor: colorBgContainer,
|
|
|
|
radioButtonBg: colorBgContainer,
|
|
|
|
radioButtonCheckedBg: colorBgContainer,
|
2022-06-01 10:14:57 +08:00
|
|
|
radioButtonColor,
|
|
|
|
radioButtonHoverColor,
|
|
|
|
radioButtonActiveColor,
|
|
|
|
radioButtonPaddingHorizontal,
|
2022-06-28 20:33:01 +08:00
|
|
|
radioDisabledButtonCheckedBg: colorBgContainerDisabled,
|
2022-06-01 10:14:57 +08:00
|
|
|
radioDisabledButtonCheckedColor,
|
|
|
|
radioWrapperMarginRight,
|
|
|
|
});
|
2022-04-14 19:14:54 +08:00
|
|
|
|
|
|
|
return [
|
2022-06-01 10:14:57 +08:00
|
|
|
getGroupRadioStyle(radioToken),
|
|
|
|
getRadioBasicStyle(radioToken),
|
|
|
|
getRadioButtonStyle(radioToken),
|
2022-04-14 19:14:54 +08:00
|
|
|
];
|
2022-06-01 10:14:57 +08:00
|
|
|
});
|