@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.
45 lines (44 loc) • 1.42 kB
JavaScript
"use client";
import _extends from "@babel/runtime/helpers/esm/extends";
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(({
type = TYPE_OPTIONS.INFO,
disabled = false,
...props
}, ref) => {
const theme = useTheme();
const propsWithTheme = {
theme,
...props
};
const commonProps = getCommonProps({
...propsWithTheme,
size: SIZE_OPTIONS.SMALL
});
const buttonStyles = getAlertButtonStyles({
type,
theme,
disabled
});
const icons = getIconContainer({
...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;