dropdown 菜单可以配置 disabled (#1574)

This commit is contained in:
liaoxuezhi 2021-02-09 21:56:15 +08:00 committed by GitHub
parent 557b3098cb
commit 568230356d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 3 deletions

View File

@ -19,7 +19,8 @@ order: 44
"buttons": [
{
"type": "button",
"label": "按钮1"
"label": "按钮1",
"disabled": true
},
{
"type": "button",

View File

@ -561,6 +561,7 @@
--DropDown-menuItem-onHover-bg: var(--ListMenu-item--onHover-bg);
--DropDown-menuItem-onHover-color: inherit;
--DropDown-menuItem-onActive-color: var(--info);
--DropDown-menuItem-onDisabled-color: var(--text--muted-color);
--DropDown-menuItem-paddingX: var(--gap-sm);
--DropDown-menuItem-paddingY: calc(
(var(--DropDown-menu-height) - var(--fontSizeBase) * var(--lineHeightBase)) /

View File

@ -72,6 +72,12 @@
cursor: pointer;
}
&.is-disabled {
cursor: not-allowed;
pointer-events: none;
color: var(--DropDown-menuItem-onDisabled-color);
}
&.#{$ns}DropDown-divider {
height: px2rem(1px);
margin: px2rem(9px) 0;
@ -82,6 +88,7 @@
}
&-menu > li a {
color: inherit;
display: block;
text-decoration: none;
}

View File

@ -5,7 +5,7 @@ import Overlay from '../components/Overlay';
import PopOver from '../components/PopOver';
import TooltipWrapper from '../components/TooltipWrapper';
import type {TooltipObject, Trigger} from '../components/TooltipWrapper';
import {isVisible, noop} from '../utils/helper';
import {isDisabled, isVisible, noop} from '../utils/helper';
import {filter} from '../utils/tpl';
import {Icon} from '../components/icons';
import {BaseSchema, SchemaClassName} from '../Schema';
@ -191,7 +191,10 @@ export default class DropDownButton extends React.Component<
}
return (
<li key={index}>
<li
key={index}
className={isDisabled(button, data) ? 'is-disabled' : ''}
>
{render(`button/${index}`, {
type: 'button',
...(button as any),