mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
按钮 tooltip 整理 支持 disabledTip
This commit is contained in:
parent
3e9df63fad
commit
384d37dc6a
@ -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;
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user