Skip to content

Commit

Permalink
Merge pull request #29 from jbetancur/28-table-header-fixes
Browse files Browse the repository at this point in the history
table header should show overflow and hide actions on pending state
  • Loading branch information
jbetancur authored Jun 18, 2018
2 parents 2f1e781 + 0ff554e commit 6990df2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
15 changes: 8 additions & 7 deletions src/DataTable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,14 @@ class DataTable extends Component {
overflowY={overflowY}
>
{!noHeader &&
<TableHeader
title={title}
showContextMenu={selectedCount > 0}
contextTitle={this.generateDefaultContextTitle()}
contextActions={contextActions}
actions={actions}
/>}
<TableHeader
title={title}
showContextMenu={selectedCount > 0}
contextTitle={this.generateDefaultContextTitle()}
contextActions={contextActions}
actions={actions}
pending={progressPending}
/>}

<TableWrapper>
{progressPending &&
Expand Down
14 changes: 9 additions & 5 deletions src/DataTable/TableHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ContextMenu from './ContextMenu';

const TableHeaderStyle = styled.header`
position: relative;
overflow: hidden;
overflow: visible;
display: flex;
flex: 1 0 auto;
align-items: center;
Expand All @@ -26,21 +26,23 @@ const Actions = styled.div`
flex: 1 0 auto;
display: flex;
justify-content: flex-end;
align-items: center;
> * {
margin-left: 5px;
}
`;

const TableHeader = ({ title, showContextMenu, contextTitle, actions, contextActions }) => (
const TableHeader = ({ title, showContextMenu, contextTitle, actions, contextActions, pending }) => (
<TableHeaderStyle>
<Title>
{title}
</Title>

<Actions>
{actions}
</Actions>
{!pending &&
<Actions>
{actions}
</Actions>}

<ContextMenu
visible={showContextMenu}
Expand All @@ -59,13 +61,15 @@ TableHeader.propTypes = {
contextTitle: PropTypes.string,
actions: PropTypes.arrayOf(PropTypes.node),
contextActions: PropTypes.arrayOf(PropTypes.node),
pending: PropTypes.bool,
};

TableHeader.defaultProps = {
showContextMenu: false,
contextTitle: '',
actions: [],
contextActions: [],
pending: false,
};

export default withTheme(TableHeader);
4 changes: 4 additions & 0 deletions src/DataTable/__tests__/__snapshots__/DataTable.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exports[`component <DataTable /> should render correctly 1`] = `
<WithTheme(TableHeader)
contextActions={Array []}
contextTitle="0 item selected"
pending={false}
showContextMenu={false}
title=""
/>
Expand All @@ -39,6 +40,7 @@ exports[`component <DataTable /> should render correctly if the keyField is over
<WithTheme(TableHeader)
contextActions={Array []}
contextTitle="0 item selected"
pending={false}
showContextMenu={false}
title=""
/>
Expand Down Expand Up @@ -135,6 +137,7 @@ exports[`component <DataTable /> should render correctly with a default sort fie
<WithTheme(TableHeader)
contextActions={Array []}
contextTitle="0 item selected"
pending={false}
showContextMenu={false}
title=""
/>
Expand Down Expand Up @@ -231,6 +234,7 @@ exports[`component <DataTable /> should render correctly with columns/data 1`] =
<WithTheme(TableHeader)
contextActions={Array []}
contextTitle="0 item selected"
pending={false}
showContextMenu={false}
title=""
/>
Expand Down
13 changes: 9 additions & 4 deletions src/DataTable/__tests__/__snapshots__/TableHeader.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports[`component <TableHeader title /> should render correctly 1`] = `
.c0 {
position: relative;
overflow: hidden;
overflow: visible;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -82,6 +82,10 @@ exports[`component <TableHeader title /> should render correctly 1`] = `
-webkit-justify-content: flex-end;
-ms-flex-pack: end;
justify-content: flex-end;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.c2 > * {
Expand All @@ -95,6 +99,7 @@ exports[`component <TableHeader title /> should render correctly 1`] = `
actions={Array []}
contextActions={Array []}
contextTitle=""
pending={false}
showContextMenu={false}
theme={
Object {
Expand Down Expand Up @@ -221,7 +226,7 @@ exports[`component <TableHeader title /> should render correctly 1`] = `
exports[`component <TableHeader title contextActions /> should render correctly 1`] = `
.c0 {
position: relative;
overflow: hidden;
overflow: visible;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -266,7 +271,7 @@ exports[`component <TableHeader title contextActions /> should render correctly
exports[`component <TableHeader title contextTitle /> should render correctly 1`] = `
.c0 {
position: relative;
overflow: hidden;
overflow: visible;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -305,7 +310,7 @@ exports[`component <TableHeader title contextTitle /> should render correctly 1`
exports[`component <TableHeader title showContextMenu /> should render correctly 1`] = `
.c0 {
position: relative;
overflow: hidden;
overflow: visible;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down

0 comments on commit 6990df2

Please sign in to comment.