@netdata/charts
Version:
Netdata frontend SDK and chart utilities
123 lines • 5.59 kB
JavaScript
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var _excluded = ["icon", "hoverIndicator", "padding"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
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 styled from "styled-components";
import { getColor, cursor } from "@netdata/netdata-ui";
import { withTooltip } from "../tooltip";
var color = function color(_ref) {
var active = _ref.active,
disabled = _ref.disabled,
_ref$defaultColor = _ref.defaultColor,
defaultColor = _ref$defaultColor === void 0 ? "textLite" : _ref$defaultColor;
if (active) return "text";
if (disabled) return "disabled";
return defaultColor;
};
var Button = styled.button.attrs(function (_ref2) {
var icon = _ref2.icon,
_ref2$hoverIndicator = _ref2.hoverIndicator,
hoverIndicator = _ref2$hoverIndicator === void 0 ? true : _ref2$hoverIndicator,
_ref2$padding = _ref2.padding,
padding = _ref2$padding === void 0 ? 0 : _ref2$padding,
rest = _objectWithoutProperties(_ref2, _excluded);
return _objectSpread(_objectSpread({
cursor: "pointer"
}, rest), {}, {
children: icon || rest.children,
active: rest.active || rest["aria-expanded"],
hoverIndicator: hoverIndicator,
padding: padding
});
}).withConfig({
displayName: "button__Button",
componentId: "sc-oqiqxn-0"
})(["border:initial;padding:", ";height:auto;line-height:0;background:", ";", " color:", ";svg{fill:", ";stroke:", ";}", " &:hover{", ";color:", ";svg{fill:", ";stroke:", ";}}"], function (_ref3) {
var padding = _ref3.padding;
return padding;
}, function (_ref4) {
var theme = _ref4.theme,
active = _ref4.active;
return active ? getColor("borderSecondary")({
theme: theme
}) : "initial";
}, cursor, function (_ref5) {
var active = _ref5.active,
disabled = _ref5.disabled,
theme = _ref5.theme;
return getColor(color({
active: active,
disabled: disabled
}))({
theme: theme
});
}, function (_ref6) {
var active = _ref6.active,
disabled = _ref6.disabled,
theme = _ref6.theme,
stroked = _ref6.stroked;
return stroked ? "none" : getColor(color({
active: active,
disabled: disabled
}))({
theme: theme
});
}, function (_ref7) {
var active = _ref7.active,
disabled = _ref7.disabled,
theme = _ref7.theme,
stroked = _ref7.stroked;
return stroked ? getColor(color({
active: active,
disabled: disabled
}))({
theme: theme
}) : "none";
}, function (_ref8) {
var active = _ref8.active,
hoverIndicator = _ref8.hoverIndicator;
return (active || hoverIndicator) && "\n border-radius: 4px;\n ";
}, function (_ref9) {
var theme = _ref9.theme,
hoverIndicator = _ref9.hoverIndicator,
disabled = _ref9.disabled;
return hoverIndicator && !disabled && "background: ".concat(getColor("mainChartTboxHover")({
theme: theme
}), ";");
}, function (_ref10) {
var active = _ref10.active,
disabled = _ref10.disabled,
theme = _ref10.theme;
return getColor(color({
active: active,
disabled: disabled
}))({
theme: theme
});
}, function (_ref11) {
var theme = _ref11.theme,
stroked = _ref11.stroked,
disabled = _ref11.disabled;
return stroked ? "none" : getColor(color({
defaultColor: "text",
disabled: disabled
}))({
theme: theme
});
}, function (_ref12) {
var theme = _ref12.theme,
stroked = _ref12.stroked,
disabled = _ref12.disabled;
return stroked ? getColor(color({
defaultColor: "text",
disabled: disabled
}))({
theme: theme
}) : "none";
});
export default withTooltip(Button);