Debian Codegraph @

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

raw
1 import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
2
3 interface Repository {
4 name: string;
5 branches: string | null;
6 prs: string | null;
7 workspaces: string;
8 lastCommit: string;
9 }
10
11 export const TableCellWidth: React.FunctionComponent = () => {
12 // In real usage, this data would come from some external source like an API via props.
13 const repositories: Repository[] = [
14 { name: 'one', branches: 'two', prs: 'three', workspaces: 'four', lastCommit: 'five' },
15 { name: 'one - 2', branches: null, prs: null, workspaces: 'four - 2', lastCommit: 'five - 2' },
16 { name: 'one - 3', branches: 'two - 3', prs: 'three - 3', workspaces: 'four - 3', lastCommit: 'five - 3' }
17 ];
18
19 const columnNames = {
20 name: 'Repositories',
21 branches: 'Branches',
22 prs: 'Pull requests',
23 workspaces: 'Workspaces',
24 lastCommit: 'Last commit'
25 };
26
27 return (
28 <Table aria-label="Cell widths">
29 <Thead>
30 <Tr>
31 <Th width={15}>{columnNames.name}</Th>
32 <Th width={15}>{columnNames.branches}</Th>
33 <Th width={40} visibility={['hiddenOnMd', 'visibleOnLg']}>
34 {columnNames.prs}
35 </Th>
36 <Th width={15}>{columnNames.workspaces}</Th>
37 <Th width={15}>{columnNames.lastCommit}</Th>
38 </Tr>
39 </Thead>
40 <Tbody>
41 {repositories.map((repo) => (
42 <Tr key={repo.name}>
43 <Td dataLabel={columnNames.name}>{repo.name}</Td>
44 <Td dataLabel={columnNames.branches}>{repo.branches}</Td>
45 <Td dataLabel={columnNames.prs} visibility={['hiddenOnMd', 'visibleOnLg']}>
46 {repo.prs}
47 </Td>
48 <Td dataLabel={columnNames.workspaces}>{repo.workspaces}</Td>
49 <Td dataLabel={columnNames.lastCommit}>{repo.lastCommit}</Td>
50 </Tr>
51 ))}
52 </Tbody>
53 </Table>
54 );
55 };