@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.
66 lines (63 loc) • 1.68 kB
JavaScript
import * as React from "react";
import TileHeader from "./components/TileHeader";
import TileContent from "./components/TileContent";
import TileExpandable from "./components/TileExpandable";
import TileWrapper from "./components/TileWrapper";
import handleKeyDown from "../utils/handleKeyDown";
const Tile = ({
href,
external = false,
dataTest,
icon,
title,
description,
header,
children,
noPadding = false,
expandable = false,
initialExpanded = false,
noHeaderIcon = false,
htmlTitle,
onClick,
as
}) => {
if (expandable) {
return /*#__PURE__*/React.createElement(TileExpandable, {
dataTest: dataTest,
icon: icon,
title: title,
description: description,
header: header,
noPadding: noPadding,
initialExpanded: initialExpanded,
onClick: onClick,
htmlTitle: htmlTitle
}, children);
}
const hasHeader = !!(title || description || icon || header);
return /*#__PURE__*/React.createElement(TileWrapper, {
href: href,
external: external,
dataTest: dataTest,
onClick: onClick,
onKeyDown: handleKeyDown(onClick),
as: as,
tabIndex: !href ? "0" : undefined,
role: onClick ? "button" : undefined,
htmlTitle: htmlTitle
}, hasHeader && /*#__PURE__*/React.createElement(TileHeader, {
title: title,
description: description,
icon: icon,
external: external,
header: header,
expandable: expandable,
noHeaderIcon: noHeaderIcon
}), children && /*#__PURE__*/React.createElement(TileContent, {
noPadding: noPadding,
withPointer: true,
withBorder: hasHeader,
useMargins: false
}, children));
};
export default Tile;