@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.
47 lines (44 loc) • 1.75 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", "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 getAlertButtonStyles from "./helpers/getAlertButtonStyles";
import getAlertButtonIconForeground from "./helpers/getAlertButtonIconForeground";
import { SIZE_OPTIONS } from "../../primitives/ButtonPrimitive/common/consts";
const AlertButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
let {
type = TYPE_OPTIONS.INFO,
disabled = false
} = _ref,
props = _objectWithoutProperties(_ref, _excluded);
const theme = useTheme();
const propsWithTheme = _objectSpread({
theme
}, props);
const commonProps = getCommonProps(_objectSpread(_objectSpread({}, propsWithTheme), {}, {
size: SIZE_OPTIONS.SMALL
}));
const buttonStyles = getAlertButtonStyles({
type,
theme,
disabled
});
const icons = getIconContainer(_objectSpread(_objectSpread({}, propsWithTheme), {}, {
iconForeground: getAlertButtonIconForeground({
type,
theme
})
}));
return /*#__PURE__*/React.createElement(ButtonPrimitive, _extends({
ref: ref,
disabled: disabled
}, props, buttonStyles, commonProps, icons));
});
AlertButton.displayName = "AlertButton";
export default AlertButton;