Skip to content

Commit c2e4893

Browse files
author
Josep Martins
authored
Merge branch 'main' into josepmartins/accessible-frontmatter-variable
2 parents a706668 + 61a93e2 commit c2e4893

37 files changed

+3841
-2838
lines changed

.changeset/clever-hotels-kneel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Fixes the sx prop on the SegmentedControl buttons by properly merging the sx prop when cloning button children.

.changeset/heavy-pets-own.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
Adds lines to indicate the depth of items in a TreeView

.changeset/large-trains-press.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': minor
3+
---
4+
5+
Adds a `size` prop to the SegmentedControl component. Users can choose between 'medium' (default), and 'small'. More sizes can be added when/if we find we need them.

.changeset/neat-squids-cheat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
Adds support for arrow key navigation of a TreeView using `aria-activedescendant`

.changeset/stupid-knives-arrive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Reverted SelectPanel breaking behavioral changes

.changeset/tidy-beans-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
Add a `current` prop to `TreeView.Item` and `TreeView.LinkItem`

docs/content/PageLayout.mdx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,39 @@ Add `offsetHeader` prop to specify the height of the custom sticky header along
202202
</Box>
203203
```
204204

205+
### With `NavList`
206+
207+
`PageLayout.Pane` by itself does not specify or provide landmark roles. Using
208+
components that define their own landmark roles, such as [`NavList`](/NavList), will provide
209+
clear structure to the page that is not present by default in `PageLayout.Pane`.
210+
211+
It's important to note that multiple landmark roles, such as multiple
212+
`<nav>` elements, should be uniquely labelled in order to clarify what the
213+
navigation container is used for.
214+
215+
```jsx live
216+
<PageLayout>
217+
<PageLayout.Header>
218+
<Placeholder label="Header" height={64} />
219+
</PageLayout.Header>
220+
<PageLayout.Pane position="start" aria-label="Secondary navigation">
221+
<NavList>
222+
<NavList.Item href="/" aria-current="page">
223+
Home
224+
</NavList.Item>
225+
<NavList.Item href="/about">About</NavList.Item>
226+
<NavList.Item href="/contact">Contact</NavList.Item>
227+
</NavList>
228+
</PageLayout.Pane>
229+
<PageLayout.Content>
230+
<Placeholder label="Content" height={240} />
231+
</PageLayout.Content>
232+
<PageLayout.Footer>
233+
<Placeholder label="Footer" height={64} />
234+
</PageLayout.Footer>
235+
</PageLayout>
236+
```
237+
205238
### With `aria-label`
206239

207240
Using `aria-label` along with `PageLayout.Header`, `PageLayout.Content`, or `PageLayout.Footer` creates a unique label for that landmark role that can make it easier to navigate between sections of content on a page.
@@ -262,6 +295,20 @@ Each component may be labeled through either `aria-label` or `aria-labelledby` i
262295
- [WCAG, ARIA11 Technique](https://www.w3.org/WAI/WCAG22/Techniques/aria/ARIA11)
263296
- [MDN, Landmark roles](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/landmark_role)
264297

298+
### `PageLayout.Pane`
299+
300+
The `PageLayout.Pane` component does not provide a default landmark role as the
301+
content of this component may have different roles. When using this component,
302+
consider the type of content being rendered inside of `PageLayout.Pane` and if
303+
it requires a landmark role. Common landmark roles include:
304+
305+
- [`aside`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/aside)
306+
- [`navigation`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/aside)
307+
308+
Some components, such as `NavList` may already include a landmark role. In these
309+
situation, these components use an appropriate landmark role and no further
310+
action is needed when using `PageLayout.Pane`.
311+
265312
### Screen readers
266313

267314
Most screen readers provide a mechanism through which you can navigate between landmarks on the page. Typically, this is done through a specific keyboard shortcut or through an option in a rotor.

docs/content/SegmentedControl.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ const Controlled = () => {
3939
render(Controlled)
4040
```
4141

