@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.
59 lines (54 loc) • 2.19 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import * as React from "react";
import { BUTTON_STATES } from "../../primitives/ButtonPrimitive/common/consts";
import getBoxShadow from "./helpers/getBoxShadow";
import getPadding from "../../primitives/ButtonPrimitive/common/getPadding";
import useTheme from "../../hooks/useTheme";
import ButtonPrimitive from "../../primitives/ButtonPrimitive";
import { ICON_SIZE, BUTTON_SIZE } from "./consts";
var Button = function Button(_ref) {
var selected = _ref.selected,
iconLeft = _ref.iconLeft,
iconRight = _ref.iconRight,
disabled = _ref.disabled,
_ref$height = _ref.height,
height = _ref$height === void 0 ? BUTTON_SIZE : _ref$height,
_ref$width = _ref.width,
width = _ref$width === void 0 ? BUTTON_SIZE : _ref$width,
children = _ref.children,
props = _objectWithoutProperties(_ref, ["selected", "iconLeft", "iconRight", "disabled", "height", "width", "children"]);
var theme = useTheme();
var onlyIcon = Boolean(iconLeft && !children);
var padding = getPadding(onlyIcon, iconRight, iconLeft, "small", theme);
var wrappedBoxShadow = function wrappedBoxShadow(state) {
return getBoxShadow({
state: state,
disabled: disabled,
theme: theme,
selected: selected
});
};
var boxShadow = {
boxShadow: wrappedBoxShadow(BUTTON_STATES.DEFAULT),
boxShadowHover: wrappedBoxShadow(BUTTON_STATES.HOVER),
boxShadowActive: wrappedBoxShadow(BUTTON_STATES.ACTIVE),
boxShadowFocus: wrappedBoxShadow(BUTTON_STATES.FOCUS)
};
return /*#__PURE__*/React.createElement(ButtonPrimitive, _extends({
circled: true,
contentAlign: "center",
icons: {
width: ICON_SIZE,
height: ICON_SIZE,
foreground: selected ? theme.orbit.paletteWhite : theme.orbit.paletteInkNormal
},
background: selected ? theme.orbit.paletteBlueNormal : theme.orbit.paletteCloudDark,
iconLeft: iconLeft,
height: height,
width: width,
disabled: disabled,
padding: padding
}, props, boxShadow));
};
export default Button;