Skip to content

Commit f4ec4c6

Browse files
committed
chore(docs): address feedback
1 parent a0abc6b commit f4ec4c6

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

packages/table/README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ import {
4444
} from '@spectrum-web-components/table';
4545
```
4646

47-
## Example
47+
### Anatomy
48+
49+
A table consists of the following parts:
50+
51+
- a table head section (`<sp-table-head>`)
52+
- header cells (`<sp-table-head-cell>`) within the table head section
53+
- a table body section, ie.`<sp-table-body>`
54+
- rows (`<sp-table-row>`) within the table body section
55+
- body cells (`<sp-table-cell>`) within the table body rows
4856

4957
```html demo
5058
<sp-table>
@@ -340,7 +348,7 @@ The `quiet` attribute creates a more subtle table appearance with a transparent
340348
</sp-tab-panel>
341349
</sp-tabs>
342350

343-
## Virtualized tables
351+
### Behaviors
344352

345353
For large amounts of data, the `<sp-table>` can be virtualised to easily add table rows by using properties.
346354

@@ -427,7 +435,7 @@ For large amounts of data, the `<sp-table>` can be virtualised to easily add tab
427435
});
428436
</script>
429437

430-
### How to use it
438+
#### How to use it
431439

432440
The virtualised table takes `items` as either a property or a JSON-encoded string, an array of type `Record`, where the key is a `string` and the value can be whatever you'd like. `items` is then fed into the `renderItem` method, which takes an `item` and its `index` as parameters and renders the `<sp-table-row>` for each item. An example is as follows:
433441
@@ -462,7 +470,7 @@ const renderItem = (item: Item, index: number): TemplateResult => {
462470
463471
Please note that there is a bug when attempting to select all virtualised elements. The items are selected programatically, it's just not reflected visually.
464472

465-
### Virtualized table selection
473+
#### Virtualized table selection
466474

467475
By default the `selected` property will surface an array of item indexes that are currently selected. However, when making a selection on a virtualized table, it can be useful to track selection as something other than indexes. To do so, set a custom method for the `itemValue` property. The `itemValue` method accepts an item and its index as arguments and should return the value you would like to track in the `selected` property.
468476

@@ -564,7 +572,7 @@ By default the `selected` property will surface an array of item indexes that ar
564572
});
565573
</script>
566574

567-
### Row Types
575+
#### Row Types
568576

569577
All values in the item array are assumed to be homogenous by default. This means all of the rendered rows are either delivered as provided, or, in the case you are leveraging `selects`, rendered with an `<sp-table-checkbox-cell>`. However, when virtualizing a table with selection, it can sometimes be useful to surface rows with additional interactions, e.g. "Load more data" links. To support that, you can optionally include the `_$rowType$` brand in your item. The values for this are outlined by the `RowType` enum and include `ITEM` (0) and `INFORMATION` (1). When `_$rowType$: RowType.INFORMATION` is provided, it instructs the `<sp-table>` not to deliver an `<sp-table-checkbox-cell>` in that row.
570578

@@ -670,7 +678,7 @@ All values in the item array are assumed to be homogenous by default. This means
670678
});
671679
</script>
672680

673-
### The `scroller` property
681+
#### The `scroller` property
674682

675683
By default, the virtualized table doesn't contain a scroll bar and will display the entire length of the table body. Use the `scroller` property and specify an inline style for the height to get a `Table` of your desired height that scrolls.
676684
@@ -796,11 +804,11 @@ For each table column you want to sort, use the `sortable` attribute in its resp
796804
});
797805
</script>
798806

799-
## Accessibility
807+
### Accessibility
800808

801809
The `<sp-table>` component provides accessibility support for tabular data:
802810

803-
### ARIA attributes
811+
#### ARIA attributes
804812

805813
The table automatically manages ARIA attributes for proper semantic structure:
806814

@@ -815,17 +823,15 @@ The table automatically manages ARIA attributes for proper semantic structure:
815823
- `aria-rowindex` on virtualized table rows
816824
- `aria-rowcount` on virtualized tables
817825

818-
### Selection accessibility
826+
#### Selection accessibility
819827

820828
When using row selection:
821829

822830
- `aria-selected` is applied to selectable rows
823831
- Selection state is announced to screen readers
824832
- Checkboxes in selection cells are properly labeled
825833

826-
### Keyboard navigation
827-
828-
#### Sortable column headers
834+
#### Keyboard navigation
829835

830836
Sortable column headers support keyboard interaction:
831837

@@ -834,14 +840,10 @@ Sortable column headers support keyboard interaction:
834840
- **Numpad Enter** - Immediately sorts the column
835841
- **Tab** - Navigates to sortable headers (only sortable headers are focusable)
836842

837-
#### Row selection
838-
839843
Selectable rows support keyboard interaction:
840844

841845
- **Click** - Toggles row selection
842846
- **Tab** - Navigates through focusable elements
843847

844-
#### Scrollable tables
845-
846848
- **Tab** - Table body automatically receives `tabindex="0"` when content is scrollable
847849
- **Mouse wheel** - Scrolls through table content when focused

0 commit comments

Comments
 (0)