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

Responsive tables #584

Merged
merged 41 commits into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ed6671b
Basic initialization of responsive table
Mar 26, 2018
55a54fa
Allowing for custom row headers
Mar 26, 2018
b514a61
Adding support for selections in mobile
Mar 26, 2018
12d97cd
Keeping pagination on one line (no responsive)
Mar 27, 2018
7e687dd
Created mobile context menu for filtering
Mar 27, 2018
a0cdbf6
Scrolling to top of table when:
Mar 27, 2018
3c7556d
Added support for actions in mobile
Mar 27, 2018
d0f34b0
Modifying the Custom table example
Mar 28, 2018
6d99e66
Allowing cells in mobile view to be explicitly 100% wide
Mar 28, 2018
9a1db8f
Displaying table cells as panels
Mar 28, 2018
8af8ced
Added support for expanding rows
Mar 29, 2018
e4b4b43
Removing truncation option in columns data for mobile headers
Mar 29, 2018
f271203
Better expandable row styles
Mar 29, 2018
3f0badd
Table style updates:
Mar 29, 2018
f729dc3
Fixes #460 Implement `compressed` on `InMemoryTable`
Mar 29, 2018
8c90377
Didn’t mean to commit compressed on basic example
Mar 29, 2018
4847a4b
Fixing up some expandable stuff
Mar 30, 2018
38bead6
Cleaning up CSS
Mar 30, 2018
d3ef1df
Compressed !== true
Mar 30, 2018
c6807ba
Make EuiTableSortMobile render EuiTableSortMobileItems, so that popov…
jen-huang Apr 5, 2018
95f907a
Fix TableSortMobile re-rendering, remove hideForMobile flag, re-rende…
jen-huang Apr 13, 2018
ed4ea6e
Fixing padding side and rebase issue
Apr 16, 2018
37b02ea
Positioning actions always on the right
Apr 16, 2018
934dd8e
Using new class selector to always display hover items
Apr 16, 2018
b04fa4b
Putting loading indicator on tbody so it’s visible on mobile too
Apr 16, 2018
a78f65a
Allowing tables to not be responsive
Apr 16, 2018
9fabb04
Updating docs
Apr 16, 2018
b28de1b
updating tables in button guidelines doc
Apr 16, 2018
789812f
Setting BasicTable default prop responsive = true
Apr 17, 2018
5370bad
Added responsive props to EuiInMemoryTable
Apr 17, 2018
5d2b324
Addressing PR feedback
Apr 17, 2018
d8f3e15
Added extra comment in docs
Apr 17, 2018
ba46ee1
Add comments
jen-huang Apr 17, 2018
0729da1
Removing min-height on psuedo title
Apr 17, 2018
1e33894
Revert "Removing min-height on psuedo title"
Apr 17, 2018
ab4380d
Removing min-height of cell header if it’s the only cell that exists
Apr 17, 2018
16d0db5
Fixing exclusivity of isExpandable and hasActions
Apr 17, 2018
5ac259f
Change function name, move stringify to inside getWatchedPropsForItems
jen-huang Apr 18, 2018
e83cd52
Addressing more PR requests
Apr 18, 2018
7330bb0
Adressing SASS PR feedback
Apr 18, 2018
64ab9ec
changelog
Apr 18, 2018
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- `EuiForm` and `EuiFormRow` now accept nodes for `errors` prop ([#685](https://github.com/elastic/eui/pull/685))
- Removed the default `max-width` from `EuiText`. This can still be applied by setting `grow={false}` ([#683](https://github.com/elastic/eui/pull/683))
- Added support for text alignment with `EuiTextAlign` ([#683](https://github.com/elastic/eui/pull/683))
- Added responsive support for tables. **Responsive table views are on by default.** ([#584](https://github.com/elastic/eui/pull/584))

**Bug fixes**

Expand Down
8 changes: 4 additions & 4 deletions src-docs/src/components/guide_section/guide_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,19 @@ export class GuideSection extends Component {
}
const cells = [
(
<EuiTableRowCell key="name">
<EuiTableRowCell key="name" header="Prop">
{humanizedName}
</EuiTableRowCell>
), (
<EuiTableRowCell key="type">
<EuiTableRowCell key="type" header="Type">
<EuiCode>{typeMarkup}</EuiCode>
</EuiTableRowCell>
), (
<EuiTableRowCell key="defaultValue">
<EuiTableRowCell key="defaultValue" header="Default" hideForMobile={!defaultValue}>
{defaultValueMarkup}
</EuiTableRowCell>
), (
<EuiTableRowCell key="description">
<EuiTableRowCell key="description" header="Note" isMobileFullWidth={true} hideForMobile={!propDescription}>
{descriptionMarkup}
</EuiTableRowCell>
)
Expand Down
14 changes: 7 additions & 7 deletions src-docs/src/views/guidelines/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ export default() => (

<EuiTableBody>
<EuiTableRow>
<EuiTableRowCell>
<EuiTableRowCell isMobileHeader>
<EuiButton>
Add thing
</EuiButton>
Expand All @@ -493,7 +493,7 @@ export default() => (
</EuiTableRow>

<EuiTableRow>
<EuiTableRowCell>
<EuiTableRowCell isMobileHeader>
<EuiButtonEmpty size="s">
Cancel
</EuiButtonEmpty>
Expand All @@ -505,7 +505,7 @@ export default() => (
</EuiTableRow>

<EuiTableRow>
<EuiTableRowCell>
<EuiTableRowCell isMobileHeader>
<EuiButton fill>
Create thing
</EuiButton>
Expand All @@ -519,7 +519,7 @@ export default() => (
</EuiTableRow>

<EuiTableRow>
<EuiTableRowCell>
<EuiTableRowCell isMobileHeader>
<EuiButton color="danger" fill>
Delete
</EuiButton>&nbsp;&nbsp;
Expand All @@ -536,7 +536,7 @@ export default() => (
</EuiTableRow>

<EuiTableRow>
<EuiTableRowCell>
<EuiTableRowCell isMobileHeader>
<EuiButton color="danger">
Remove
</EuiButton>&nbsp;&nbsp;
Expand All @@ -549,7 +549,7 @@ export default() => (
</EuiTableRow>

<EuiTableRow>
<EuiTableRowCell>
<EuiTableRowCell isMobileHeader>
<EuiButton fill>
Save
</EuiButton>&nbsp;&nbsp;
Expand All @@ -574,7 +574,7 @@ export default() => (

<EuiSpacer/>

<EuiTable>
<EuiTable responsive={false}>
<EuiTableHeader>
<EuiTableHeaderCell>
Text
Expand Down
13 changes: 12 additions & 1 deletion src-docs/src/views/tables/actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,20 @@ export class Table extends Component {
field: 'firstName',
name: 'First Name',
truncateText: true,
sortable: true
sortable: true,
hideForMobile: true,
}, {
field: 'lastName',
name: 'Last Name',
truncateText: true,
hideForMobile: true,
}, {
field: 'firstName',
name: 'Full Name',
isMobileHeader: true,
render: (name, item) => (
<span>{item.firstName} {item.lastName}</span>
),
}, {
field: 'github',
name: 'Github',
Expand Down Expand Up @@ -287,6 +296,8 @@ export class Table extends Component {
pagination={pagination}
sorting={sorting}
selection={selection}
isSelectable={true}
hasActions={true}
onChange={this.onTableChange}
/>
</Fragment>
Expand Down
11 changes: 10 additions & 1 deletion src-docs/src/views/tables/basic/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,23 @@ export const Table = () => {
field: 'firstName',
name: 'First Name',
sortable: true,
hideForMobile: true,
'data-test-subj': 'firstNameCell',
}, {
field: 'lastName',
name: 'Last Name',
truncateText: true,
hideForMobile: true,
render: (name) => (
<EuiLink href="#" target="_blank">{name}</EuiLink>
)
),
}, {
field: 'firstName',
name: 'Full Name',
isMobileHeader: true,
render: (name, item) => (
<span>{item.firstName} <EuiLink href="#" target="_blank">{item.lastName}</EuiLink></span>
),
}, {
field: 'github',
name: 'Github',
Expand Down
1 change: 1 addition & 0 deletions src-docs/src/views/tables/custom/compressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export default class extends Component {
return (
<EuiTableRowCell
key={column.id}
header={column.label}
align={column.alignment}
truncateText={cell && cell.truncateText}
>
Expand Down
104 changes: 82 additions & 22 deletions src-docs/src/views/tables/custom/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
EuiTableRow,
EuiTableRowCell,
EuiTableRowCellCheckbox,
EuiTableSortMobile,
EuiTableHeaderMobile,
} from '../../../../../src/components';

import {
Expand Down Expand Up @@ -207,11 +209,20 @@ export default class extends Component {
alignment: LEFT_ALIGNMENT,
width: '24px',
cellProvider: cell => <EuiIcon type={cell} size="m" />,
hideForMobile: true,
}, {
id: 'title',
label: 'Title',
alignment: LEFT_ALIGNMENT,
isSortable: true,
hideForMobile: true,
}, {
id: 'title_type',
label: 'Title',
isMobileHeader: true,
render: (title, item) => (
<span><EuiIcon type={item.type} size="m" style={{ verticalAlign: "text-top" }} /> {title}</span>
),
}, {
id: 'health',
label: 'Health',
Expand Down Expand Up @@ -332,37 +343,66 @@ export default class extends Component {
return this.state.itemIdToOpenActionsPopoverMap[itemId];
};

renderSelectAll = mobile => {
return (
<EuiCheckbox
id="selectAllCheckbox"
label={mobile ? 'Select all' : null}
checked={this.areAllItemsSelected()}
onChange={this.toggleAll.bind(this)}
type={mobile ? null : 'inList'}
/>
);
}

getTableMobileSortItems() {
const items = [];
this.columns.forEach((column) => {
if (column.isCheckbox || !column.isSortable) {
return;
}
items.push({
name: column.label,
key: column.id,
onSort: this.onSort.bind(this, column.id),
isSorted: this.state.sortedColumn === column.id,
isSortAscending: this.sortableProperties.isAscendingByName(column.id),
});
});
return items.length ? items : null;
}

renderHeaderCells() {
return this.columns.map((column, columnIndex) => {
const headers = [];

this.columns.forEach((column, columnIndex) => {
if (column.isCheckbox) {
return (
headers.push(
<EuiTableHeaderCellCheckbox
key={column.id}
width={column.width}
>
<EuiCheckbox
id="selectAllCheckbox"
checked={this.areAllItemsSelected()}
onChange={this.toggleAll.bind(this)}
type="inList"
/>
{this.renderSelectAll()}
</EuiTableHeaderCellCheckbox>
);
} else {
headers.push(
<EuiTableHeaderCell
key={column.id}
align={this.columns[columnIndex].alignment}
width={column.width}
onSort={column.isSortable ? this.onSort.bind(this, column.id) : undefined}
isSorted={this.state.sortedColumn === column.id}
isSortAscending={this.sortableProperties.isAscendingByName(column.id)}
isMobileHeader={column.isMobileHeader}
>
{column.label}
</EuiTableHeaderCell>
);
}

return (
<EuiTableHeaderCell
key={column.id}
align={this.columns[columnIndex].alignment}
width={column.width}
onSort={column.isSortable ? this.onSort.bind(this, column.id) : undefined}
isSorted={this.state.sortedColumn === column.id}
isSortAscending={this.sortableProperties.isAscendingByName(column.id)}
>
{column.label}
</EuiTableHeaderCell>
);
});

return headers.length ? headers : null;
}

renderRows() {
Expand All @@ -389,7 +429,9 @@ export default class extends Component {
return (
<EuiTableRowCell
key={column.id}
header={column.label}
textOnly={false}
hasActions={true}
align="right"
>
<EuiPopover
Expand Down Expand Up @@ -442,7 +484,11 @@ export default class extends Component {
);
}

if (column.cellProvider) {
if (column.render) {
const titleText = item.title.truncateText ? item.title.value : item.title;
const title = item.title.isLink ? <EuiLink href="">{item.title.value}</EuiLink> : titleText;
child = column.render(title, item);
} else if (column.cellProvider) {
child = column.cellProvider(cell);
} else if (cell.isLink) {
child = <EuiLink href="">{cell.value}</EuiLink>;
Expand All @@ -455,9 +501,12 @@ export default class extends Component {
return (
<EuiTableRowCell
key={column.id}
header={column.label}
align={column.alignment}
truncateText={cell && cell.truncateText}
textOnly={cell ? cell.textOnly : true}
hideForMobile={column.hideForMobile}
isMobileHeader={column.isMobileHeader}
>
{child}
</EuiTableRowCell>
Expand All @@ -468,6 +517,8 @@ export default class extends Component {
<EuiTableRow
key={item.id}
isSelected={this.isItemSelected(item.id)}
isSelectable={true}
hasActions={true}
>
{cells}
</EuiTableRow>
Expand Down Expand Up @@ -507,6 +558,15 @@ export default class extends Component {

<EuiSpacer size="m" />

<EuiTableHeaderMobile>
<EuiFlexGroup responsive={false} justifyContent="spaceBetween" alignItems="baseline">
<EuiFlexItem grow={false}>{this.renderSelectAll(true)}</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiTableSortMobile items={this.getTableMobileSortItems()} />
</EuiFlexItem>
</EuiFlexGroup>
</EuiTableHeaderMobile>

<EuiTable>
<EuiTableHeader>
{this.renderHeaderCells()}
Expand Down
Loading