Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resizable support to the <PageLayout> component #2352

Merged
merged 27 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dacf38d
add resizable support to the PageLayout component
japf Sep 20, 2022
5e74d8b
Add changeset file
japf Sep 20, 2022
ffad694
update snapshot
japf Sep 20, 2022
a5291c4
take client left position into account when pane is not left aligned
japf Sep 23, 2022
53ca22a
fix resize behavior when pane is not at start position
japf Sep 23, 2022
d12ba19
fix resize when there are column gaps
japf Sep 23, 2022
8ef210f
use story debug values
japf Sep 23, 2022
9a7b498
decouple the resize handle from the vertical divider
japf Sep 23, 2022
bbff181
update snap file
japf Sep 26, 2022
e808e0c
update snap file
japf Sep 26, 2022
56413f8
rename canResizePane to resizable
japf Sep 28, 2022
64ff267
Merge branch 'main' into japf/resizable-pane
japf Oct 18, 2022
975eef9
update snap files
japf Oct 18, 2022
b66583e
update resizable PageLayout story
japf Oct 18, 2022
7cfccdb
rename paneWidthStorageKey to widthStorageKey
japf Oct 18, 2022
8fe1bcd
refactor(PageLayout): set pane with in CSS Custom Property
joshblack Oct 18, 2022
11ffb7e
docs: add documentation for resizable nad widthStorageKey
joshblack Oct 19, 2022
9784fe8
Merge branch 'main' into japf/resizable-pane
joshblack Oct 19, 2022
ea629b3
Resizable pane refactor (#2481)
colebemis Oct 27, 2022
b282042
Wrap localStorage in try/catch
colebemis Oct 27, 2022
75cd2f3
Merge branch 'main' into japf/resizable-pane
colebemis Oct 27, 2022
6a21e91
Merge branch 'main' into japf/resizable-pane
colebemis Oct 27, 2022
78f0317
Store pane width in px
colebemis Oct 27, 2022
a9f81ac
Merge branch 'main' into japf/resizable-pane
colebemis Oct 31, 2022
d2076f5
Update snapshot
colebemis Oct 31, 2022
925fa0e
Merge branch 'japf/resizable-pane' of github.com:primer/react into ja…
colebemis Oct 31, 2022
6edaf11
Update pagelayout snapshots
colebemis Oct 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/polite-ligers-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Add resizable support to the PageLayout component.
32 changes: 32 additions & 0 deletions docs/content/PageLayout.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,25 @@ Using `aria-labelledby` along with `PageLayout.Header`, `PageLayout.Content`, or
</PageLayout>
```

### With resizable pane

```jsx live
<PageLayout>
<PageLayout.Header>
<Placeholder label="Header" height={64} />
</PageLayout.Header>
<PageLayout.Content>
<Placeholder label="Content" height={240} />
</PageLayout.Content>
<PageLayout.Pane resizable>
<Placeholder label="Pane" height={120} />
</PageLayout.Pane>
<PageLayout.Footer>
<Placeholder label="Footer" height={64} />
</PageLayout.Footer>
</PageLayout>
```

## Accessibility

The `PageLayout` component uses [landmark roles](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/landmark_role) for `PageLayout.Header`, `PageLayout.Content`, and `PageLayout.Footer` in order to make it easier for screen reader users to navigate between sections of the page.
Expand Down Expand Up @@ -365,6 +384,7 @@ On macOS, you can open the VoiceOver rotor by pressing `VO-U`. You can navigate
| 'normal'`}
defaultValue="'normal'"
/>

<PropsTableSxRow />
</PropsTable>

