@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.
46 lines (43 loc) • 1.57 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
const _excluded = ["type", "size", "disabled"];
import * as React from "react";
import { TYPE_OPTIONS } from "./consts";
import ButtonPrimitive from "../primitives/ButtonPrimitive";
import getIconContainer from "../primitives/ButtonPrimitive/common/getIconContainer";
import getCommonProps from "../primitives/ButtonPrimitive/common/getCommonProps";
import useTheme from "../hooks/useTheme";
import getButtonStyles from "./helpers/getButtonStyles";
import getButtonIconForeground from "./helpers/getButtonIconForeground";
const Button = /*#__PURE__*/React.forwardRef((_ref, ref) => {
let {
type = TYPE_OPTIONS.PRIMARY,
size,
disabled = false
} = _ref,
props = _objectWithoutProperties(_ref, _excluded);
const theme = useTheme();
const propsWithTheme = _objectSpread({
theme,
size
}, props);
const commonProps = getCommonProps(propsWithTheme);
const buttonStyles = getButtonStyles({
type,
theme,
disabled
});
const icons = getIconContainer(_objectSpread(_objectSpread({}, propsWithTheme), {}, {
iconForeground: getButtonIconForeground({
type,
theme
})
}));
return /*#__PURE__*/React.createElement(ButtonPrimitive, _extends({
ref: ref,
disabled: disabled
}, props, buttonStyles, commonProps, icons));
});
Button.displayName = "Button";
export default Button;