123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _cssinjs = require("@ant-design/cssinjs");
- var _style = require("../../style");
- const accessibilityFocus = token => (0, _style.genFocusOutline)(token);
- const getThemeStyle = (token, themeSuffix) => {
- const {
- componentCls,
- itemColor,
- itemSelectedColor,
- subMenuItemSelectedColor,
- groupTitleColor,
- itemBg,
- subMenuItemBg,
- itemSelectedBg,
- activeBarHeight,
- activeBarWidth,
- activeBarBorderWidth,
- motionDurationSlow,
- motionEaseInOut,
- motionEaseOut,
- itemPaddingInline,
- motionDurationMid,
- itemHoverColor,
- lineType,
- colorSplit,
- // Disabled
- itemDisabledColor,
- // Danger
- dangerItemColor,
- dangerItemHoverColor,
- dangerItemSelectedColor,
- dangerItemActiveBg,
- dangerItemSelectedBg,
- // Bg
- popupBg,
- itemHoverBg,
- itemActiveBg,
- menuSubMenuBg,
- // Horizontal
- horizontalItemSelectedColor,
- horizontalItemSelectedBg,
- horizontalItemBorderRadius,
- horizontalItemHoverBg
- } = token;
- return {
- [`${componentCls}-${themeSuffix}, ${componentCls}-${themeSuffix} > ${componentCls}`]: {
- color: itemColor,
- background: itemBg,
- [`&${componentCls}-root:focus-visible`]: Object.assign({}, accessibilityFocus(token)),
- // ======================== Item ========================
- [`${componentCls}-item`]: {
- '&-group-title, &-extra': {
- color: groupTitleColor
- }
- },
- [`${componentCls}-submenu-selected > ${componentCls}-submenu-title`]: {
- color: subMenuItemSelectedColor
- },
- [`${componentCls}-item, ${componentCls}-submenu-title`]: {
- color: itemColor,
- [`&:not(${componentCls}-item-disabled):focus-visible`]: Object.assign({}, accessibilityFocus(token))
- },
- // Disabled
- [`${componentCls}-item-disabled, ${componentCls}-submenu-disabled`]: {
- color: `${itemDisabledColor} !important`
- },
- // Hover
- [`${componentCls}-item:not(${componentCls}-item-selected):not(${componentCls}-submenu-selected)`]: {
- [`&:hover, > ${componentCls}-submenu-title:hover`]: {
- color: itemHoverColor
- }
- },
- [`&:not(${componentCls}-horizontal)`]: {
- [`${componentCls}-item:not(${componentCls}-item-selected)`]: {
- '&:hover': {
- backgroundColor: itemHoverBg
- },
- '&:active': {
- backgroundColor: itemActiveBg
- }
- },
- [`${componentCls}-submenu-title`]: {
- '&:hover': {
- backgroundColor: itemHoverBg
- },
- '&:active': {
- backgroundColor: itemActiveBg
- }
- }
- },
- // Danger - only Item has
- [`${componentCls}-item-danger`]: {
- color: dangerItemColor,
- [`&${componentCls}-item:hover`]: {
- [`&:not(${componentCls}-item-selected):not(${componentCls}-submenu-selected)`]: {
- color: dangerItemHoverColor
- }
- },
- [`&${componentCls}-item:active`]: {
- background: dangerItemActiveBg
- }
- },
- [`${componentCls}-item a`]: {
- '&, &:hover': {
- color: 'inherit'
- }
- },
- [`${componentCls}-item-selected`]: {
- color: itemSelectedColor,
- // Danger
- [`&${componentCls}-item-danger`]: {
- color: dangerItemSelectedColor
- },
- 'a, a:hover': {
- color: 'inherit'
- }
- },
- [`& ${componentCls}-item-selected`]: {
- backgroundColor: itemSelectedBg,
- // Danger
- [`&${componentCls}-item-danger`]: {
- backgroundColor: dangerItemSelectedBg
- }
- },
- [`&${componentCls}-submenu > ${componentCls}`]: {
- backgroundColor: menuSubMenuBg
- },
- // ===== 设置浮层的颜色 =======
- // !dark 模式会被popupBg 会被rest 为 darkPopupBg
- [`&${componentCls}-popup > ${componentCls}`]: {
- backgroundColor: popupBg
- },
- [`&${componentCls}-submenu-popup > ${componentCls}`]: {
- backgroundColor: popupBg
- },
- // ===== 设置浮层的颜色 end =======
- // ====================== Horizontal ======================
- [`&${componentCls}-horizontal`]: Object.assign(Object.assign({}, themeSuffix === 'dark' ? {
- borderBottom: 0
- } : {}), {
- [`> ${componentCls}-item, > ${componentCls}-submenu`]: {
- top: activeBarBorderWidth,
- marginTop: token.calc(activeBarBorderWidth).mul(-1).equal(),
- marginBottom: 0,
- borderRadius: horizontalItemBorderRadius,
- '&::after': {
- position: 'absolute',
- insetInline: itemPaddingInline,
- bottom: 0,
- borderBottom: `${(0, _cssinjs.unit)(activeBarHeight)} solid transparent`,
- transition: `border-color ${motionDurationSlow} ${motionEaseInOut}`,
- content: '""'
- },
- '&:hover, &-active, &-open': {
- background: horizontalItemHoverBg,
- '&::after': {
- borderBottomWidth: activeBarHeight,
- borderBottomColor: horizontalItemSelectedColor
- }
- },
- '&-selected': {
- color: horizontalItemSelectedColor,
- backgroundColor: horizontalItemSelectedBg,
- '&:hover': {
- backgroundColor: horizontalItemSelectedBg
- },
- '&::after': {
- borderBottomWidth: activeBarHeight,
- borderBottomColor: horizontalItemSelectedColor
- }
- }
- }
- }),
- // ================== Inline & Vertical ===================
- //
- [`&${componentCls}-root`]: {
- [`&${componentCls}-inline, &${componentCls}-vertical`]: {
- borderInlineEnd: `${(0, _cssinjs.unit)(activeBarBorderWidth)} ${lineType} ${colorSplit}`
- }
- },
- // ======================== Inline ========================
- [`&${componentCls}-inline`]: {
- // Sub
- [`${componentCls}-sub${componentCls}-inline`]: {
- background: subMenuItemBg
- },
- [`${componentCls}-item`]: {
- position: 'relative',
- '&::after': {
- position: 'absolute',
- insetBlock: 0,
- insetInlineEnd: 0,
- borderInlineEnd: `${(0, _cssinjs.unit)(activeBarWidth)} solid ${itemSelectedColor}`,
- transform: 'scaleY(0.0001)',
- opacity: 0,
- transition: [`transform ${motionDurationMid} ${motionEaseOut}`, `opacity ${motionDurationMid} ${motionEaseOut}`].join(','),
- content: '""'
- },
- // Danger
- [`&${componentCls}-item-danger`]: {
- '&::after': {
- borderInlineEndColor: dangerItemSelectedColor
- }
- }
- },
- [`${componentCls}-selected, ${componentCls}-item-selected`]: {
- '&::after': {
- transform: 'scaleY(1)',
- opacity: 1,
- transition: [`transform ${motionDurationMid} ${motionEaseInOut}`, `opacity ${motionDurationMid} ${motionEaseInOut}`].join(',')
- }
- }
- }
- }
- };
- };
- var _default = exports.default = getThemeStyle;
|