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

fix(DataTable): expandable table size variations alignment issues #8080

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@
padding: $spacing-03;
}

.#{$prefix}--toolbar-action.#{$prefix}--toolbar-search-container-persistent {
width: 100%;
}

//hidden
.#{$prefix}--toolbar-search-container-expandable {
width: rem(32px);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@

.#{$prefix}--data-table--tall thead th.#{$prefix}--table-expand,
.#{$prefix}--data-table--tall tbody td.#{$prefix}--table-expand {
width: rem(64px);
height: rem(64px);
}

Expand Down Expand Up @@ -532,7 +531,6 @@

.#{$prefix}--data-table--sticky-header {
display: block;
// max-height: rem(300px);
overflow-y: scroll;

thead,
Expand Down Expand Up @@ -587,10 +585,6 @@
min-height: 3rem;
}

// .#{$prefix}--parent-row td {
// padding: 1rem;
// }

&:not(.#{$prefix}--data-table--compact):not(.#{$prefix}--data-table--tall):not(.#{$prefix}--data-table--short)
td:not(.#{$prefix}--table-column-menu):not(.#{$prefix}--table-column-checkbox) {
padding-top: rem(14px);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@
background-color $duration--fast-02 motion(standard, productive);
}

//compact child row padding
.#{$prefix}--data-table--compact
tr.#{$prefix}--parent-row.#{$prefix}--expandable-row
+ tr[data-child-row]
td {
padding-left: 2.5rem;
}

//short child row padding
.#{$prefix}--data-table--short
tr.#{$prefix}--parent-row.#{$prefix}--expandable-row
+ tr[data-child-row]
td {
padding-left: 3rem;
}

//tall child row padding
.#{$prefix}--data-table--tall
tr.#{$prefix}--parent-row.#{$prefix}--expandable-row
+ tr[data-child-row]
td {
padding-left: 5rem;
}

tr.#{$prefix}--parent-row.#{$prefix}--expandable-row
+ tr[data-child-row]
td
Expand Down Expand Up @@ -198,6 +222,7 @@
width: 100%;
// Account for the border in `.bx--table-expand`
height: calc(100% + 1px);
padding: 0 1rem;
vertical-align: inherit;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const Usage = () => (
</TableBatchActions>
<TableToolbarContent>
<TableToolbarSearch
defaultExpanded
persistent="true"
tabIndex={getBatchActionProps().shouldShowBatchActions ? -1 : 0}
onChange={onInputChange}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.demo-expanded-td td {
padding-left: 4rem;
padding-bottom: 1.5rem;
padding-top: 1rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
*/

import './DataTable-expansion-story.scss';
import { action } from '@storybook/addon-actions';

import React from 'react';
import Button from '../../../Button';
import DataTable, {
Table,
TableBody,
Expand All @@ -19,6 +21,11 @@ import DataTable, {
TableHead,
TableHeader,
TableRow,
TableToolbar,
TableToolbarAction,
TableToolbarContent,
TableToolbarSearch,
TableToolbarMenu,
} from '../../../DataTable';
import { rows, headers } from '../shared';
import mdx from '../../DataTable.mdx';
Expand Down Expand Up @@ -93,6 +100,171 @@ export const Usage = () => (
</DataTable>
);

export const CompactExpansion = () => (
<DataTable rows={rows} headers={headers}>
{({
rows,
headers,
getHeaderProps,
getRowProps,
getTableProps,
onInputChange,
getToolbarProps,
getTableContainerProps,
}) => (
<TableContainer
title="DataTable"
description="With expansion"
{...getTableContainerProps()}>
<TableToolbar {...getToolbarProps()} size="small">
<TableToolbarContent>
<TableToolbarSearch persistent="true" onChange={onInputChange} />
<TableToolbarMenu>
<TableToolbarAction onClick={() => alert('Alert 1')}>
Action 1
</TableToolbarAction>
<TableToolbarAction onClick={() => alert('Alert 2')}>
Action 2
</TableToolbarAction>
<TableToolbarAction onClick={() => alert('Alert 3')}>
Action 3
</TableToolbarAction>
</TableToolbarMenu>
<Button onClick={action('Add new row')} size="small" kind="primary">
Add new
</Button>
</TableToolbarContent>
</TableToolbar>
<Table {...getTableProps()} size="compact">
<TableHead>
<TableRow>
<TableExpandHeader />
{headers.map((header, i) => (
<TableHeader key={i} {...getHeaderProps({ header })}>
{header.header}
</TableHeader>
))}
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<React.Fragment key={row.id}>
<TableExpandRow {...getRowProps({ row })}>
{row.cells.map((cell) => (
<TableCell key={cell.id}>{cell.value}</TableCell>
))}
</TableExpandRow>
<TableExpandedRow
colSpan={headers.length + 1}
className="demo-expanded-td">
<h6>Expandable row content</h6>
<div>Description here</div>
</TableExpandedRow>
</React.Fragment>
))}
</TableBody>
</Table>
</TableContainer>
)}
</DataTable>
);

export const ShortExpansion = () => (
<DataTable rows={rows} headers={headers}>
{({
rows,
headers,
getHeaderProps,
getRowProps,
getTableProps,
getTableContainerProps,
}) => (
<TableContainer
title="DataTable"
description="With expansion"
{...getTableContainerProps()}>
<Table {...getTableProps()} size="short">
<TableHead>
<TableRow>
<TableExpandHeader />
{headers.map((header, i) => (
<TableHeader key={i} {...getHeaderProps({ header })}>
{header.header}
</TableHeader>
))}
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<React.Fragment key={row.id}>
<TableExpandRow {...getRowProps({ row })}>
{row.cells.map((cell) => (
<TableCell key={cell.id}>{cell.value}</TableCell>
))}
</TableExpandRow>
<TableExpandedRow
colSpan={headers.length + 1}
className="demo-expanded-td">
<h6>Expandable row content</h6>
<div>Description here</div>
</TableExpandedRow>
</React.Fragment>
))}
</TableBody>
</Table>
</TableContainer>
)}
</DataTable>
);

export const TallExpansion = () => (
<DataTable rows={rows} headers={headers}>
{({
rows,
headers,
getHeaderProps,
getRowProps,
getTableProps,
getTableContainerProps,
}) => (
<TableContainer
title="DataTable"
description="With expansion"
{...getTableContainerProps()}>
<Table {...getTableProps()} size="tall">
<TableHead>
<TableRow>
<TableExpandHeader />
{headers.map((header, i) => (
<TableHeader key={i} {...getHeaderProps({ header })}>
{header.header}
</TableHeader>
))}
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<React.Fragment key={row.id}>
<TableExpandRow {...getRowProps({ row })}>
{row.cells.map((cell) => (
<TableCell key={cell.id}>{cell.value}</TableCell>
))}
</TableExpandRow>
<TableExpandedRow
colSpan={headers.length + 1}
className="demo-expanded-td">
<h6>Expandable row content</h6>
<div>Description here</div>
</TableExpandedRow>
</React.Fragment>
))}
</TableBody>
</Table>
</TableContainer>
)}
</DataTable>
);

export const BatchExpansion = () => (
<DataTable
rows={rows}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

.demo-expanded-td td {
padding-left: 4rem;
padding-bottom: 1.5rem;
padding-top: 1rem;
}

.demo-inner-container-header {
Expand Down