|
1 | 1 | import {Primary, Controls, Stories, Meta, ArgTypes} from '@storybook/blocks'; |
2 | 2 |
|
3 | 3 | import * as TableStories from './Table.stories.js'; |
| 4 | +import TableColumn from './TableColumn.vue'; |
| 5 | +import TableCell from './TableCell.vue'; |
4 | 6 |
|
5 | 7 | <Meta of={TableStories} /> |
6 | 8 |
|
7 | 9 | # Table |
8 | 10 |
|
9 | 11 | ## Usage |
10 | 12 |
|
11 | | -WIP Some informations are inaccurate. |
| 13 | +Use the `Table` component to display tabular data when the user will sort, search, filter, or if interactive elements such as a button appear within the table. |
12 | 14 |
|
13 | | -## Usage |
14 | | - |
15 | | -Use the `Table` component to display tabular data when the user will sort, search, filter or edit the rows in the table, or if interactive elements such as a button appear within the table. |
16 | | - |
17 | | -## Datagrid |
18 | | - |
19 | | -This component implements a [Data Grid](https://www.w3.org/TR/wai-aria-practices/examples/grid/dataGrids.html), which provides accessible keyboard controls and markup for managing the data in the table. All interactions in the table rows, including buttons or fields to edit a row, must be accessible by keyboard. |
20 | | - |
21 | | -## <TableCell> |
22 | | - |
23 | | -All cells in the table must use the `<TableCell>` component in order to support the accessible keyboard navigation features. Use a `<TableCell>` inside of a `<tr>` in the same way that a `<td>` element would be used. |
24 | | - |
25 | | -```html |
26 | | -<pkp-table> |
27 | | - <tr> |
28 | | - <table-cell :isRowHeader="true">dbarnes</table-cell> |
29 | | - <table-cell>Daniel Barnes</table-cell> |
30 | | - </tr> |
31 | | - <tr> |
32 | | - <table-cell :isRowHeader="true">sminotue</table-cell> |
33 | | - <table-cell>Stephanie Minotue</table-cell> |
34 | | - </tr> |
35 | | -</pkp-table> |
36 | | -``` |
37 | | - |
38 | | -When writing a `<TableCell>` in a Smarty template, you must use a `<td>` with with the `is` attribute. |
| 15 | +## Accessibility |
39 | 16 |
|
40 | | -```html |
41 | | -<pkp-table> |
42 | | - <tr> |
43 | | - <td is="table-cell" :isRowHeader="true">dbarnes</td> |
44 | | - <td is="table-cell">Daniel Barnes</td> |
45 | | - </tr> |
46 | | - <tr> |
47 | | - <td is="table-cell" :isRowHeader="true">sminotue</td> |
48 | | - <td is="table-cell">Stephanie Minotue</td> |
49 | | - </tr> |
50 | | -</pkp-table> |
51 | | -``` |
| 17 | +Table component requires aria-label attribute to describe content of table. |
52 | 18 |
|
53 | | -This is because templates written in Smarty are parsed by the browser before they are parsed by Vue. Learn more about Vue's [DOM Template Parsing Caveats](https://v2.vuejs.org/v2/guide/components.html#DOM-Template-Parsing-Caveats). |
| 19 | +One column should be [rowheader](https://www.w3.org/TR/wai-aria-1.1/#rowheader) to improve screen reader experience. Its prop on TableCell, not on TableColumn as one would expect as it allows for significantly easier implementation. |
54 | 20 |
|
55 | | -## Sorting |
| 21 | +## Table Props |
56 | 22 |
|
57 | | -When a table can be sorted, you must [announce the changes](#/pages/announcer). When a sort is performed by making a request to the server, announce at both the start and end of the process. |
58 | | - |
59 | | -```js |
60 | | -methods: { |
61 | | - sort(col) { |
62 | | - this.$announcer.set('Loading'); |
63 | | - $.ajax({ |
64 | | - |
65 | | - // ... |
66 | | - |
67 | | - success(r) { |
68 | | - |
69 | | - // ... |
70 | | - |
71 | | - this.$announcer.set('Sorted by ' + col); |
72 | | - } |
73 | | - }); |
74 | | - } |
75 | | -} |
76 | | -``` |
| 23 | +<ArgTypes /> |
77 | 24 |
|
78 | | -## Accessible Caption |
| 25 | +## TableColumn Props |
79 | 26 |
|
80 | | -Every table needs an accessible caption. Use the `caption` slot to provide a title with the correct `<h*>` heading according to the page hierarchy. The description is optional. |
| 27 | +<ArgTypes of={TableColumn} /> |
81 | 28 |
|
82 | | -```html |
83 | | -<pkp-table> |
84 | | - <pkp-header #caption> |
85 | | - <h2>Example Table</h2> |
86 | | - </pkp-header> |
87 | | -</pkp-table> |
88 | | -``` |
| 29 | +# TableCell Props |
89 | 30 |
|
90 | | -If you do not use the `caption` slot, you must use the `labelledBy` prop to provide an accessible label for the table. See the [Labelled By](#/component/Table/with-labelledby) example. |
| 31 | +<ArgTypes of={TableCell} /> |
91 | 32 |
|
92 | | -<ArgTypes /> |
| 33 | +<Primary /> |
0 commit comments