@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.
56 lines • 1.72 kB
JavaScript
import * as React from "react";
import cx from "clsx";
import ChevronDown from "../../icons/ChevronDown";
import Stack from "../../Stack";
import Heading from "../../Heading";
import Text from "../../Text";
import Close from "../../icons/Close";
import ButtonLink from "../../ButtonLink";
const Header = ({
description,
title,
titleAs,
isSection,
labelClose,
actions,
dataA11ySection,
onClose,
header,
expandable,
expanded
}) => /*#__PURE__*/React.createElement(Stack, {
align: "center",
spacing: "small"
}, (title || description) && !header && /*#__PURE__*/React.createElement(Stack, {
flex: true,
shrink: !!actions || expandable,
align: "stretch",
direction: "column",
spacing: isSection ? "none" : "XXSmall"
}, /*#__PURE__*/React.createElement(Stack, {
inline: true,
spacing: "small",
align: "center"
}, title && /*#__PURE__*/React.createElement(Heading, {
type: isSection ? "title4" : "title3",
as: titleAs,
dataA11ySection: dataA11ySection
}, title)), description && /*#__PURE__*/React.createElement(Text, {
as: "div"
}, description)), header, expandable && !actions && /*#__PURE__*/React.createElement(ChevronDown, {
className: cx("duration-fast transition-transform ease-in-out", expanded && "-rotate-180"),
color: "secondary"
}), actions && /*#__PURE__*/React.createElement(Stack, {
inline: true,
grow: false,
justify: "end"
}, actions), onClose && !actions && /*#__PURE__*/React.createElement("div", {
className: "absolute end-0 top-0"
}, /*#__PURE__*/React.createElement(ButtonLink, {
type: "secondary",
size: "small",
iconLeft: /*#__PURE__*/React.createElement(Close, null),
onClick: onClose,
title: labelClose
})));
export default Header;