@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.
48 lines (45 loc) • 1.65 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", "compact"];
import * as React from "react";
import { TYPES } from "./consts";
import ButtonPrimitive from "../primitives/ButtonPrimitive";
import useTheme from "../hooks/useTheme";
import getIconContainer from "../primitives/ButtonPrimitive/common/getIconContainer";
import getButtonLinkStyles from "./helpers/getButtonLinkStyles";
import getButtonLinkIconForeground from "./helpers/getButtonLinkIconForeground";
import getButtonLinkCommonProps from "./helpers/getButtonLinkCommonProps";
const ButtonLink = /*#__PURE__*/React.forwardRef((_ref, ref) => {
let {
type = TYPES.PRIMARY,
size,
compact = false
} = _ref,
props = _objectWithoutProperties(_ref, _excluded);
const theme = useTheme();
const propsWithTheme = _objectSpread({
theme,
size
}, props);
const commonProps = getButtonLinkCommonProps(_objectSpread(_objectSpread({}, propsWithTheme), {}, {
compact
}));
const buttonLinkStyles = getButtonLinkStyles({
type,
theme,
compact
});
const icons = getIconContainer(_objectSpread(_objectSpread({}, propsWithTheme), {}, {
iconForeground: getButtonLinkIconForeground({
type,
theme,
compact
})
}));
return /*#__PURE__*/React.createElement(ButtonPrimitive, _extends({
ref: ref
}, props, buttonLinkStyles, commonProps, icons));
});
ButtonLink.displayName = "ButtonLink";
export default ButtonLink;