-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
adds back to top button [Fixes #12194] #12906
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { memo } from "react" | ||
import { IoChevronUpSharp } from "react-icons/io5" | ||
|
||
import { Button } from "./Buttons" | ||
|
||
const scrollToTop = () => { | ||
window.scrollTo({ top: 0, behavior: "smooth" }) | ||
} | ||
|
||
export const GoToTopButton = memo(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alex1092 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep no worries, there had been design changes so I need to refactor this again |
||
return ( | ||
<Button | ||
leftIcon={<IoChevronUpSharp />} | ||
variant="outline" | ||
isSecondary | ||
onClick={scrollToTop} | ||
> | ||
Go to top | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll want to set this up for translation as well. I'm happy to do this before this gets merged when ready. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh brilliant |
||
</Button> | ||
) | ||
}) | ||
|
||
GoToTopButton.displayName = "GoToTopButton" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
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.
@alex1092 Note that we have a
scrollIntoView.ts
insidesrc/lib/utls
which we can use here instead of making a new "scrollToTop" component. Just pass__next
as thetoId
... that will target the root Next.js div and scroll the user to the top.ie: