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.

71 lines (70 loc) 2.03 kB
"use client"; import _extends from "@babel/runtime/helpers/esm/extends"; 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.DIV, actions, description, children, labelClose = "Close", dataTest, id, onClose, loading, margin, header, spaceAfter, dataA11ySection, loadingTitle, loadingHidden }) { 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("orbit-card font-base bg-white-normal *:border-elevation-flat-border-color lm:first:*:rounded-t-300 lm:last:*:rounded-b-300 w-full first:*:border-t", spaceAfter != null && spaceAfterClasses[spaceAfter]), "data-test": dataTest, style: marginStyles }, (title != null || header != null) && !loading && /*#__PURE__*/React.createElement("div", { className: "p-400 lm:p-600 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, _extends({ loading: loading, type: "boxLoader" }, loadingHidden ? { ariaHidden: true } : { title: loadingTitle })))); }