Debian Codegraph @

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

raw
1 import { useState } from 'react';
2 import { Table, Thead, Tr, Th, Tbody, Td, TableText } from '@patternfly/react-table';
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 const columnNames = {
8 truncate: 'Truncating text',
9 wrap: 'Wrapping table header text. This th text will wrap instead of truncate.'
10 };
11
12 export const TableTextModifiers: React.FunctionComponent = () => {
13 const [focused, setFocused] = useState(false);
14
15 return (
16 <Table aria-label="Table text">
17 <Thead>
18 <Tr>
19 <Th width={30}>{columnNames.truncate}</Th>
20 <Th>{columnNames.wrap}</Th>
21 </Tr>
22 </Thead>
23 <Tbody>
24 <Tr>
25 <Td
26 onFocus={() => setFocused(true)}
27 onBlur={() => setFocused(false)}
28 tabIndex={0}
29 dataLabel={columnNames.truncate}
30 >
31 <TableText focused={focused} wrapModifier="truncate">
32 This text will truncate instead of wrap.
33 </TableText>
34 </Td>
35 <Td dataLabel={columnNames.wrap}>
36 <TableText wrapModifier="nowrap">
37 <a href="#">This is a link that needs to be on one line and fully readable.</a>
38 </TableText>
39 </Td>
40 </Tr>
41 </Tbody>
42 </Table>
43 );
44 };