UNPKG

@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.

41 lines 1.25 kB
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 getButtonStyles from "./helpers/getButtonStyles"; import getButtonIconForeground from "./helpers/getButtonIconForeground"; const Button = /*#__PURE__*/React.forwardRef(({ type = TYPE_OPTIONS.PRIMARY, size, disabled = false, ...props }, ref) => { const theme = useTheme(); const propsWithTheme = { theme, size, ...props }; const commonProps = getCommonProps(propsWithTheme); const buttonStyles = getButtonStyles({ type, theme, disabled }); const icons = getIconContainer({ ...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;