UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

40 lines 1.93 kB
import * as tslib_1 from "tslib"; import { Tooltip } from '@atlaskit/tooltip'; import * as React from 'react'; import { PureComponent } from 'react'; import { AkButton } from './styles'; var ToolbarButton = (function (_super) { tslib_1.__extends(ToolbarButton, _super); function ToolbarButton() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.state = { isTooltipVisible: false }; _this.handleClick = function () { var _a = _this.props, disabled = _a.disabled, onClick = _a.onClick; if (!disabled && onClick) { onClick(); } _this.setState({ isTooltipVisible: false }); }; _this.handleMouseOver = function () { _this.setState({ isTooltipVisible: true }); }; _this.handleMouseOut = function () { _this.setState({ isTooltipVisible: false }); }; return _this; } ToolbarButton.prototype.render = function () { var button = (React.createElement(AkButton, { className: "" + this.props.className, ariaHaspopup: true, isDisabled: this.props.disabled, isSelected: this.props.selected, spacing: this.props.spacing || 'none', appearance: "subtle", href: this.props.href, onClick: this.handleClick, target: this.props.target, theme: this.props.theme, iconBefore: this.props.iconBefore, iconAfter: this.props.iconAfter }, this.props.children)); return this.props.title ? (React.createElement(Tooltip, { position: this.props.titlePosition || 'top', description: this.props.title, visible: this.state.isTooltipVisible, onMouseOver: this.handleMouseOver, onMouseOut: this.handleMouseOut }, button)) : button; }; return ToolbarButton; }(PureComponent)); export default ToolbarButton; ToolbarButton.defaultProps = { className: '', }; //# sourceMappingURL=index.js.map