按钮 tooltip 整理 支持 disabledTip

This commit is contained in:
liaoxuezhi 2021-05-23 22:08:00 +08:00
parent 3e9df63fad
commit 384d37dc6a
4 changed files with 22 additions and 41 deletions

View File

@ -331,13 +331,4 @@ input[type='button'] {
margin-left: var(--gap-xs);
margin-top: var(--gap-xs);
}
> .#{$ns}Button--disabled-wrap > .#{$ns}Button {
margin-left: var(--gap-xs);
margin-top: var(--gap-xs);
}
}
.#{$ns}Button--disabled-wrap {
display: inline-block !important;
}

View File

@ -76,8 +76,9 @@
&.is-disabled {
cursor: not-allowed;
pointer-events: none;
// pointer-events: none;
color: var(--DropDown-menuItem-onDisabled-color);
filter: grayscale(80%);
}
&.#{$ns}DropDown-divider {

View File

@ -28,6 +28,7 @@ interface ButtonProps extends React.DOMAttributes<HTMLButtonElement> {
classPrefix: string;
classnames: ClassNamesFn;
componentClass: React.ReactType;
overrideClassName?: boolean;
}
export class Button extends React.Component<ButtonProps> {
@ -63,28 +64,33 @@ export class Button extends React.Component<ButtonProps> {
active,
iconOnly,
href,
overrideClassName,
...rest
} = this.props;
if (href) {
Comp = 'a';
} else if (Comp === 'button' && disabled) {
Comp = 'div';
}
return (
<Comp
type={Comp === 'a' ? undefined : type}
type={Comp === 'input' || Comp === 'button' ? type : undefined}
{...pickEventsProps(rest)}
href={href}
className={cx(
`Button`,
{
[`Button--${level}`]: level,
[`Button--${size}`]: size,
[`Button--block`]: block,
[`Button--iconOnly`]: iconOnly,
'is-disabled': disabled,
'is-active': active
},
overrideClassName
? ''
: {
'Button': true,
[`Button--${level}`]: level,
[`Button--${size}`]: size,
[`Button--block`]: block,
[`Button--iconOnly`]: iconOnly,
'is-disabled': disabled,
'is-active': active
},
className
)}
disabled={disabled}
@ -103,7 +109,6 @@ export class Button extends React.Component<ButtonProps> {
tooltipRootClose,
disabled,
disabledTip,
classPrefix,
classnames: cx
} = this.props;
@ -115,13 +120,7 @@ export class Button extends React.Component<ButtonProps> {
trigger={tooltipTrigger}
rootClose={tooltipRootClose}
>
{disabled && disabledTip ? (
<div className={cx('Button--disabled-wrap')}>
{this.renderButton()}
</div>
) : (
this.renderButton()
)}
{this.renderButton()}
</TooltipWrapper>
);
}

View File

@ -514,18 +514,7 @@ export class Action extends React.Component<ActionProps, ActionState> {
const iconElement = generateIcon(cx, icon, 'Button-icon', iconClassName);
return isMenuItem ? (
<a
className={cx(className, {
[activeClassName || 'is-active']: isActive,
'is-disabled': disabled
})}
onClick={this.handleAction}
>
{iconElement}
{label}
</a>
) : (
return (
<Button
className={cx(className, {
[activeClassName || 'is-active']: isActive
@ -539,7 +528,8 @@ export class Action extends React.Component<ActionProps, ActionState> {
onClick={this.handleAction}
type={type && ~allowedType.indexOf(type) ? type : 'button'}
disabled={disabled}
componentClass={componentClass}
componentClass={isMenuItem ? 'a' : componentClass}
overrideClassName={isMenuItem}
tooltip={filterContents(tooltip, data)}
disabledTip={filterContents(disabledTip, data)}
placement={tooltipPlacement}