@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.21 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 = props => {
const {
align = ALIGN_OPTIONS.LEFT,
as: Component = TYPE_AS.TD,
verticalAlign,
whiteSpace,
dataTest,
children
} = props;
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: props.as === TYPE_AS.TH ? props.scope : undefined
}, children);
};
export default TableCell;