UNPKG

@netdata/netdata-ui

Version:

netdata UI kit

52 lines 2.47 kB
var _excluded = ["label", "icon", "flavour", "isLoading", "loadingLabel", "onClick", "textTransform", "iconColor", "iconSize", "iconWidth", "iconHeight", "children", "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 { StyledButton } from "./styled"; import { Icon } from "../icon"; import { LoaderIcon } from "../icon/components"; import Flex from "../templates/flex"; export var Button = function Button(_ref) { var label = _ref.label, _ref$icon = _ref.icon, icon = _ref$icon === void 0 ? null : _ref$icon, flavour = _ref.flavour, isLoading = _ref.isLoading, loadingLabel = _ref.loadingLabel, _ref$onClick = _ref.onClick, onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick, _ref$textTransform = _ref.textTransform, textTransform = _ref$textTransform === void 0 ? "firstLetter" : _ref$textTransform, iconColor = _ref.iconColor, iconSize = _ref.iconSize, iconWidth = _ref.iconWidth, iconHeight = _ref.iconHeight, _ref$children = _ref.children, children = _ref$children === void 0 ? label : _ref$children, ref = _ref.ref, rest = _objectWithoutPropertiesLoose(_ref, _excluded); return /*#__PURE__*/React.createElement(StyledButton, _extends({ flavour: flavour, textTransform: textTransform, hasIcon: !!icon || isLoading, onClick: isLoading ? undefined : onClick, ref: ref, iconColor: iconColor, iconWidth: iconWidth, iconHeight: iconHeight }, rest), isLoading && /*#__PURE__*/React.createElement(LoaderIcon, { className: "button-icon" }), icon && !isLoading && /*#__PURE__*/React.createElement(Flex, { justifyContent: "center", alignItems: "center", width: "auto", height: "100%" }, /*#__PURE__*/React.createElement(Icon, { size: iconSize, className: "button-icon", title: icon, name: icon, width: iconWidth, height: iconHeight })), !!children && /*#__PURE__*/React.createElement("span", null, isLoading && loadingLabel || children)); };