2022-11-30 18:56:36 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2023-05-26 17:15:03 +08:00
|
|
|
import { TinyColor } from '@ctrl/tinycolor';
|
2023-11-17 14:09:58 +08:00
|
|
|
import type { CSSProperties } from 'react';
|
2023-05-26 17:15:03 +08:00
|
|
|
import { clearFix, resetComponent, resetIcon } from '../../style';
|
2022-07-28 20:33:10 +08:00
|
|
|
import { genCollapseMotion, initSlideMotion, initZoomMotion } from '../../style/motion';
|
2022-11-23 20:22:38 +08:00
|
|
|
import type { FullToken, GenerateStyle, UseComponentStyleResult } from '../../theme/internal';
|
|
|
|
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
|
2022-05-23 10:58:30 +08:00
|
|
|
import getHorizontalStyle from './horizontal';
|
|
|
|
import getRTLStyle from './rtl';
|
|
|
|
import getThemeStyle from './theme';
|
|
|
|
import getVerticalStyle from './vertical';
|
2017-06-30 21:07:01 +08:00
|
|
|
|
2022-04-20 15:31:04 +08:00
|
|
|
/** Component only token. Which will handle additional calculation of alias token */
|
2022-05-23 10:58:30 +08:00
|
|
|
export interface ComponentToken {
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 弹出菜单的宽度
|
|
|
|
* @descEN Width of popup menu
|
|
|
|
*/
|
2022-05-23 10:58:30 +08:00
|
|
|
dropdownWidth: number;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 弹出菜单的 z-index
|
|
|
|
* @descEN z-index of popup menu
|
|
|
|
*/
|
2022-05-23 10:58:30 +08:00
|
|
|
zIndexPopup: number;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Group
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `groupTitleColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorGroupTitle: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 分组标题文字颜色
|
|
|
|
* @descEN Color of group title text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
groupTitleColor: string;
|
2023-07-17 10:13:22 +08:00
|
|
|
/**
|
|
|
|
* @desc 分组标题文字高度
|
|
|
|
* @descEN line-height of group title
|
|
|
|
*/
|
|
|
|
groupTitleLineHeight: CSSProperties['lineHeight'];
|
|
|
|
/**
|
|
|
|
* @desc 分组标题文字大小
|
|
|
|
* @descEN font-size of group title
|
|
|
|
*/
|
|
|
|
groupTitleFontSize: number;
|
2022-07-28 20:33:10 +08:00
|
|
|
|
|
|
|
// radius
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `itemBorderRadius` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
radiusItem: number;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项的圆角
|
|
|
|
* @descEN Radius of menu item
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemBorderRadius: number;
|
|
|
|
|
|
|
|
/** @deprecated Use `subMenuItemBorderRadius` instead */
|
2022-10-18 17:04:06 +08:00
|
|
|
radiusSubMenuItem: number;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 子菜单项的圆角
|
|
|
|
* @descEN Radius of sub-menu item
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
subMenuItemBorderRadius: number;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Item Text
|
|
|
|
// > Default
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `itemColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemText: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项文字颜色
|
|
|
|
* @descEN Color of menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `itemHoverColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemTextHover: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项文字悬浮颜色
|
|
|
|
* @descEN Hover color of menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemHoverColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `horizontalItemHoverColor` instead */
|
2022-10-18 17:04:06 +08:00
|
|
|
colorItemTextHoverHorizontal: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 水平菜单项文字悬浮颜色
|
|
|
|
* @descEN Hover color of horizontal menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
horizontalItemHoverColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `itemSelectedColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemTextSelected: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项文字选中颜色
|
|
|
|
* @descEN Color of selected menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemSelectedColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `horizontalItemSelectedColor` instead */
|
2022-10-18 17:04:06 +08:00
|
|
|
colorItemTextSelectedHorizontal: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 水平菜单项文字选中颜色
|
|
|
|
* @descEN Color of selected horizontal menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
horizontalItemSelectedColor: string;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// > Disabled
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `itemDisabledColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemTextDisabled: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项文字禁用颜色
|
|
|
|
* @descEN Color of disabled menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemDisabledColor: string;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// > Danger
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `dangerItemColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorDangerItemText: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 危险菜单项文字颜色
|
|
|
|
* @descEN Color of danger menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `dangerItemHoverColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorDangerItemTextHover: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 危险菜单项文字悬浮颜色
|
|
|
|
* @descEN Hover color of danger menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemHoverColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `dangerItemSelectedColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorDangerItemTextSelected: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 危险菜单项文字选中颜色
|
|
|
|
* @descEN Color of selected danger menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemSelectedColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `dangerItemActiveBg` instead */
|
2022-09-19 22:17:26 +08:00
|
|
|
colorDangerItemBgActive: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 危险菜单项文字激活颜色
|
|
|
|
* @descEN Color of active danger menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemActiveBg: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `dangerItemSelectedBg` instead */
|
2022-09-19 22:17:26 +08:00
|
|
|
colorDangerItemBgSelected: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 危险菜单项文字选中颜色
|
|
|
|
* @descEN Color of selected danger menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemSelectedBg: string;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Item Bg
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `itemBg` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemBg: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项背景色
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemBg: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `itemHoverBg` instead */
|
2022-10-18 17:04:06 +08:00
|
|
|
colorItemBgHover: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项悬浮态背景色
|
|
|
|
* @descEN Background color of menu item when hover
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemHoverBg: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `subMenuItemBg` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorSubItemBg: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 子菜单项背景色
|
|
|
|
* @descEN Background color of sub-menu item
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
subMenuItemBg: string;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// > Default
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `itemActiveBg` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemBgActive: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项激活态背景色
|
|
|
|
* @descEN Background color of menu item when active
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemActiveBg: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `itemSelectedBg` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemBgSelected: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项选中态背景色
|
|
|
|
* @descEN Background color of menu item when selected
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemSelectedBg: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `horizontalItemSelectedBg` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemBgSelectedHorizontal: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 水平菜单项选中态背景色
|
|
|
|
* @descEN Background color of horizontal menu item when selected
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
horizontalItemSelectedBg: string;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Ink Bar
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `activeBarWidth` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorActiveBarWidth: number;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项指示条宽度
|
|
|
|
* @descEN Width of menu item active bar
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
activeBarWidth: number;
|
|
|
|
|
|
|
|
/** @deprecated Use `activeBarHeight` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorActiveBarHeight: number;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项指示条高度
|
|
|
|
* @descEN Height of menu item active bar
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
activeBarHeight: number;
|
|
|
|
|
|
|
|
/** @deprecated Use `activeBarBorderWidth` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorActiveBarBorderSize: number;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项指示条边框宽度
|
|
|
|
* @descEN Border width of menu item active bar
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
activeBarBorderWidth: number;
|
2022-10-18 17:04:06 +08:00
|
|
|
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项横向外间距
|
|
|
|
* @descEN Horizontal margin of menu item
|
|
|
|
*/
|
2022-10-18 17:04:06 +08:00
|
|
|
itemMarginInline: number;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 横向菜单项横悬浮态背景色
|
|
|
|
* @descEN Background color of horizontal menu item when hover
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
horizontalItemHoverBg: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 横向菜单项圆角
|
|
|
|
* @descEN Border radius of horizontal menu item
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
horizontalItemBorderRadius: number;
|
2023-07-17 10:13:22 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项高度
|
|
|
|
* @descEN Height of menu item
|
|
|
|
*/
|
|
|
|
itemHeight: number;
|
|
|
|
/**
|
|
|
|
* @desc 收起后的宽度
|
|
|
|
* @descEN Width when collapsed
|
|
|
|
*/
|
|
|
|
collapsedWidth: number;
|
|
|
|
/**
|
|
|
|
* @desc 弹出框背景色
|
|
|
|
* @descEN Background color of popup
|
|
|
|
*/
|
|
|
|
popupBg: string;
|
|
|
|
/**
|
|
|
|
* @desc 菜单项纵向外间距
|
|
|
|
* @descEN margin-block of menu item
|
|
|
|
*/
|
|
|
|
itemMarginBlock: CSSProperties['marginBlock'];
|
|
|
|
/**
|
|
|
|
* @desc 菜单项横向内间距
|
|
|
|
* @descEN padding-inline of menu item
|
|
|
|
*/
|
|
|
|
itemPaddingInline: CSSProperties['paddingInline'];
|
|
|
|
/**
|
|
|
|
* @desc 横向菜单行高
|
|
|
|
* @descEN LineHeight of horizontal menu item
|
|
|
|
*/
|
|
|
|
horizontalLineHeight: CSSProperties['lineHeight'];
|
|
|
|
/**
|
|
|
|
* @desc 图标与文字间距
|
|
|
|
* @descEN Spacing between icon and text
|
|
|
|
*/
|
|
|
|
iconMarginInlineEnd: CSSProperties['marginInlineEnd'];
|
|
|
|
/**
|
|
|
|
* @desc 图标尺寸
|
|
|
|
* @descEN Size of icon
|
|
|
|
*/
|
|
|
|
iconSize: number;
|
|
|
|
/**
|
|
|
|
* @desc 收起时图标尺寸
|
|
|
|
* @descEN Size of icon when collapsed
|
|
|
|
*/
|
|
|
|
collapsedIconSize: number;
|
|
|
|
|
|
|
|
// Dark
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项文字颜色
|
|
|
|
* @descEN Color of menu item text in dark mode
|
|
|
|
*/
|
|
|
|
darkItemColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的危险菜单项文字颜色
|
|
|
|
* @descEN Color of danger menu item text in dark mode
|
|
|
|
*/
|
|
|
|
darkDangerItemColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项背景
|
|
|
|
* @descEN Background of menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkItemBg: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的子菜单项背景
|
|
|
|
* @descEN Background of submenu item in dark mode
|
|
|
|
*/
|
|
|
|
darkSubMenuItemBg: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项选中颜色
|
|
|
|
* @descEN Color of selected menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkItemSelectedColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项选中背景
|
|
|
|
* @descEN Background of active menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkItemSelectedBg: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项悬浮背景
|
|
|
|
* @descEN Background of hovered menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkItemHoverBg: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的分组标题文字颜色
|
|
|
|
* @descEN Color of group title text in dark mode
|
|
|
|
*/
|
|
|
|
darkGroupTitleColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项悬浮颜色
|
|
|
|
* @descEN Color of hovered menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkItemHoverColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项禁用颜色
|
|
|
|
* @descEN Color of disabled menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkItemDisabledColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的危险菜单项选中背景
|
|
|
|
* @descEN Background of active danger menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkDangerItemSelectedBg: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的危险菜单项悬浮文字背景
|
|
|
|
* @descEN Background of hovered danger menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkDangerItemHoverColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的危险菜单项选中文字颜色
|
|
|
|
* @descEN Color of selected danger menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkDangerItemSelectedColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的危险菜单项激活态背景
|
|
|
|
* @descEN Background of active danger menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkDangerItemActiveBg: string;
|
2022-07-28 20:33:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface MenuToken extends FullToken<'Menu'> {
|
|
|
|
menuHorizontalHeight: number;
|
|
|
|
menuArrowSize: number;
|
|
|
|
menuArrowOffset: string;
|
|
|
|
menuPanelMaskInset: number;
|
2022-11-25 16:00:01 +08:00
|
|
|
menuSubMenuBg: string;
|
2022-05-23 10:58:30 +08:00
|
|
|
}
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-11-30 18:56:36 +08:00
|
|
|
const genMenuItemStyle = (token: MenuToken): CSSObject => {
|
|
|
|
const {
|
|
|
|
componentCls,
|
|
|
|
motionDurationSlow,
|
|
|
|
motionDurationMid,
|
|
|
|
motionEaseInOut,
|
|
|
|
motionEaseOut,
|
|
|
|
iconCls,
|
2023-07-17 10:13:22 +08:00
|
|
|
iconSize,
|
|
|
|
iconMarginInlineEnd,
|
2022-11-30 18:56:36 +08:00
|
|
|
} = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
// >>>>> Item
|
|
|
|
[`${componentCls}-item, ${componentCls}-submenu-title`]: {
|
|
|
|
position: 'relative',
|
|
|
|
display: 'block',
|
|
|
|
margin: 0,
|
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
cursor: 'pointer',
|
|
|
|
transition: [
|
|
|
|
`border-color ${motionDurationSlow}`,
|
|
|
|
`background ${motionDurationSlow}`,
|
|
|
|
`padding ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
].join(','),
|
|
|
|
|
|
|
|
[`${componentCls}-item-icon, ${iconCls}`]: {
|
2023-07-17 10:13:22 +08:00
|
|
|
minWidth: iconSize,
|
|
|
|
fontSize: iconSize,
|
2022-11-30 18:56:36 +08:00
|
|
|
transition: [
|
|
|
|
`font-size ${motionDurationMid} ${motionEaseOut}`,
|
|
|
|
`margin ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`color ${motionDurationSlow}`,
|
|
|
|
].join(','),
|
|
|
|
|
|
|
|
'+ span': {
|
2023-07-17 10:13:22 +08:00
|
|
|
marginInlineStart: iconMarginInlineEnd,
|
2022-11-30 18:56:36 +08:00
|
|
|
opacity: 1,
|
|
|
|
transition: [
|
|
|
|
`opacity ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`margin ${motionDurationSlow}`,
|
|
|
|
`color ${motionDurationSlow}`,
|
|
|
|
].join(','),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-item-icon`]: {
|
|
|
|
...resetIcon(),
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${componentCls}-item-only-child`]: {
|
|
|
|
[`> ${iconCls}, > ${componentCls}-item-icon`]: {
|
|
|
|
marginInlineEnd: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// Disabled state sets text to gray and nukes hover/tab effects
|
|
|
|
[`${componentCls}-item-disabled, ${componentCls}-submenu-disabled`]: {
|
|
|
|
background: 'none !important',
|
|
|
|
cursor: 'not-allowed',
|
|
|
|
|
|
|
|
'&::after': {
|
|
|
|
borderColor: 'transparent !important',
|
|
|
|
},
|
|
|
|
|
|
|
|
a: {
|
|
|
|
color: 'inherit !important',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`> ${componentCls}-submenu-title`]: {
|
|
|
|
color: 'inherit !important',
|
|
|
|
cursor: 'not-allowed',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genSubMenuArrowStyle = (token: MenuToken): CSSObject => {
|
|
|
|
const {
|
|
|
|
componentCls,
|
|
|
|
motionDurationSlow,
|
|
|
|
motionEaseInOut,
|
|
|
|
borderRadius,
|
|
|
|
menuArrowSize,
|
|
|
|
menuArrowOffset,
|
|
|
|
} = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
[`${componentCls}-submenu`]: {
|
|
|
|
[`&-expand-icon, &-arrow`]: {
|
|
|
|
position: 'absolute',
|
|
|
|
top: '50%',
|
|
|
|
insetInlineEnd: token.margin,
|
|
|
|
width: menuArrowSize,
|
|
|
|
color: 'currentcolor',
|
|
|
|
transform: 'translateY(-50%)',
|
2023-01-01 00:26:54 +08:00
|
|
|
transition: `transform ${motionDurationSlow} ${motionEaseInOut}, opacity ${motionDurationSlow}`,
|
2022-11-30 18:56:36 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&-arrow': {
|
|
|
|
// →
|
|
|
|
'&::before, &::after': {
|
|
|
|
position: 'absolute',
|
|
|
|
width: menuArrowSize * 0.6,
|
|
|
|
height: menuArrowSize * 0.15,
|
|
|
|
backgroundColor: 'currentcolor',
|
|
|
|
borderRadius,
|
|
|
|
transition: [
|
|
|
|
`background ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`transform ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`top ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`color ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
].join(','),
|
|
|
|
content: '""',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&::before': {
|
|
|
|
transform: `rotate(45deg) translateY(-${menuArrowOffset})`,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&::after': {
|
|
|
|
transform: `rotate(-45deg) translateY(${menuArrowOffset})`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// =============================== Base ===============================
|
2022-11-15 22:08:30 +08:00
|
|
|
const getBaseStyle: GenerateStyle<MenuToken> = (token) => {
|
2022-04-20 15:31:04 +08:00
|
|
|
const {
|
|
|
|
antCls,
|
2022-05-23 10:58:30 +08:00
|
|
|
componentCls,
|
|
|
|
fontSize,
|
2022-04-20 15:31:04 +08:00
|
|
|
motionDurationSlow,
|
2022-05-23 10:58:30 +08:00
|
|
|
motionDurationMid,
|
2022-04-20 15:31:04 +08:00
|
|
|
motionEaseInOut,
|
|
|
|
paddingXS,
|
2022-05-23 10:58:30 +08:00
|
|
|
padding,
|
2022-07-21 17:00:42 +08:00
|
|
|
colorSplit,
|
2022-05-23 10:58:30 +08:00
|
|
|
lineWidth,
|
|
|
|
zIndexPopup,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderRadiusLG,
|
2023-06-06 16:11:18 +08:00
|
|
|
subMenuItemBorderRadius,
|
2022-05-23 10:58:30 +08:00
|
|
|
menuArrowSize,
|
|
|
|
menuArrowOffset,
|
|
|
|
lineType,
|
|
|
|
menuPanelMaskInset,
|
2023-07-17 10:13:22 +08:00
|
|
|
groupTitleLineHeight,
|
|
|
|
groupTitleFontSize,
|
2022-04-20 15:31:04 +08:00
|
|
|
} = token;
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
return [
|
|
|
|
// Misc
|
|
|
|
{
|
|
|
|
'': {
|
2022-04-20 15:31:04 +08:00
|
|
|
[`${componentCls}`]: {
|
2022-11-20 01:08:15 +08:00
|
|
|
...clearFix(),
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Hidden
|
|
|
|
[`&-hidden`]: {
|
|
|
|
display: 'none',
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-submenu-hidden`]: {
|
|
|
|
display: 'none',
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
2022-05-23 10:58:30 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
[componentCls]: {
|
|
|
|
...resetComponent(token),
|
2022-11-17 18:37:48 +08:00
|
|
|
...clearFix(),
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
marginBottom: 0,
|
|
|
|
paddingInlineStart: 0, // Override default ul/ol
|
|
|
|
fontSize,
|
|
|
|
lineHeight: 0, // Fix display inline-block gap
|
|
|
|
listStyle: 'none',
|
|
|
|
outline: 'none',
|
2023-04-25 22:53:14 +08:00
|
|
|
// Magic cubic here but smooth transition
|
|
|
|
transition: `width ${motionDurationSlow} cubic-bezier(0.2, 0, 0, 1) 0s`,
|
2022-05-23 10:58:30 +08:00
|
|
|
|
|
|
|
[`ul, ol`]: {
|
|
|
|
margin: 0,
|
2022-04-20 15:31:04 +08:00
|
|
|
padding: 0,
|
2022-05-23 10:58:30 +08:00
|
|
|
listStyle: 'none',
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Overflow ellipsis
|
|
|
|
[`&-overflow`]: {
|
|
|
|
display: 'flex',
|
2022-04-20 15:31:04 +08:00
|
|
|
|
|
|
|
[`${componentCls}-item`]: {
|
2022-05-23 10:58:30 +08:00
|
|
|
flex: 'none',
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
2022-11-10 22:03:34 +08:00
|
|
|
[`${componentCls}-item, ${componentCls}-submenu, ${componentCls}-submenu-title`]: {
|
2023-06-06 16:11:18 +08:00
|
|
|
borderRadius: token.itemBorderRadius,
|
2022-07-28 20:33:10 +08:00
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-item-group-title`]: {
|
|
|
|
padding: `${paddingXS}px ${padding}px`,
|
2023-07-17 10:13:22 +08:00
|
|
|
fontSize: groupTitleFontSize,
|
|
|
|
lineHeight: groupTitleLineHeight,
|
2022-05-23 10:58:30 +08:00
|
|
|
transition: `all ${motionDurationSlow}`,
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`&-horizontal ${componentCls}-submenu`]: {
|
|
|
|
transition: [
|
|
|
|
`border-color ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`background ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
].join(','),
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-submenu, ${componentCls}-submenu-inline`]: {
|
|
|
|
transition: [
|
|
|
|
`border-color ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`background ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`padding ${motionDurationMid} ${motionEaseInOut}`,
|
|
|
|
].join(','),
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-submenu ${componentCls}-sub`]: {
|
|
|
|
cursor: 'initial',
|
|
|
|
transition: [
|
|
|
|
`background ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`padding ${motionDurationSlow} ${motionEaseInOut}`,
|
2022-12-25 22:55:47 +08:00
|
|
|
].join(','),
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-title-content`]: {
|
|
|
|
transition: `color ${motionDurationSlow}`,
|
2023-10-08 09:57:58 +08:00
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/41143
|
|
|
|
[`> ${antCls}-typography-ellipsis-single-line`]: {
|
|
|
|
display: 'inline',
|
|
|
|
verticalAlign: 'unset',
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-item a`]: {
|
|
|
|
'&::before': {
|
|
|
|
position: 'absolute',
|
|
|
|
inset: 0,
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
content: '""',
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Removed a Badge related style seems it's safe
|
|
|
|
// https://github.com/ant-design/ant-design/issues/19809
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// >>>>> Divider
|
|
|
|
[`${componentCls}-item-divider`]: {
|
|
|
|
overflow: 'hidden',
|
|
|
|
lineHeight: 0,
|
2022-07-21 17:00:42 +08:00
|
|
|
borderColor: colorSplit,
|
2022-05-23 10:58:30 +08:00
|
|
|
borderStyle: lineType,
|
2023-01-16 19:55:12 +08:00
|
|
|
borderWidth: 0,
|
2022-05-23 10:58:30 +08:00
|
|
|
borderTopWidth: lineWidth,
|
|
|
|
marginBlock: lineWidth,
|
|
|
|
padding: 0,
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
'&-dashed': {
|
|
|
|
borderStyle: 'dashed',
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-11-30 18:56:36 +08:00
|
|
|
// Item
|
|
|
|
...genMenuItemStyle(token),
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-item-group`]: {
|
|
|
|
[`${componentCls}-item-group-list`]: {
|
|
|
|
margin: 0,
|
|
|
|
padding: 0,
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-item, ${componentCls}-submenu-title`]: {
|
|
|
|
paddingInline: `${fontSize * 2}px ${padding}px`,
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// ======================= Sub Menu =======================
|
|
|
|
'&-submenu': {
|
|
|
|
'&-popup': {
|
|
|
|
position: 'absolute',
|
|
|
|
zIndex: zIndexPopup,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderRadius: borderRadiusLG,
|
2022-05-23 10:58:30 +08:00
|
|
|
boxShadow: 'none',
|
|
|
|
transformOrigin: '0 0',
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2023-05-26 17:15:03 +08:00
|
|
|
[`&${componentCls}-submenu`]: {
|
|
|
|
background: 'transparent',
|
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// https://github.com/ant-design/ant-design/issues/13955
|
|
|
|
'&::before': {
|
|
|
|
position: 'absolute',
|
|
|
|
inset: `${menuPanelMaskInset}px 0 0`,
|
|
|
|
zIndex: -1,
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
opacity: 0,
|
|
|
|
content: '""',
|
|
|
|
},
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// https://github.com/ant-design/ant-design/issues/13955
|
|
|
|
'&-placement-rightTop::before': {
|
|
|
|
top: 0,
|
|
|
|
insetInlineStart: menuPanelMaskInset,
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2023-05-26 17:15:03 +08:00
|
|
|
[`
|
|
|
|
&-placement-leftTop,
|
|
|
|
&-placement-bottomRight,
|
|
|
|
`]: {
|
|
|
|
transformOrigin: '100% 0',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
&-placement-leftBottom,
|
|
|
|
&-placement-topRight,
|
|
|
|
`]: {
|
|
|
|
transformOrigin: '100% 100%',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
&-placement-rightBottom,
|
|
|
|
&-placement-topLeft,
|
|
|
|
`]: {
|
|
|
|
transformOrigin: '0 100%',
|
|
|
|
},
|
|
|
|
|
2023-06-06 16:11:18 +08:00
|
|
|
[`
|
|
|
|
&-placement-bottomLeft,
|
|
|
|
&-placement-rightTop,
|
|
|
|
`]: {
|
|
|
|
transformOrigin: '0 0',
|
|
|
|
},
|
|
|
|
|
2023-05-26 17:15:03 +08:00
|
|
|
[`
|
|
|
|
&-placement-leftTop,
|
|
|
|
&-placement-leftBottom
|
|
|
|
`]: {
|
|
|
|
paddingInlineEnd: token.paddingXS,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
&-placement-rightTop,
|
|
|
|
&-placement-rightBottom
|
|
|
|
`]: {
|
|
|
|
paddingInlineStart: token.paddingXS,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
&-placement-topRight,
|
|
|
|
&-placement-topLeft
|
|
|
|
`]: {
|
|
|
|
paddingBottom: token.paddingXS,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
&-placement-bottomRight,
|
|
|
|
&-placement-bottomLeft
|
|
|
|
`]: {
|
|
|
|
paddingTop: token.paddingXS,
|
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`> ${componentCls}`]: {
|
2022-11-01 15:06:38 +08:00
|
|
|
borderRadius: borderRadiusLG,
|
2022-10-18 17:04:06 +08:00
|
|
|
|
2022-11-30 18:56:36 +08:00
|
|
|
...genMenuItemStyle(token),
|
|
|
|
...genSubMenuArrowStyle(token),
|
|
|
|
|
|
|
|
[`${componentCls}-item, ${componentCls}-submenu > ${componentCls}-submenu-title`]: {
|
2023-06-06 16:11:18 +08:00
|
|
|
borderRadius: subMenuItemBorderRadius,
|
2022-10-18 17:04:06 +08:00
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-submenu-title::after`]: {
|
|
|
|
transition: `transform ${motionDurationSlow} ${motionEaseInOut}`,
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-11-30 18:56:36 +08:00
|
|
|
...genSubMenuArrowStyle(token),
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`&-inline-collapsed ${componentCls}-submenu-arrow,
|
|
|
|
&-inline ${componentCls}-submenu-arrow`]: {
|
|
|
|
// ↓
|
2022-04-20 15:31:04 +08:00
|
|
|
'&::before': {
|
2022-05-23 10:58:30 +08:00
|
|
|
transform: `rotate(-45deg) translateX(${menuArrowOffset})`,
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&::after': {
|
2022-05-23 10:58:30 +08:00
|
|
|
transform: `rotate(45deg) translateX(-${menuArrowOffset})`,
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-submenu-open${componentCls}-submenu-inline > ${componentCls}-submenu-title > ${componentCls}-submenu-arrow`]:
|
|
|
|
{
|
|
|
|
// ↑
|
|
|
|
transform: `translateY(-${menuArrowSize * 0.2}px)`,
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
'&::after': {
|
|
|
|
transform: `rotate(-45deg) translateX(-${menuArrowOffset})`,
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
'&::before': {
|
|
|
|
transform: `rotate(45deg) translateX(${menuArrowOffset})`,
|
|
|
|
},
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// Integration with header element so menu items have the same height
|
2022-05-23 10:58:30 +08:00
|
|
|
{
|
|
|
|
[`${antCls}-layout-header`]: {
|
|
|
|
[componentCls]: {
|
|
|
|
lineHeight: 'inherit',
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
2022-05-23 10:58:30 +08:00
|
|
|
];
|
2022-04-20 15:31:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2022-04-25 10:54:00 +08:00
|
|
|
export default (prefixCls: string, injectStyle: boolean): UseComponentStyleResult => {
|
2022-05-23 10:58:30 +08:00
|
|
|
const useOriginHook = genComponentStyleHook(
|
|
|
|
'Menu',
|
2023-07-17 10:13:22 +08:00
|
|
|
(token) => {
|
2022-05-23 10:58:30 +08:00
|
|
|
// Dropdown will handle menu style self. We do not need to handle this.
|
|
|
|
if (injectStyle === false) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2023-03-27 10:08:22 +08:00
|
|
|
const {
|
|
|
|
colorBgElevated,
|
|
|
|
colorPrimary,
|
|
|
|
colorTextLightSolid,
|
|
|
|
controlHeightLG,
|
|
|
|
fontSize,
|
2023-07-17 10:13:22 +08:00
|
|
|
darkItemColor,
|
|
|
|
darkDangerItemColor,
|
|
|
|
darkItemBg,
|
|
|
|
darkSubMenuItemBg,
|
|
|
|
darkItemSelectedColor,
|
|
|
|
darkItemSelectedBg,
|
|
|
|
darkDangerItemSelectedBg,
|
|
|
|
darkItemHoverBg,
|
|
|
|
darkGroupTitleColor,
|
|
|
|
darkItemHoverColor,
|
|
|
|
darkItemDisabledColor,
|
|
|
|
darkDangerItemHoverColor,
|
|
|
|
darkDangerItemSelectedColor,
|
|
|
|
darkDangerItemActiveBg,
|
2023-03-27 10:08:22 +08:00
|
|
|
} = token;
|
2022-05-23 10:58:30 +08:00
|
|
|
|
|
|
|
const menuArrowSize = (fontSize / 7) * 5;
|
|
|
|
|
|
|
|
// Menu Token
|
|
|
|
const menuToken = mergeToken<MenuToken>(token, {
|
|
|
|
menuArrowSize,
|
|
|
|
menuHorizontalHeight: controlHeightLG * 1.15,
|
|
|
|
menuArrowOffset: `${menuArrowSize * 0.25}px`,
|
|
|
|
menuPanelMaskInset: -7, // Still a hardcode here since it's offset by rc-align
|
2022-11-25 16:00:01 +08:00
|
|
|
menuSubMenuBg: colorBgElevated,
|
2022-05-23 10:58:30 +08:00
|
|
|
});
|
|
|
|
|
2023-07-17 10:13:22 +08:00
|
|
|
const menuDarkToken = mergeToken<MenuToken>(menuToken, {
|
|
|
|
itemColor: darkItemColor,
|
|
|
|
itemHoverColor: darkItemHoverColor,
|
|
|
|
groupTitleColor: darkGroupTitleColor,
|
|
|
|
itemSelectedColor: darkItemSelectedColor,
|
|
|
|
itemBg: darkItemBg,
|
2023-11-17 14:09:58 +08:00
|
|
|
popupBg: darkItemBg,
|
2023-07-17 10:13:22 +08:00
|
|
|
subMenuItemBg: darkSubMenuItemBg,
|
|
|
|
itemActiveBg: 'transparent',
|
|
|
|
itemSelectedBg: darkItemSelectedBg,
|
|
|
|
activeBarHeight: 0,
|
|
|
|
activeBarBorderWidth: 0,
|
|
|
|
itemHoverBg: darkItemHoverBg,
|
2023-01-09 16:50:08 +08:00
|
|
|
|
2023-07-17 10:13:22 +08:00
|
|
|
// Disabled
|
|
|
|
itemDisabledColor: darkItemDisabledColor,
|
|
|
|
|
|
|
|
// Danger
|
|
|
|
dangerItemColor: darkDangerItemColor,
|
|
|
|
dangerItemHoverColor: darkDangerItemHoverColor,
|
|
|
|
dangerItemSelectedColor: darkDangerItemSelectedColor,
|
|
|
|
dangerItemActiveBg: darkDangerItemActiveBg,
|
|
|
|
dangerItemSelectedBg: darkDangerItemSelectedBg,
|
|
|
|
|
|
|
|
menuSubMenuBg: darkSubMenuItemBg,
|
|
|
|
|
|
|
|
// Horizontal
|
|
|
|
horizontalItemSelectedColor: colorTextLightSolid,
|
|
|
|
horizontalItemSelectedBg: colorPrimary,
|
|
|
|
});
|
2022-09-19 22:17:26 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
return [
|
|
|
|
// Basic
|
|
|
|
getBaseStyle(menuToken),
|
|
|
|
|
|
|
|
// Horizontal
|
2022-07-28 20:33:10 +08:00
|
|
|
getHorizontalStyle(menuToken), // Hard code for some light style
|
2022-05-23 10:58:30 +08:00
|
|
|
|
|
|
|
// Vertical
|
2022-07-28 20:33:10 +08:00
|
|
|
getVerticalStyle(menuToken), // Hard code for some light style
|
2022-05-23 10:58:30 +08:00
|
|
|
|
|
|
|
// Theme
|
2022-09-19 22:17:26 +08:00
|
|
|
getThemeStyle(menuToken, 'light'),
|
|
|
|
getThemeStyle(menuDarkToken, 'dark'),
|
2022-05-23 10:58:30 +08:00
|
|
|
|
|
|
|
// RTL
|
|
|
|
getRTLStyle(menuToken),
|
2022-07-19 22:53:38 +08:00
|
|
|
|
|
|
|
// Motion
|
|
|
|
genCollapseMotion(menuToken),
|
2022-07-28 20:33:10 +08:00
|
|
|
|
|
|
|
initSlideMotion(menuToken, 'slide-up'),
|
|
|
|
initSlideMotion(menuToken, 'slide-down'),
|
|
|
|
initZoomMotion(menuToken, 'zoom-big'),
|
2022-05-23 10:58:30 +08:00
|
|
|
];
|
|
|
|
},
|
2022-11-15 22:08:30 +08:00
|
|
|
(token) => {
|
2022-07-28 20:33:10 +08:00
|
|
|
const {
|
|
|
|
colorPrimary,
|
|
|
|
colorError,
|
|
|
|
colorTextDisabled,
|
|
|
|
colorErrorBg,
|
|
|
|
colorText,
|
2022-08-04 16:16:50 +08:00
|
|
|
colorTextDescription,
|
2022-07-28 20:33:10 +08:00
|
|
|
colorBgContainer,
|
|
|
|
colorFillAlter,
|
2022-10-18 17:04:06 +08:00
|
|
|
colorFillContent,
|
2022-07-28 20:33:10 +08:00
|
|
|
lineWidth,
|
|
|
|
lineWidthBold,
|
2022-12-09 22:04:26 +08:00
|
|
|
controlItemBgActive,
|
2022-10-18 17:04:06 +08:00
|
|
|
colorBgTextHover,
|
2023-07-17 10:13:22 +08:00
|
|
|
controlHeightLG,
|
|
|
|
lineHeight,
|
|
|
|
colorBgElevated,
|
|
|
|
marginXXS,
|
|
|
|
padding,
|
|
|
|
fontSize,
|
|
|
|
controlHeightSM,
|
|
|
|
fontSizeLG,
|
|
|
|
colorTextLightSolid,
|
|
|
|
colorErrorHover,
|
2022-07-28 20:33:10 +08:00
|
|
|
} = token;
|
|
|
|
|
2023-07-17 10:13:22 +08:00
|
|
|
const colorTextDark = new TinyColor(colorTextLightSolid).setAlpha(0.65).toRgbString();
|
|
|
|
|
2022-07-28 20:33:10 +08:00
|
|
|
return {
|
|
|
|
dropdownWidth: 160,
|
|
|
|
zIndexPopup: token.zIndexPopupBase + 50,
|
2022-11-01 15:06:38 +08:00
|
|
|
radiusItem: token.borderRadiusLG,
|
2023-06-06 16:11:18 +08:00
|
|
|
itemBorderRadius: token.borderRadiusLG,
|
2022-11-01 15:06:38 +08:00
|
|
|
radiusSubMenuItem: token.borderRadiusSM,
|
2023-06-06 16:11:18 +08:00
|
|
|
subMenuItemBorderRadius: token.borderRadiusSM,
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemText: colorText,
|
2023-06-06 16:11:18 +08:00
|
|
|
itemColor: colorText,
|
2022-10-18 17:04:06 +08:00
|
|
|
colorItemTextHover: colorText,
|
2023-06-06 16:11:18 +08:00
|
|
|
itemHoverColor: colorText,
|
2022-10-18 17:04:06 +08:00
|
|
|
colorItemTextHoverHorizontal: colorPrimary,
|
2023-06-06 16:11:18 +08:00
|
|
|
horizontalItemHoverColor: colorPrimary,
|
2022-08-04 16:16:50 +08:00
|
|
|
colorGroupTitle: colorTextDescription,
|
2023-06-06 16:11:18 +08:00
|
|
|
groupTitleColor: colorTextDescription,
|
2022-12-09 22:04:26 +08:00
|
|
|
colorItemTextSelected: colorPrimary,
|
2023-06-06 16:11:18 +08:00
|
|
|
itemSelectedColor: colorPrimary,
|
2022-10-18 17:04:06 +08:00
|
|
|
colorItemTextSelectedHorizontal: colorPrimary,
|
2023-06-06 16:11:18 +08:00
|
|
|
horizontalItemSelectedColor: colorPrimary,
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemBg: colorBgContainer,
|
2023-06-06 16:11:18 +08:00
|
|
|
itemBg: colorBgContainer,
|
2022-10-18 17:04:06 +08:00
|
|
|
colorItemBgHover: colorBgTextHover,
|
2023-06-06 16:11:18 +08:00
|
|
|
itemHoverBg: colorBgTextHover,
|
2022-10-18 17:04:06 +08:00
|
|
|
colorItemBgActive: colorFillContent,
|
2023-07-19 18:52:07 +08:00
|
|
|
itemActiveBg: controlItemBgActive,
|
2022-07-28 20:33:10 +08:00
|
|
|
colorSubItemBg: colorFillAlter,
|
2023-06-06 16:11:18 +08:00
|
|
|
subMenuItemBg: colorFillAlter,
|
2022-12-09 22:04:26 +08:00
|
|
|
colorItemBgSelected: controlItemBgActive,
|
2023-06-06 16:11:18 +08:00
|
|
|
itemSelectedBg: controlItemBgActive,
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemBgSelectedHorizontal: 'transparent',
|
2023-06-06 16:11:18 +08:00
|
|
|
horizontalItemSelectedBg: 'transparent',
|
2022-10-18 17:04:06 +08:00
|
|
|
colorActiveBarWidth: 0,
|
2023-06-06 16:11:18 +08:00
|
|
|
activeBarWidth: 0,
|
2022-07-28 20:33:10 +08:00
|
|
|
colorActiveBarHeight: lineWidthBold,
|
2023-06-06 16:11:18 +08:00
|
|
|
activeBarHeight: lineWidthBold,
|
2022-07-28 20:33:10 +08:00
|
|
|
colorActiveBarBorderSize: lineWidth,
|
2023-06-06 16:11:18 +08:00
|
|
|
activeBarBorderWidth: lineWidth,
|
2022-07-28 20:33:10 +08:00
|
|
|
|
|
|
|
// Disabled
|
|
|
|
colorItemTextDisabled: colorTextDisabled,
|
2023-06-06 16:11:18 +08:00
|
|
|
itemDisabledColor: colorTextDisabled,
|
2022-07-28 20:33:10 +08:00
|
|
|
|
|
|
|
// Danger
|
|
|
|
colorDangerItemText: colorError,
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemColor: colorError,
|
2022-07-28 20:33:10 +08:00
|
|
|
colorDangerItemTextHover: colorError,
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemHoverColor: colorError,
|
2022-07-28 20:33:10 +08:00
|
|
|
colorDangerItemTextSelected: colorError,
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemSelectedColor: colorError,
|
2022-07-28 20:33:10 +08:00
|
|
|
colorDangerItemBgActive: colorErrorBg,
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemActiveBg: colorErrorBg,
|
2022-07-28 20:33:10 +08:00
|
|
|
colorDangerItemBgSelected: colorErrorBg,
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemSelectedBg: colorErrorBg,
|
2022-10-18 17:04:06 +08:00
|
|
|
|
|
|
|
itemMarginInline: token.marginXXS,
|
2023-06-06 16:11:18 +08:00
|
|
|
|
|
|
|
horizontalItemBorderRadius: 0,
|
|
|
|
horizontalItemHoverBg: 'transparent',
|
2023-07-17 10:13:22 +08:00
|
|
|
itemHeight: controlHeightLG,
|
|
|
|
groupTitleLineHeight: lineHeight,
|
|
|
|
collapsedWidth: controlHeightLG * 2,
|
|
|
|
popupBg: colorBgElevated,
|
|
|
|
itemMarginBlock: marginXXS,
|
|
|
|
itemPaddingInline: padding,
|
|
|
|
horizontalLineHeight: `${controlHeightLG * 1.15}px`,
|
|
|
|
iconSize: fontSize,
|
|
|
|
iconMarginInlineEnd: controlHeightSM - fontSize,
|
|
|
|
collapsedIconSize: fontSizeLG,
|
|
|
|
groupTitleFontSize: fontSize,
|
|
|
|
|
|
|
|
// Disabled
|
|
|
|
darkItemDisabledColor: new TinyColor(colorTextLightSolid).setAlpha(0.25).toRgbString(),
|
|
|
|
|
|
|
|
// Dark
|
|
|
|
darkItemColor: colorTextDark,
|
|
|
|
darkDangerItemColor: colorError,
|
|
|
|
darkItemBg: '#001529',
|
|
|
|
darkSubMenuItemBg: '#000c17',
|
|
|
|
darkItemSelectedColor: colorTextLightSolid,
|
|
|
|
darkItemSelectedBg: colorPrimary,
|
|
|
|
darkDangerItemSelectedBg: colorError,
|
|
|
|
darkItemHoverBg: 'transparent',
|
|
|
|
darkGroupTitleColor: colorTextDark,
|
|
|
|
darkItemHoverColor: colorTextLightSolid,
|
|
|
|
darkDangerItemHoverColor: colorErrorHover,
|
|
|
|
darkDangerItemSelectedColor: colorTextLightSolid,
|
|
|
|
darkDangerItemActiveBg: colorError,
|
2022-07-28 20:33:10 +08:00
|
|
|
};
|
|
|
|
},
|
2023-06-06 16:11:18 +08:00
|
|
|
{
|
|
|
|
deprecatedTokens: [
|
|
|
|
['colorGroupTitle', 'groupTitleColor'],
|
|
|
|
['radiusItem', 'itemBorderRadius'],
|
|
|
|
['radiusSubMenuItem', 'subMenuItemBorderRadius'],
|
|
|
|
['colorItemText', 'itemColor'],
|
|
|
|
['colorItemTextHover', 'itemHoverColor'],
|
|
|
|
['colorItemTextHoverHorizontal', 'horizontalItemHoverColor'],
|
|
|
|
['colorItemTextSelected', 'itemSelectedColor'],
|
|
|
|
['colorItemTextSelectedHorizontal', 'horizontalItemSelectedColor'],
|
|
|
|
['colorItemTextDisabled', 'itemDisabledColor'],
|
|
|
|
['colorDangerItemText', 'dangerItemColor'],
|
|
|
|
['colorDangerItemTextHover', 'dangerItemHoverColor'],
|
|
|
|
['colorDangerItemTextSelected', 'dangerItemSelectedColor'],
|
|
|
|
['colorDangerItemBgActive', 'dangerItemActiveBg'],
|
|
|
|
['colorDangerItemBgSelected', 'dangerItemSelectedBg'],
|
|
|
|
['colorItemBg', 'itemBg'],
|
|
|
|
['colorItemBgHover', 'itemHoverBg'],
|
|
|
|
['colorSubItemBg', 'subMenuItemBg'],
|
|
|
|
['colorItemBgActive', 'itemActiveBg'],
|
|
|
|
['colorItemBgSelectedHorizontal', 'horizontalItemSelectedBg'],
|
|
|
|
['colorActiveBarWidth', 'activeBarWidth'],
|
|
|
|
['colorActiveBarHeight', 'activeBarHeight'],
|
|
|
|
['colorActiveBarBorderSize', 'activeBarBorderWidth'],
|
2023-07-10 10:36:35 +08:00
|
|
|
['colorItemBgSelected', 'itemSelectedBg'],
|
2023-06-06 16:11:18 +08:00
|
|
|
],
|
|
|
|
},
|
2022-05-23 10:58:30 +08:00
|
|
|
);
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-04-25 10:54:00 +08:00
|
|
|
return useOriginHook(prefixCls);
|
|
|
|
};
|