Debian Codegraph @

node/@patternfly/react-table/src/deprecated/components/Table/examples/LegacyTableControllingText.tsx

raw
1 import { cellWidth, truncate, breakWord, wrappable, fitContent, nowrap } from '@patternfly/react-table';
2 import { Table, TableHeader, TableBody, TableProps } from '@patternfly/react-table/deprecated';
3
4 // This example has been simplified to focus on the text modifier props. In real usage,
5 // you may want to derive your rows from typed underlying data and minimal state. See other examples.
6
7 export const LegacyTableControllingText: React.FunctionComponent = () => {
8 const columns: TableProps['cells'] = [
9 { title: 'Truncate (width 20%)', transforms: [cellWidth(20)], cellTransforms: [truncate] },
10 { title: 'Break word', cellTransforms: [breakWord] },
11 { title: 'Wrapping table header text. This th text will wrap instead of truncate.', transforms: [wrappable] },
12 { title: 'Fit content', transforms: [fitContent] },
13 { title: '', cellTransforms: [nowrap] }
14 ];
15 const rows: TableProps['rows'] = [
16 [
17 'This text will truncate instead of wrap.',
18 { title: <a href="#">http://thisisaverylongurlthatneedstobreakusethebreakwordmodifier.org</a> },
19 {
20 title: (
21 <p>
22 By default,
23 <code>thead</code> cells will truncate and
24 <code>tbody</code> cells will wrap. Use
25 <code>transforms</code> and/or <code>cellTransforms</code> to change the behavior.
26 </p>
27 )
28 },
29 "This cell's content will adjust itself to the parent th width. This modifier only affects table layouts.",
30 { title: <a href="#">No wrap</a> }
31 ]
32 ];
33
34 return (
35 <Table aria-label="Controlling text" cells={columns} rows={rows}>
36 <TableHeader />
37 <TableBody />
38 </Table>
39 );
40 };