|
|
|
import type { CSSInterpolation } from '@ant-design/cssinjs';
|
|
|
|
import { genFocusOutline } from '../../style';
|
|
|
|
import type { MenuToken } from '.';
|
|
|
|
|
|
|
|
const accessibilityFocus = (token: MenuToken) => ({
|
|
|
|
...genFocusOutline(token),
|
|
|
|
});
|
|
|
|
|
|
|
|
const getThemeStyle = (token: MenuToken, themeSuffix: string): CSSInterpolation => {
|
|
|
|
const {
|
|
|
|
componentCls,
|
|
|
|
colorItemText,
|
|
|
|
colorItemTextSelected,
|
|
|
|
colorItemTextSelectedHorizontal,
|
|
|
|
colorGroupTitle,
|
|
|
|
colorItemBg,
|
|
|
|
colorSubItemBg,
|
|
|
|
colorItemBgSelectedHorizontal,
|
|
|
|
colorItemBgSelected,
|
|
|
|
colorActiveBarHeight,
|
|
|
|
colorActiveBarWidth,
|
|
|
|
colorActiveBarBorderSize,
|
|
|
|
motionDurationSlow,
|
|
|
|
motionEaseInOut,
|
|
|
|
motionEaseOut,
|
|
|
|
menuItemPaddingInline,
|
|
|
|
motionDurationMid,
|
|
|
|
colorItemTextHover,
|
|
|
|
lineType,
|
|
|
|
colorSplit,
|
|
|
|
|
|
|
|
// Disabled
|
|
|
|
colorItemTextDisabled,
|
|
|
|
|
|
|
|
// Danger
|
|
|
|
colorDangerItemText,
|
|
|
|
colorDangerItemTextHover,
|
|
|
|
colorDangerItemTextSelected,
|
|
|
|
colorDangerItemBgActive,
|
|
|
|
colorDangerItemBgSelected,
|
|
|
|
|
|
|
|
colorItemBgHover,
|
|
|
|
menuSubMenuBg,
|
|
|
|
} = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
[`${componentCls}-${themeSuffix}`]: {
|
|
|
|
color: colorItemText,
|
|
|
|
background: colorItemBg,
|
|
|
|
|
|
|
|
[`&${componentCls}-root:focus-visible`]: {
|
|
|
|
...accessibilityFocus(token),
|
|
|
|
},
|
|
|
|
|
|
|
|
// ======================== Item ========================
|
|
|
|
[`${componentCls}-item-group-title`]: {
|
|
|
|
color: colorGroupTitle,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-submenu-selected`]: {
|
|
|
|
[`> ${componentCls}-submenu-title`]: {
|
|
|
|
color: colorItemTextSelected,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// Disabled
|
|
|
|
[`${componentCls}-item-disabled, ${componentCls}-submenu-disabled`]: {
|
|
|
|
color: `${colorItemTextDisabled} !important`,
|
|
|
|
},
|
|
|
|
|
|
|
|
// Hover
|
|
|
|
[`${componentCls}-item:hover, ${componentCls}-submenu-title:hover`]: {
|
|
|
|
[`&:not(${componentCls}-item-selected):not(${componentCls}-submenu-selected)`]: {
|
|
|
|
color: colorItemTextHover,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&:not(${componentCls}-horizontal)`]: {
|
|
|
|
[`${componentCls}-item:not(${componentCls}-item-selected)`]: {
|
|
|
|
'&:hover': {
|
|
|
|
backgroundColor: colorItemBgHover,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:active': {
|
|
|
|
backgroundColor: colorItemBgSelected,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[`${componentCls}-submenu-title`]: {
|
|
|
|
'&:hover': {
|
|
|
|
backgroundColor: colorItemBgHover,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:active': {
|
|
|
|
backgroundColor: colorItemBgSelected,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// Danger - only Item has
|
|
|
|
[`${componentCls}-item-danger`]: {
|
|
|
|
color: colorDangerItemText,
|
|
|
|
|
|
|
|
[ |