-
Notifications
You must be signed in to change notification settings - Fork 151
/
index.tsx
60 lines (54 loc) · 1.43 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import * as React from "react";
import styled, { css } from "styled-components";
import type { Theme } from "../../defaultTheme";
import defaultTheme from "../../defaultTheme";
import { ALIGN_OPTIONS } from "./consts";
import { TYPE_AS } from "../consts";
import { textAlign } from "../../utils/rtl";
import type { Props } from "./types";
interface StyledProps extends Partial<Props> {
theme: Theme;
}
export const StyledTableCell = styled(
({ element: Component, children, className, dataTest, scope }) => (
<Component className={className} data-test={dataTest} scope={scope}>
{children}
</Component>
),
)`
${({ theme, whiteSpace, verticalAlign, align }: StyledProps) => css`
box-sizing: border-box;
font-family: ${theme.orbit.fontFamily};
font-size: ${theme.orbit.fontSizeTextNormal};
color: ${theme.orbit.paletteInkDark};
text-align: ${align && textAlign(align)};
white-space: ${whiteSpace};
vertical-align: ${verticalAlign};
`}
`;
StyledTableCell.defaultProps = {
theme: defaultTheme,
};
const TableCell = ({
align = ALIGN_OPTIONS.LEFT,
scope,
as = TYPE_AS.TD,
verticalAlign,
whiteSpace,
dataTest,
children,
}: Props) => {
return (
<StyledTableCell
verticalAlign={verticalAlign}
whiteSpace={whiteSpace}
align={align}
dataTest={dataTest}
scope={scope}
element={as}
>
{children}
</StyledTableCell>
);
};
export default TableCell;