Skip to content

Commit bba26a3

Browse files
pkp/pkp-lib#7495 Refactor & document Table, improve styling, various … (#332)
* pkp/pkp-lib#7495 Refactor & document Table, improve styling, various improvements
1 parent 8dc0d9e commit bba26a3

22 files changed

+445
-460
lines changed

public/globals.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ window.pkp = {
2020
preferredName: 'Daniel Barnes',
2121
},
2222

23+
/**
24+
*
25+
*
26+
*/
27+
context: {
28+
apiBaseUrl: 'https://mock/index.php/publicknowledge/api/v1/',
29+
},
30+
2331
/**
2432
* Dummy constants required by components
2533
*/

src/components/TableNext/Table.mdx

Lines changed: 13 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,33 @@
11
import {Primary, Controls, Stories, Meta, ArgTypes} from '@storybook/blocks';
22

33
import * as TableStories from './Table.stories.js';
4+
import TableColumn from './TableColumn.vue';
5+
import TableCell from './TableCell.vue';
46

57
<Meta of={TableStories} />
68

79
# Table
810

911
## Usage
1012

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.
1214

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-
## &lt;TableCell&gt;
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
3916

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.
5218

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.
5420

55-
## Sorting
21+
## Table Props
5622

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 />
7724

78-
## Accessible Caption
25+
## TableColumn Props
7926

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} />
8128

82-
```html
83-
<pkp-table>
84-
<pkp-header #caption>
85-
<h2>Example Table</h2>
86-
</pkp-header>
87-
</pkp-table>
88-
```
29+
# TableCell Props
8930

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} />
9132

92-
<ArgTypes />
33+
<Primary />

0 commit comments

Comments
 (0)