42+
### Small
43+
44+
```jsx live
45+
<SegmentedControl aria-label="File view" size="small">
46+
<SegmentedControl.Button defaultSelected>Preview</SegmentedControl.Button>
47+
<SegmentedControl.Button>Raw</SegmentedControl.Button>
48+
<SegmentedControl.Button>Blame</SegmentedControl.Button>
49+
</SegmentedControl>
50+
```
51+
4252
### With icons and labels
4353

4454
```jsx live
@@ -210,6 +220,7 @@ render(Controlled)
210220
type="boolean"
211221
description="Whether the segment is selected. This is used for controlled SegmentedControls, and needs to be updated using the onChange handler on SegmentedControl."
212222
/>
223+
<PropsTableRow name="selected" type="'small' | 'medium'" description="The size of the buttons" />
213224
<PropsTableRow
214225
name="defaultSelected"
215226
type="boolean"

docs/content/SelectPanel.mdx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,27 @@ const items = [
3737
]
3838

3939
function DemoComponent() {
40-
const [selected, setSelected] = React.useState([items[2], items[4]])
40+
const [selected, setSelected] = React.useState([items[0], items[1]])
4141
const [filter, setFilter] = React.useState('')
4242
const filteredItems = items.filter(item => item.text.toLowerCase().startsWith(filter.toLowerCase()))
4343
const [open, setOpen] = React.useState(false)
4444

4545
return (
4646
<SelectPanel
47-
renderAnchor={({...anchorProps}) => (
48-
<Button trailingIcon={TriangleDownIcon} {...anchorProps}>
49-
Select Labels
47+
renderAnchor={({children, 'aria-labelledby': ariaLabelledBy, ...anchorProps}) => (
48+
<Button trailingIcon={TriangleDownIcon} aria-labelledby={` ${ariaLabelledBy}`} {...anchorProps}>
49+
{children || 'Select Labels'}
5050
</Button>
5151
)}
52-
title="Select Items"
53-
inputLabel="Select Items"
52+
placeholderText="Filter Labels"
5453
open={open}
5554
onOpenChange={setOpen}
5655
items={filteredItems}
5756
selected={selected}
5857
onSelectedChange={setSelected}
5958
onFilterChange={setFilter}
6059
showItemDividers={true}
61-
overlayProps={{width: 'medium', height: 'medium'}}
60+
overlayProps={{width: 'small', height: 'xsmall'}}
6261
/>
6362
)
6463
}

docs/content/TreeView.mdx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ description: A hierarchical list of items where nested items can be expanded and
1919
<TreeView.Item>
2020
Button
2121
<TreeView.SubTree>
22-
<TreeView.LinkItem href="#">Button.tsx</TreeView.LinkItem>
22+
<TreeView.LinkItem href="#" current>
23+
Button.tsx
24+
</TreeView.LinkItem>
2325
<TreeView.LinkItem href="#">Button.test.tsx</TreeView.LinkItem>
2426
</TreeView.SubTree>
2527
</TreeView.Item>
@@ -46,7 +48,7 @@ description: A hierarchical list of items where nested items can be expanded and
4648
src
4749
<TreeView.SubTree>
4850
<TreeView.LinkItem href="#">Avatar.tsx</TreeView.LinkItem>
49-
<TreeView.LinkItem href="#">
51+
<TreeView.LinkItem href="#" current>
5052
Button
5153
<TreeView.SubTree>
5254
<TreeView.LinkItem href="#">Button.tsx</TreeView.LinkItem>
@@ -80,6 +82,13 @@ description: A hierarchical list of items where nested items can be expanded and
8082

8183
<PropsTable>
8284
<PropsTableRow name="children" type="React.ReactNode" required />
85+
<PropsTable
86+
name="current"
87+
type="boolean"
88+
defaultValue="false"
89+
description="Whether the item is the current item. No more than one item should be current at once."
90+
/>
91+
<PropsTableRow name="defaultExpanded" type="boolean" description="Whether the item is expanded by default." />
8392
<PropsTableRow
8493
name="onSelect"
8594
type="(event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void"

0 commit comments

Comments
 (0)