Expand Down Expand Up @@ -512,6 +532,18 @@ On macOS, you can open the VoiceOver rotor by pressing `VO-U`. You can navigate
defaultValue="'medium'"
description="The width of the pane."
/>
<PropsTableRow
name="resizable"
type="boolean"
defaultValue="false"
description="When true, the pane may be resized by the user."
/>
<PropsTableRow
name="widthStorageKey"
type="string"
defaultValue="'paneWidth'"
description="Provide a key used by localStorage to persist the size of the pane on the client."
/>
<PropsTableRow
name="sticky"
type="boolean"
Expand Down
33 changes: 33 additions & 0 deletions docs/content/SplitPageLayout.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,27 @@ If you need a more flexible layout component, consider using the [PageLayout](/P
</Box>
```

### With resizable pane

```jsx live drafts
<Box sx={{height: 320, overflowY: 'auto', border: '1px solid', borderColor: 'border.default'}}>
<SplitPageLayout>
<SplitPageLayout.Header>
<Placeholder label="Header" height={64} />
</SplitPageLayout.Header>
<SplitPageLayout.Pane resizable>
<Placeholder label="Pane" height={120} />
</SplitPageLayout.Pane>
<SplitPageLayout.Content>
<Placeholder label="Content" height={420} />
</SplitPageLayout.Content>
<SplitPageLayout.Footer>
<Placeholder label="Footer" height={64} />
</SplitPageLayout.Footer>
</SplitPageLayout>
</Box>
```

### Without dividers

```jsx live drafts
Expand Down Expand Up @@ -378,6 +399,18 @@ If you need a more flexible layout component, consider using the [PageLayout](/P
defaultValue="'medium'"
description="The width of the pane."
/>
<PropsTableRow
name="resizable"
type="boolean"
defaultValue="false"
description="When true, the pane may be resized by the user."
/>
<PropsTableRow
name="widthStorageKey"
type="string"
defaultValue="'paneWidth'"
description="Provide a key used by localStorage to persist the size of the pane on the client."
/>
<PropsTableRow
name="sticky"
type="boolean"
Expand Down
25 changes: 24 additions & 1 deletion src/PageLayout/PageLayout.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const meta: Meta = {
'Pane.position.wide': 'end',
'Pane.width': 'medium',
'Pane.sticky': false,
'Pane.resizable': false,
'Pane.padding': 'none',
'Pane.divider.regular': 'none',
'Pane.divider.narrow': 'none',
Expand Down Expand Up @@ -242,6 +243,10 @@ const meta: Meta = {
type: 'boolean',
table: {category: 'Pane props'}
},
'Pane.resizable': {
type: 'boolean',
table: {category: 'Pane props'}
},
'Pane.padding': {
type: {
name: 'enum',
Expand Down Expand Up @@ -380,6 +385,7 @@ const Template: Story = args => (
}}
width={args['Pane.width']}
sticky={args['Pane.sticky']}
resizable={args['Pane.resizable']}
padding={args['Pane.padding']}
divider={{
narrow: args['Pane.divider.narrow'],
Expand Down Expand Up @@ -509,7 +515,7 @@ export const StickyPane: Story = args => (
})}
</Box>
</PageLayout.Content>
<PageLayout.Pane position="start" padding="normal" divider="line" sticky={args.sticky}>
<PageLayout.Pane position="start" resizable padding="normal" divider="line" sticky={args.sticky}>
<Box sx={{display: 'grid', gap: 3}}>
{Array.from({length: args.numParagraphsInPane}).map((_, i) => {
const testId = `paragraph${i}`
Expand Down Expand Up @@ -694,4 +700,21 @@ CustomStickyHeader.argTypes = {
}
}

export const ResizablePane: Story = () => (
<PageLayout containerWidth="full">
<PageLayout.Header>
<Placeholder height={64} label="Header" />
</PageLayout.Header>
<PageLayout.Pane resizable position="start">
<Placeholder height={320} label="Pane" />
</PageLayout.Pane>
<PageLayout.Content>
<Placeholder height={640} label="Content" />
</PageLayout.Content>
<PageLayout.Footer>
<Placeholder height={64} label="Footer" />
</PageLayout.Footer>
</PageLayout>
)

export default meta
Loading