diff --git a/src-docs/src/views/tables/custom/custom.js b/src-docs/src/views/tables/custom/custom.js index ca9c9c4fd488..5b7979693d85 100644 --- a/src-docs/src/views/tables/custom/custom.js +++ b/src-docs/src/views/tables/custom/custom.js @@ -26,6 +26,9 @@ import { EuiTableRow, EuiTableRowCell, EuiTableRowCellCheckbox, + EuiTableSortMobile, + EuiTableSortMobileItem, + EuiTableHeaderMobile, } from '../../../../../src/components'; import { @@ -207,11 +210,20 @@ export default class extends Component { alignment: LEFT_ALIGNMENT, width: '24px', cellProvider: cell => , + hideForMobile: true, }, { id: 'title', label: 'Title', alignment: LEFT_ALIGNMENT, isSortable: true, + hideForMobile: true, + }, { + id: 'title_type', + label: 'Title', + isMobileHeader: true, + render: (title, item) => ( + {title} + ), }, { id: 'health', label: 'Health', @@ -332,36 +344,59 @@ export default class extends Component { return this.state.itemIdToOpenActionsPopoverMap[itemId]; }; - renderHeaderCells() { + renderSelectAll = mobile => { + return ( + + ); + } + + renderHeaderCells(mobile) { return this.columns.map((column, columnIndex) => { if (column.isCheckbox) { + if (!mobile) { + return ( + + {this.renderSelectAll()} + + ); + } + } + + if (mobile) { + return ( + + {column.label} + + ); + } else { return ( - - - + {column.label} + ); } - - return ( - - {column.label} - - ); }); } @@ -391,6 +426,7 @@ export default class extends Component { key={column.id} header={column.label} textOnly={false} + hasActions={true} align="right" > {item.title.value} : titleText; + child = column.render(title, item); + } else if (column.cellProvider) { child = column.cellProvider(cell); } else if (cell.isLink) { child = {cell.value}; @@ -460,6 +500,8 @@ export default class extends Component { align={column.alignment} truncateText={cell && cell.truncateText} textOnly={cell ? cell.textOnly : true} + hideForMobile={column.hideForMobile} + isMobileHeader={column.isMobileHeader} > {child} @@ -470,6 +512,8 @@ export default class extends Component { {cells} @@ -509,6 +553,17 @@ export default class extends Component { + + + {this.renderSelectAll(true)} + + + {this.renderHeaderCells(true)} + + + + + {this.renderHeaderCells()} diff --git a/src/components/basic_table/__snapshots__/basic_table.test.js.snap b/src/components/basic_table/__snapshots__/basic_table.test.js.snap index 0bf9cfc7f5fc..3f4dfbb3e9f0 100644 --- a/src/components/basic_table/__snapshots__/basic_table.test.js.snap +++ b/src/components/basic_table/__snapshots__/basic_table.test.js.snap @@ -5,6 +5,7 @@ exports[`EuiBasicTable basic - empty - custom message 1`] = ` className="euiBasicTable testClass1 testClass2" >
+
+
+
+
+
+
+
+
- - - Name - - + + + + Name + + +
- - - Name - - + + + + Name + + +
- - - Count - - + + + + Count + + +
- - - Name - - + + + + Name + + +
- - - Name - - + + + + Name + + +
- - - Count - - + + + + Count + + +
+
- - - Name - - + + + + Name + + + { this.tableElement = element; }} > - {mobileSort} + {mobileSort} {head}{body}
); diff --git a/src/components/index.js b/src/components/index.js index 887de8ccab91..b6b220d74251 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -235,11 +235,12 @@ export { EuiTableHeaderCell, EuiTableHeaderCellCheckbox, EuiTablePagination, - EuiTableSortMobile, - EuiTableSortMobileItem, EuiTableRow, EuiTableRowCell, EuiTableRowCellCheckbox, + EuiTableHeaderMobile, + EuiTableSortMobile, + EuiTableSortMobileItem, } from './table'; export { diff --git a/src/components/table/__snapshots__/table_header_cell_checkbox.test.js.snap b/src/components/table/__snapshots__/table_header_cell_checkbox.test.js.snap index 14264e0c8535..4e921b9ccd66 100644 --- a/src/components/table/__snapshots__/table_header_cell_checkbox.test.js.snap +++ b/src/components/table/__snapshots__/table_header_cell_checkbox.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`EuiTableHeaderCellCheckbox is rendered 1`] = ` - - + `; diff --git a/src/components/table/_index.scss b/src/components/table/_index.scss index b390b90eddbc..4f47f5ad5bc2 100644 --- a/src/components/table/_index.scss +++ b/src/components/table/_index.scss @@ -12,4 +12,4 @@ } @import "table"; -@import "responsive"; +@import "mobile/index"; diff --git a/src/components/table/_table.scss b/src/components/table/_table.scss index 225e538c9ecd..729217cf6448 100644 --- a/src/components/table/_table.scss +++ b/src/components/table/_table.scss @@ -12,6 +12,11 @@ background-color: $euiColorEmptyShade; } +.euiTableHeaderMobile { + padding: $euiSizeS; +} + +.euiTableHeaderMobile, .euiTableSortMobile { display: none; } diff --git a/src/components/table/index.js b/src/components/table/index.js index 5c4caaa5ed20..da56b30da2ff 100644 --- a/src/components/table/index.js +++ b/src/components/table/index.js @@ -5,8 +5,9 @@ export { EuiTableHeaderButton } from './table_header_button'; export { EuiTableHeaderCell } from './table_header_cell'; export { EuiTableHeaderCellCheckbox } from './table_header_cell_checkbox'; export { EuiTablePagination } from './table_pagination'; -export { EuiTableSortMobile } from './table_sort_mobile'; -export { EuiTableSortMobileItem } from './table_sort_mobile_item'; +export { EuiTableHeaderMobile } from './mobile/table_header_mobile'; +export { EuiTableSortMobile } from './mobile/table_sort_mobile'; +export { EuiTableSortMobileItem } from './mobile/table_sort_mobile_item'; export { EuiTableRow } from './table_row'; export { EuiTableRowCell } from './table_row_cell'; export { EuiTableRowCellCheckbox } from './table_row_cell_checkbox'; diff --git a/src/components/table/mobile/__snapshots__/table_header_mobile.test.js.snap b/src/components/table/mobile/__snapshots__/table_header_mobile.test.js.snap new file mode 100644 index 000000000000..2aafb93781b6 --- /dev/null +++ b/src/components/table/mobile/__snapshots__/table_header_mobile.test.js.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EuiTableHeaderMobile is rendered 1`] = ` +
+`; diff --git a/src/components/table/__snapshots__/table_sort_mobile.test.js.snap b/src/components/table/mobile/__snapshots__/table_sort_mobile.test.js.snap similarity index 95% rename from src/components/table/__snapshots__/table_sort_mobile.test.js.snap rename to src/components/table/mobile/__snapshots__/table_sort_mobile.test.js.snap index 3e12888b9cb5..06de16355522 100644 --- a/src/components/table/__snapshots__/table_sort_mobile.test.js.snap +++ b/src/components/table/mobile/__snapshots__/table_sort_mobile.test.js.snap @@ -8,12 +8,11 @@ exports[`EuiTableSortMobile is rendered 1`] = ` aria-label="aria-label" class="euiPopover euiPopover--anchorDownLeft" data-test-subj="test subject string" - style="min-width:200px" >