slate/components/core/DynamicIcon.js

32 lines
794 B
JavaScript
Raw Normal View History

2020-10-05 00:30:28 +03:00
import * as React from "react";
export class DynamicIcon extends React.Component {
state = {
clicked: false,
};
_handleClick = (e) => {
2021-07-07 23:50:57 +03:00
if (this.props.onClick) {
this.props.onClick(e);
}
2020-10-05 00:30:28 +03:00
this.setState({ clicked: true });
2020-11-08 05:32:17 +03:00
setTimeout(() => this.setState({ clicked: false }), this.props.timeout || 1000);
2020-10-05 00:30:28 +03:00
};
render() {
return (
<div
style={{ cursor: "pointer", ...this.props.style }}
onClick={this._handleClick}
onMouseUp={this.props.onMouseUp}
onMouseDown={this.props.onMouseDown}
onMouseEnter={this.props.onMouseEnter}
onMouseLeave={this.props.onMouseLeave}
css={this.props.css}
>
{this.state.clicked ? this.props.successState : this.props.children}
</div>
);
}
}