fix: menu icon
parent
b8c52b34cb
commit
6b2af5c038
|
@ -33,7 +33,7 @@ export default defineComponent({
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: menuItemProps,
|
props: menuItemProps,
|
||||||
emits: ['mouseenter', 'mouseleave', 'click', 'keydown', 'focus'],
|
emits: ['mouseenter', 'mouseleave', 'click', 'keydown', 'focus'],
|
||||||
slots: ['icon'],
|
slots: ['icon', 'title'],
|
||||||
setup(props, { slots, emit, attrs }) {
|
setup(props, { slots, emit, attrs }) {
|
||||||
const instance = getCurrentInstance();
|
const instance = getCurrentInstance();
|
||||||
const key = instance.vnode.key;
|
const key = instance.vnode.key;
|
||||||
|
@ -149,6 +149,7 @@ export default defineComponent({
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderItemChildren = (icon: any, children: any) => {
|
const renderItemChildren = (icon: any, children: any) => {
|
||||||
|
const wrapNode = <span class={`${prefixCls.value}-title-content`}>{children}</span>;
|
||||||
// inline-collapsed.md demo 依赖 span 来隐藏文字,有 icon 属性,则内部包裹一个 span
|
// inline-collapsed.md demo 依赖 span 来隐藏文字,有 icon 属性,则内部包裹一个 span
|
||||||
// ref: https://github.com/ant-design/ant-design/pull/23456
|
// ref: https://github.com/ant-design/ant-design/pull/23456
|
||||||
if (!icon || (isValidElement(children) && children.type === 'span')) {
|
if (!icon || (isValidElement(children) && children.type === 'span')) {
|
||||||
|
@ -157,16 +158,15 @@ export default defineComponent({
|
||||||
<div class={`${prefixCls.value}-inline-collapsed-noicon`}>{children.charAt(0)}</div>
|
<div class={`${prefixCls.value}-inline-collapsed-noicon`}>{children.charAt(0)}</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return children;
|
|
||||||
}
|
}
|
||||||
return <span class={`${prefixCls.value}-title-content`}>{children}</span>;
|
return wrapNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ========================== DirectionStyle ==========================
|
// ========================== DirectionStyle ==========================
|
||||||
const directionStyle = useDirectionStyle(computed(() => keysPath.value.length));
|
const directionStyle = useDirectionStyle(computed(() => keysPath.value.length));
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const { title } = props;
|
const title = props.title ?? slots.title?.();
|
||||||
const children = flattenChildren(slots.default?.());
|
const children = flattenChildren(slots.default?.());
|
||||||
const childrenLength = children.length;
|
const childrenLength = children.length;
|
||||||
let tooltipTitle: any = title;
|
let tooltipTitle: any = title;
|
||||||
|
|
|
@ -188,7 +188,7 @@ export default defineComponent({
|
||||||
typeof title === 'string' ? (
|
typeof title === 'string' ? (
|
||||||
<div class={`${prefixCls.value}-inline-collapsed-noicon`}>{title.charAt(0)}</div>
|
<div class={`${prefixCls.value}-inline-collapsed-noicon`}>{title.charAt(0)}</div>
|
||||||
) : (
|
) : (
|
||||||
title
|
<span class={`${prefixCls.value}-title-content`}>{title}</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// inline-collapsed.md demo 依赖 span 来隐藏文字,有 icon 属性,则内部包裹一个 span
|
// inline-collapsed.md demo 依赖 span 来隐藏文字,有 icon 属性,则内部包裹一个 span
|
||||||
|
@ -223,6 +223,10 @@ export default defineComponent({
|
||||||
return res ? getTransitionProps(res.name) : undefined;
|
return res ? getTransitionProps(res.name) : undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const subMenuTriggerModeRef = computed(() =>
|
||||||
|
triggerModeRef.value === 'horizontal' ? 'vertical' : triggerModeRef.value,
|
||||||
|
);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const icon = getPropsSlot(slots, props, 'icon');
|
const icon = getPropsSlot(slots, props, 'icon');
|
||||||
const title = renderTitle(getPropsSlot(slots, props, 'title'), icon);
|
const title = renderTitle(getPropsSlot(slots, props, 'title'), icon);
|
||||||
|
@ -268,7 +272,7 @@ export default defineComponent({
|
||||||
popup: ({ visible }) => (
|
popup: ({ visible }) => (
|
||||||
<MenuContextProvider
|
<MenuContextProvider
|
||||||
props={{
|
props={{
|
||||||
mode: computed(() => (triggerMode === 'horizontal' ? 'vertical' : triggerMode)),
|
mode: subMenuTriggerModeRef,
|
||||||
isRootMenu: false,
|
isRootMenu: false,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
|
@ -87,8 +87,7 @@
|
||||||
> span > a {
|
> span > a {
|
||||||
color: @menu-dark-highlight-color;
|
color: @menu-dark-highlight-color;
|
||||||
}
|
}
|
||||||
> .@{menu-prefix-cls}-submenu-title,
|
> .@{menu-prefix-cls}-submenu-title {
|
||||||
> .@{menu-prefix-cls}-submenu-title:hover {
|
|
||||||
> .@{menu-prefix-cls}-submenu-arrow {
|
> .@{menu-prefix-cls}-submenu-arrow {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
&::after,
|
&::after,
|
||||||
|
|
|
@ -211,8 +211,6 @@
|
||||||
+ span {
|
+ span {
|
||||||
margin-left: @menu-icon-margin-right;
|
margin-left: @menu-icon-margin-right;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
// transition: opacity @animation-duration-slow @ease-in-out,
|
|
||||||
// width @animation-duration-slow @ease-in-out, color @animation-duration-slow;
|
|
||||||
transition: opacity @animation-duration-slow @ease-in-out, margin @animation-duration-slow,
|
transition: opacity @animation-duration-slow @ease-in-out, margin @animation-duration-slow,
|
||||||
color @animation-duration-slow;
|
color @animation-duration-slow;
|
||||||
}
|
}
|
||||||
|
@ -365,19 +363,19 @@
|
||||||
&:not(.@{menu-prefix-cls}-dark) {
|
&:not(.@{menu-prefix-cls}-dark) {
|
||||||
> .@{menu-prefix-cls}-item,
|
> .@{menu-prefix-cls}-item,
|
||||||
> .@{menu-prefix-cls}-submenu {
|
> .@{menu-prefix-cls}-submenu {
|
||||||
margin: @menu-item-padding;
|
|
||||||
margin-top: -1px;
|
margin-top: -1px;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
padding: @menu-item-padding;
|
padding: @menu-item-padding;
|
||||||
padding-right: 0;
|
|
||||||
padding-left: 0;
|
|
||||||
|
|
||||||
&:hover,
|
&:hover,
|
||||||
&-active,
|
&-active,
|
||||||
&-open,
|
&-open,
|
||||||
&-selected {
|
&-selected {
|
||||||
color: @menu-highlight-color;
|
color: @menu-highlight-color;
|
||||||
border-bottom: 2px solid @menu-highlight-color;
|
|
||||||
|
&::after {
|
||||||
|
border-bottom: 2px solid @menu-highlight-color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -388,7 +386,16 @@
|
||||||
top: 1px;
|
top: 1px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
border-bottom: 2px solid transparent;
|
|
||||||
|
&::after {
|
||||||
|
position: absolute;
|
||||||
|
right: @menu-item-padding-horizontal;
|
||||||
|
bottom: 0;
|
||||||
|
left: @menu-item-padding-horizontal;
|
||||||
|
border-bottom: 2px solid transparent;
|
||||||
|
transition: border-color @animation-duration-slow @ease-in-out;
|
||||||
|
content: '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> .@{menu-prefix-cls}-submenu > .@{menu-prefix-cls}-submenu-title {
|
> .@{menu-prefix-cls}-submenu > .@{menu-prefix-cls}-submenu-title {
|
||||||
|
@ -535,7 +542,6 @@
|
||||||
|
|
||||||
.@{menu-prefix-cls}-submenu-arrow {
|
.@{menu-prefix-cls}-submenu-arrow {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.@{menu-prefix-cls}-item-icon,
|
.@{menu-prefix-cls}-item-icon,
|
||||||
|
@ -626,8 +632,12 @@
|
||||||
&-submenu-disabled {
|
&-submenu-disabled {
|
||||||
color: @disabled-color !important;
|
color: @disabled-color !important;
|
||||||
background: none;
|
background: none;
|
||||||
border-color: transparent !important;
|
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
border-color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: @disabled-color !important;
|
color: @disabled-color !important;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
|
@ -512,7 +512,8 @@
|
||||||
@menu-item-vertical-margin: 4px;
|
@menu-item-vertical-margin: 4px;
|
||||||
@menu-item-font-size: @font-size-base;
|
@menu-item-font-size: @font-size-base;
|
||||||
@menu-item-boundary-margin: 8px;
|
@menu-item-boundary-margin: 8px;
|
||||||
@menu-item-padding: 0 20px;
|
@menu-item-padding-horizontal: 20px;
|
||||||
|
@menu-item-padding: 0 @menu-item-padding-horizontal;
|
||||||
@menu-horizontal-line-height: 46px;
|
@menu-horizontal-line-height: 46px;
|
||||||
@menu-icon-margin-right: 10px;
|
@menu-icon-margin-right: 10px;
|
||||||
@menu-icon-size: @menu-item-font-size;
|
@menu-icon-size: @menu-item-font-size;
|
||||||
|
|
2
v2-doc
2
v2-doc
|
@ -1 +1 @@
|
||||||
Subproject commit bf14bc00195ce0880e2b234743245c4faf18dd7d
|
Subproject commit 001bf204ea9b389f1ab7ec1ce23cd6243db64251
|
Loading…
Reference in New Issue