Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate borderless prop from DataTable to Table #1354

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/components/data/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ type ComponentProps<Row> = {
/** Callback to render an individual table cell */
renderItem?: (r: Row, field: keyof Row) => ComponentChildren;
title: string;

/** Turn off outer table borders */
borderless?: boolean;
acelaya marked this conversation as resolved.
Show resolved Hide resolved
};

export type DataTableProps<Row> = CompositeProps &
Expand All @@ -63,6 +66,9 @@ export default function DataTable<Row>({
onConfirmRow,
emptyMessage,

// Forwarded to Table
borderless,

...htmlAttributes
}: DataTableProps<Row>) {
const tableRef = useSyncedRef(elementRef);
Expand Down Expand Up @@ -133,7 +139,8 @@ export default function DataTable<Row>({
title={title}
elementRef={downcastRef(tableRef)}
interactive={!!(onSelectRow || onConfirmRow)}
stickyHeader={true}
stickyHeader
borderless={borderless}
>
<TableHead>
<TableRow>
Expand Down
12 changes: 12 additions & 0 deletions src/pattern-library/components/patterns/data/DataTablePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,18 @@ export default function DataTablePage() {
</Library.Demo>
</Library.Example>

<Library.Example title="borderless">
acelaya marked this conversation as resolved.
Show resolved Hide resolved
<Library.Info>
<Library.InfoItem label="description">
See{' '}
<Library.Link href="/data-table#table-props-borderless">
borderless Table
</Library.Link>
.
</Library.InfoItem>
</Library.Info>
</Library.Example>

<Library.Example title="...htmlAttributes">
<Library.Info>
<Library.InfoItem label="description">
Expand Down
2 changes: 1 addition & 1 deletion src/pattern-library/components/patterns/data/TablePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export default function TablePage() {
</Table>
</Library.Demo>
</Library.Example>
<Library.Example title="borderless">
<Library.Example id="table-props-borderless" title="borderless">
<Library.Info>
<Library.InfoItem label="description">
Set this boolean prop if you want to remove the table{"'"}s
Expand Down