@netdata/netdata-ui
Version:
netdata UI kit
46 lines • 1.93 kB
JavaScript
var _excluded = ["width", "height", "tooltip", "ref"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import React from "react";
import Box from "../templates/box";
import Flex from "../templates/flex";
import Tooltip from "../drops/tooltip";
import { TextSmall } from "../typography";
import { Button } from "./button";
var CustomTooltipContent = function CustomTooltipContent(_ref) {
var content = _ref.content;
return /*#__PURE__*/React.createElement(Flex, {
padding: [1.5, 2],
margin: [2],
background: "tooltip",
round: 1,
alignSelf: "start"
}, /*#__PURE__*/React.createElement(TextSmall, {
color: "tooltipText"
}, content));
};
var IconButton = function IconButton(_ref2) {
var _ref2$width = _ref2.width,
width = _ref2$width === void 0 ? "14px" : _ref2$width,
_ref2$height = _ref2.height,
height = _ref2$height === void 0 ? "14px" : _ref2$height,
_ref2$tooltip = _ref2.tooltip,
tooltip = _ref2$tooltip === void 0 ? "" : _ref2$tooltip,
ref = _ref2.ref,
props = _objectWithoutPropertiesLoose(_ref2, _excluded);
return /*#__PURE__*/React.createElement(Tooltip, {
plain: true,
animation: true,
content: tooltip && /*#__PURE__*/React.createElement(CustomTooltipContent, {
content: tooltip
})
}, /*#__PURE__*/React.createElement(Box, _extends({
as: Button,
iconWidth: width,
iconHeight: height,
ref: ref,
flavour: "borderless",
neutral: true
}, props)));
};
export default IconButton;