-
Notifications
You must be signed in to change notification settings - Fork 584
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 stickyTop prop to PageLayout.Pane #2232
Conversation
🦋 Changeset detectedLatest commit: 0adf6b0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
a59d85a
to
515992a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work, @broccolinisoup! 💖 Thank you for taking this on.
Left a couple of minor comments but I don't see any blockers. Feel free to merge this when you feel ready 🚢
docs/content/PageLayout.mdx
Outdated
name="stickyTop" | ||
type="number | string" | ||
defaultValue="0" | ||
description="Use stickyTop to push the sticky pane down to make room for a sticky header if necessary" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add into the description that if it is number, we expect px and if it is string value with units?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! 800b3ec let me know if you have a better wording :)
calculatedHeight = `calc(100vh - ${Math.max(topOffset, stickyTopHeight) + bottomOffset - overflowScroll}px)` | ||
const stickyTopWithUnits = typeof stickyTop === 'number' ? `${stickyTop}px` : stickyTop | ||
|
||
calculatedHeight = `calc(100vh - (max(${topOffset}px, ${stickyTopWithUnits}) + ${bottomOffset}px - ${overflowScroll}px))` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love that! 🙌🏼
> | ||
<Heading>Sticky top content</Heading> | ||
Custom sticky header |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this is very explanatory. Thanks for updating it!
Co-authored-by: Cole Bemis <[email protected]>
Co-authored-by: Cole Bemis <[email protected]>
name="stickyTop" | ||
type="number | string" | ||
defaultValue="0" | ||
description="Use stickyTop to push the sticky pane down to make room for a sticky header if necessary. Use the type `string` to specify the height with a unit i.e. 5rem; otherwise the type `number` will be taken as px." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you copy this prop documentation and With custom sticky header
example into the SplitPageLayout.mdx
page as well?
Hi! Sorry, late to the party, how do you feel about calling the prop 1. <PageLayout.Pane position="start" sticky offset={64}>
// because you use it with the sticky prop, ↑ i like this one the most
2. <PageLayout.Pane position="start" sticky offsetTop={64}>
// this is a close second for explicit direction
3. <PageLayout.Pane position="start" sticky offsetHeader={64}>
// i lowkey like this one because it tells you offset from what
4. <PageLayout.Pane position="start" sticky stickyOffset={64}>
// stick-offset is bit redundant when used with sticky, but more clear
5. <PageLayout.Pane position="start" sticky stickyOffsetTop={64}>
// this is the most clear we can be 😅 also the most verbose |
I like the word "offset" 👍 I think |
I like
I am just now thinking we weren't super explicit about stickyTop needs sticky prop to work on the docs. Maybe we should mention that they need to be used together? |
Happy with
It's not super clear, we can make it more explicit with
- <PageLayout.Pane position="start" offsetTop={64} sticky>
+ <PageLayout.Pane position="start" sticky offsetTop={64}>
Yes good point! We should add that to the prop description of offsetTop |
Good call to improve the docs! I created a PR to get the feelings of the new name with the improved docs. Let me know what you think 😊 |
Closes this issue which lives in the internal repo.
Motivation
This PR adds a prop called stickyTop to the PageLayout.Pane to be able to push the pane down and make space for the top sticky element (which lives outside of the PageLayout component) and sticks the pane to a position where the top element ends.
Screen record
StickyTop.on.PageLayout.Pane.1.mp4
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.