@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.
64 lines (63 loc) • 1.88 kB
JavaScript
"use client";
import * as React from "react";
import cx from "clsx";
import { ELEMENT_OPTIONS } from "../Heading/consts";
import Header from "./components/Header";
import { spaceAfterClasses } from "../common/tailwind";
import Loading from "../Loading";
export { default as CardSection } from "./CardSection";
export default function Card({
title,
titleAs = ELEMENT_OPTIONS.H2,
actions,
description,
children,
labelClose = "Close",
dataTest,
id,
onClose,
loading,
margin,
header,
spaceAfter,
dataA11ySection
}) {
const marginStyles = (() => {
if (margin == null) {
return {};
}
if (typeof margin === "string" || typeof margin === "number") {
return {
margin
};
}
return {
marginTop: margin.top,
marginRight: margin.right,
marginBottom: margin.bottom,
marginLeft: margin.left
};
})();
return /*#__PURE__*/React.createElement("div", {
id: id,
className: cx("font-base bg-white-normal [&>*]:border-elevation-flat-border-color [&>*:first-child]:rounded-t-normal [&>*:last-child]:rounded-b-normal w-full [&>*:first-child]:border-t", spaceAfter != null && spaceAfterClasses[spaceAfter]),
"data-test": dataTest,
style: marginStyles
}, (title != null || header != null) && !loading && /*#__PURE__*/React.createElement("div", {
className: "p-md lm:p-lg lm:border-x relative border-b"
}, /*#__PURE__*/React.createElement(Header, {
description: description,
dataA11ySection: dataA11ySection,
actions: actions,
title: title,
labelClose: labelClose,
titleAs: titleAs,
onClose: onClose,
header: header
})), !loading && children, loading && /*#__PURE__*/React.createElement("div", {
className: "lm:border-x border-b"
}, /*#__PURE__*/React.createElement(Loading, {
loading: loading,
type: "boxLoader"
})));
}