Skip to content

Commit 4d491be

Browse files
authored
feat(fuselage): TableCell empty fallback (#1080)
1 parent 924c896 commit 4d491be

File tree

4 files changed

+14
-37
lines changed

4 files changed

+14
-37
lines changed

packages/fuselage/src/components/Table/Table.tsx

-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import type { ComponentProps, CSSProperties } from 'react';
22
import React from 'react';
33

44
import Box from '../Box';
5-
import { TableSelection } from './TableSelection';
6-
import { TableSelectionButton } from './TableSelectionButton';
75

86
export const style: CSSProperties = {
97
overflow: 'hidden',
@@ -34,6 +32,3 @@ export const Table = ({
3432
/>
3533
</Box>
3634
);
37-
38-
Table.Selection = TableSelection;
39-
Table.Button = TableSelectionButton;

packages/fuselage/src/components/Table/TableCell.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,27 @@ type TableCellProps = TableProps & {
99
clickable?: boolean;
1010
};
1111

12-
export const TableCell = ({ align, clickable, ...props }: TableCellProps) => {
12+
export const TableCell = ({
13+
align,
14+
clickable,
15+
children,
16+
...props
17+
}: TableCellProps) => {
1318
const isInsideHead = useContext(TableHeadContext);
19+
20+
const innerElement =
21+
children ?? !isInsideHead ? (
22+
<Box is='hr' width='x14' borderWidth={1} />
23+
) : undefined;
24+
1425
return (
1526
<Box
1627
is={isInsideHead ? 'th' : 'td'}
1728
rcx-table__cell
1829
rcx-table__cell--align={align}
1930
rcx-table__cell--header={isInsideHead}
2031
rcx-table__cell--clickable={clickable}
32+
children={innerElement}
2133
{...props}
2234
/>
2335
);
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
1-
import { Table } from './Table';
2-
import { TableBody } from './TableBody';
3-
import { TableCell } from './TableCell';
4-
import { TableFoot } from './TableFoot';
5-
import { TableHead } from './TableHead';
6-
import { TableRow } from './TableRow';
7-
81
export * from './Table';
92
export * from './TableBody';
103
export * from './TableCell';
114
export * from './TableFoot';
125
export * from './TableHead';
136
export * from './TableRow';
14-
export * from './TableRow';
157
export * from './TableSelection';
168
export * from './TableSelectionButton';
17-
18-
export default Object.assign(Table, {
19-
/** @deprecated */
20-
Head: TableHead,
21-
/** @deprecated */
22-
Body: TableBody,
23-
/** @deprecated */
24-
Foot: TableFoot,
25-
/** @deprecated */
26-
Row: TableRow,
27-
/** @deprecated */
28-
Cell: TableCell,
29-
});

packages/fuselage/src/components/index.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,7 @@ export { default as Sidebar } from './Sidebar';
5454
export * from './Sidebar';
5555
export * from './Skeleton';
5656
export * from './States';
57-
export {
58-
default as Table,
59-
TableBody,
60-
TableCell,
61-
TableFoot,
62-
TableHead,
63-
TableRow,
64-
TableSelection,
65-
TableSelectionButton,
66-
} from './Table';
57+
export * from './Table';
6758
export * from './Tabs';
6859
export * from './Tag';
6960
export * from './TelephoneInput';

0 commit comments

Comments
 (0)