FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(Table): Add the wrap transform by boaz0 · Pull Request #2615 · patternfly/patternfly-react · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (4) .md  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
    • Table.md
    • index.js
        • wrappable.js
      • transformers.js
      • transformers.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
compoundExpand,
cellWidth,
textCenter,
wrappable,
classNames,
Visibility
} from '@patternfly/react-table';
Expand Down Expand Up @@ -1032,4 +1033,48 @@ class CompoundExpandableTable extends React.Component {
);
}
}
```
```

## Table with headers that wrap

```js
import React from 'react';
import {
Table,
TableHeader,
TableBody,
wrappable
} from '@patternfly/react-table';

class CompactTable extends React.Component {
constructor(props) {
super(props);
this.state = {
columns: [
{title: 'This is a really long table header that goes on for a long time 1.', transforms: [wrappable]},
{title: 'This is a really long table header that goes on for a long time 2.', transforms: [wrappable]},
{title: 'This is a really long table header that goes on for a long time 3.', transforms: [wrappable]},
{title: 'This is a really long table header that goes on for a long time 4.', transforms: [wrappable]},
{title: 'This is a really long table header that goes on for a long time 5.', transforms: [wrappable]},
],
rows: [
['Repository 1', '10', '25', '5', '2 days ago'],
['Repository 2', '10', '25', '5', '2 days ago'],
['Repository 3', '10', '25', '5', '2 days ago'],
['Repository 4', '10', '25', '5', '2 days ago'],
]
};
}

render() {
const { columns, rows } = this.state;

return (
<Table caption="Wrappable headers" cells={columns} rows={rows}>
<TableHeader />
<TableBody />
</Table>
);
}
}
```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export {
sortable,
headerCol,
cellWidth,
wrappable,
expandable,
isRowExpanded,
textCenter,
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { css, getModifier } from '@patternfly/react-styles';
import styles from '@patternfly/react-styles/css/components/Table/table';

export default () => ({
className: css(getModifier(styles, 'wrap'))
});
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export { default as selectable } from './decorators/selectable';
export { default as sortable } from './decorators/sortable';
export { default as cellActions } from './decorators/cellActions';
export { default as cellWidth } from './decorators/cellWidth';
export { default as wrappable } from './decorators/wrappable';
export { default as textCenter } from './decorators/textCenter';
export { collapsible, expandedRow, expandable } from './decorators/collapsible';
export { compoundExpand } from './decorators/compoundExpand';
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
mapProps,
expandable,
expandedRow,
wrappable,
textCenter
} from './transformers';
import { DropdownDirection, DropdownPosition } from '@patternfly/react-core';
Expand Down Expand Up @@ -267,4 +268,8 @@ describe('Transformer functions', () => {
test('textCenter', () => {
expect(textCenter()).toEqual({ textCenter: true });
});

test('wrappable', () => {
expect(wrappable()).toEqual({ className: 'pf-m-wrap' });
});
});

Back | FazBrowse Home | New Git URL