@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.
33 lines • 1.14 kB
JavaScript
import * as React from "react";
import cx from "clsx";
import { ALIGN_OPTIONS } from "./consts";
import { TYPE_AS } from "../consts";
const verticalAlignStyles = {
baseline: "align-baseline",
middle: "align-middle",
top: "align-top",
bottom: "align-bottom"
};
const whitespaceStyles = {
normal: "whitespace-normal",
nowrap: "whitespace-nowrap",
pre: "whitespace-pre",
"pre-line": "whitespace-pre-line",
"pre-wrap": "whitespace-pre-wrap"
};
const TableCell = ({
align = ALIGN_OPTIONS.LEFT,
scope,
as: Component = TYPE_AS.TD,
verticalAlign,
whiteSpace,
dataTest,
children
}) => {
return /*#__PURE__*/React.createElement(Component, {
className: cx("font-base text-normal text-ink-dark box-border", verticalAlign != null && verticalAlignStyles[verticalAlign], whiteSpace != null && whitespaceStyles[whiteSpace], (align === ALIGN_OPTIONS.START || align === ALIGN_OPTIONS.LEFT) && "text-start", align === ALIGN_OPTIONS.CENTER && "text-center", (align === ALIGN_OPTIONS.END || align === ALIGN_OPTIONS.RIGHT) && "text-end"),
"data-test": dataTest,
scope: scope
}, children);
};
export default TableCell;