diff --git a/packages/react-table/src/demos/Table.md b/packages/react-table/src/demos/Table.md index a485aad52e1..562cd7cd35f 100644 --- a/packages/react-table/src/demos/Table.md +++ b/packages/react-table/src/demos/Table.md @@ -4,6 +4,7 @@ section: components --- import { Checkbox, PageSection, ToolbarExpandIconWrapper, ToolbarContent } from '@patternfly/react-core'; +import CheckIcon from '@patternfly/react-icons/dist/esm/icons/check-icon'; import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon'; import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; @@ -277,6 +278,11 @@ class BulkSelectTableDemo extends React.Component { ```js file="table-demos/ExpandCollapseAll.jsx" ``` +### Compact + +```js isFullscreen file="table-demos/Compact.jsx" +``` + ### Column management ```js @@ -3043,7 +3049,7 @@ class LoadingStateDemo extends React.Component { props: { colSpan: 8 }, title: ( - + ) } diff --git a/packages/react-table/src/demos/table-demos/Compact.jsx b/packages/react-table/src/demos/table-demos/Compact.jsx new file mode 100644 index 00000000000..49adefa1e64 --- /dev/null +++ b/packages/react-table/src/demos/table-demos/Compact.jsx @@ -0,0 +1,135 @@ +import React from 'react'; +import { + Button, + Card, + Toolbar, + ToolbarContent, + ToolbarGroup, + ToolbarItem, + Pagination, + Select, + SelectVariant, + SelectOption, + PageSection +} from '@patternfly/react-core'; +import { TableComposable, Thead, Tr, Th, Tbody, Td, ActionsColumn } from '@patternfly/react-table'; + +import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon'; +import CheckIcon from '@patternfly/react-icons/dist/esm/icons/check-icon'; +import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper'; + +export const ComposableTable = () => { + const [isSelectOpen, setIsSelectOpen] = React.useState(false); + + const columns = ['Contributor', 'Position', 'Location', 'Last seen', 'Numbers', 'Icons']; + const rows = [ + ['Sam Jones', 'CSS guru', 'Not too sure', 'May 9, 2018', '0556'], + ['Amy Miller', 'Visual design', 'Raleigh', 'May 9, 2018', '9492'], + ['Steve Wilson', 'Visual design lead', 'Westford', 'May 9, 2018', '9929'], + ['Emma Jackson', 'Interaction design', 'Westford', 'May 9, 2018', '2217'] + ]; + + const defaultActions = () => [ + { + title: 'Settings', + // eslint-disable-next-line no-console + onClick: () => console.log(`clicked on Settings`) + }, + { + title: 'Help', + // eslint-disable-next-line no-console + onClick: () => console.log(`clicked on Help`) + } + ]; + const renderPagination = (variant, isCompact) => ( + + ); + + const tableToolbar = ( + + + + + + + + + + + {renderPagination('top', true)} + + + ); + + return ( + + + + + {tableToolbar} + + + + {columns.map((column, columnIndex) => ( + {column} + ))} + + + + {rows.map((row, rowIndex) => ( + + <> + {row[0]} + {row[1]} + {row[2]} + {row[3]} + {row[4]} + + + + + Action link + + + + + + + ))} + + + {renderPagination('bottom', false)} + + + + + ); +};