提交 be3a90fb 编写于 作者: A afc163

Add click effect for primary button, close #942

上级 a567faea
......@@ -30,9 +30,17 @@ export default class Button extends React.Component {
window.PIE.attach(findDOMNode(this));
}
}
handleClick() {
const buttonNode = findDOMNode(this);
buttonNode.className = buttonNode.className.replace(`${prefix}clicked`, '');
setTimeout(() => {
buttonNode.className += ` ${prefix}clicked`;
}, 10);
this.props.onClick();
}
render() {
const props = this.props;
const { type, shape, size, onClick, className, htmlType, children, ...others } = props;
const { type, shape, size, className, htmlType, children, ...others } = props;
// large => lg
// small => sm
......@@ -53,7 +61,7 @@ export default class Button extends React.Component {
const kids = React.Children.map(children, insertSpace);
return (
<button {...others} type={htmlType || 'button'} className={classes} onClick={onClick}>
<button {...others} type={htmlType || 'button'} className={classes} onClick={this.handleClick.bind(this)}>
{kids}
</button>
);
......
......@@ -97,4 +97,26 @@
> span + .@{iconfont-css-prefix} {
margin-left: 0.5em;
}
&-clicked:before {
content: '';
position: absolute;
top: -6px;
left: -6px;
bottom: -6px;
right: -6px;
border-radius: inherit;
z-index: -1;
background: inherit;
opacity: 1;
transform: scale3d(0.5, 0.5, 1);
animation: buttonEffect 0.48s ease forwards;
}
}
@keyframes buttonEffect {
to {
opacity: 0;
transform: scale3d(1, 1, 1);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册