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

PageLayout.Pane: Add sticky prop #2212

Merged
merged 28 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2bd4a0f
Add storybook story to test sticky behavior
colebemis Aug 2, 2022
68a8934
First draft of sticky implementation
colebemis Aug 2, 2022
e1f1db0
Update stories
colebemis Aug 4, 2022
ab32ec4
Fix overflow
colebemis Aug 4, 2022
0bab542
wip
colebemis Aug 4, 2022
7220176
Create useStickyPaneHeight hook
colebemis Aug 5, 2022
aa74e26
Update comments
colebemis Aug 5, 2022
62c86b5
Add TODO comments
colebemis Aug 5, 2022
08f8df7
Avoid recalculating sticky pane height when sticky is disabled
colebemis Aug 8, 2022
ad0519f
Calculate intital height
colebemis Aug 8, 2022
be186f9
Handle elastic scroll in safari
colebemis Aug 8, 2022
a9fa86d
Clean up max() functions
colebemis Aug 8, 2022
60cc14d
Merge branch 'main' into pagelayout-sticky-prop
colebemis Aug 8, 2022
3e6a769
Add docs
colebemis Aug 8, 2022
c68f1eb
Create serious-pots-confess.md
colebemis Aug 8, 2022
c723deb
Merge branch 'main' into pagelayout-sticky-prop
colebemis Aug 8, 2022
d7180a8
Update serious-pots-confess.md
colebemis Aug 8, 2022
7caa413
Merge branch 'pagelayout-sticky-prop' of github.com:primer/react into…
colebemis Aug 9, 2022
c7e7149
Update tests
colebemis Aug 9, 2022
f81704f
Import React in tests
colebemis Aug 9, 2022
1dcea16
Remove position: relative from content region
colebemis Aug 10, 2022
ebb7ed0
Merge branch 'main' into pagelayout-sticky-prop
colebemis Aug 11, 2022
b07f807
Update snapshots
colebemis Aug 11, 2022
52e174f
Handle nested scroll containers
colebemis Aug 15, 2022
55fcd74
Update sticky prop docs
colebemis Aug 16, 2022
867c9bd
Update sticky pane docs example
colebemis Aug 16, 2022
41fed71
Merge branch 'main' into pagelayout-sticky-prop
colebemis Aug 16, 2022
295a1ae
Update src/PageLayout/PageLayout.stories.tsx
colebemis Aug 16, 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
13 changes: 13 additions & 0 deletions .changeset/serious-pots-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@primer/react": minor
---

Add a `sticky` prop to the `PageLayout.Pane` component that provides a convenient way for you to make side panes sticky:

```diff
<PageLayout>
- <PageLayout.Pane>...</PageLayout.Pane>
+ <PageLayout.Pane sticky>...</PageLayout.Pane>
<PageLayout.Content>...</PageLayout.Content>
</PageLayout>
```
27 changes: 27 additions & 0 deletions docs/content/PageLayout.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,27 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
</PageLayout>
```

### With a sticky pane

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

## Props

### PageLayout
Expand Down Expand Up @@ -310,6 +331,12 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
defaultValue="'medium'"
description="The width of the pane."
/>
<PropsTableRow
name="sticky"
type="boolean"
defaultValue="false"
description="Whether the pane should stick to the top of the screen while the content scrolls."
/>
<PropsTableRow
name="padding"
type={`| 'none'
Expand Down
1 change: 1 addition & 0 deletions docs/content/SplitPageLayout.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ description: Provides structure for a split page layout, including independent s
defaultValue="'medium'"
description="The width of the pane."
/>
<PropsTableRow name="sticky" type="boolean" defaultValue="true" description="Whether the pane is sticky." />
<PropsTableRow
name="divider"
type={`ResponsiveValue<
Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"focus-visible": "^5.2.0",
"fzy.js": "0.4.1",
"history": "^5.0.0",
"react-intersection-observer": "9.4.0",
"styled-system": "^5.1.5"
},
"devDependencies": {
Expand Down
Loading