-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: Add a Back to top float button to the proposal page #3958 * fix: Update remarks * fix: use styled-components pull-out style --------- Co-authored-by: yuankang <[email protected]>
- Loading branch information
1 parent
3bbe969
commit 6c34715
Showing
6 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions
43
packages/next-common/components/layout/DetailLayout/ScrollToTopButton.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { animateScroll as scroll } from 'react-scroll'; | ||
import SystemTop from "next-common/assets/imgs/icons/systemTop.svg"; | ||
import styled from "styled-components"; | ||
|
||
const ScrollToTopDiv = styled.div` | ||
display:flex; | ||
justify-content:center; | ||
align-items:center; | ||
position: fixed; | ||
cursor:pointer; | ||
bottom: 96px; | ||
right: 24px; | ||
z-index:1000; | ||
border-radius: 8px; | ||
border: 1px solid var(--color-neutral400, #E0E4EB); | ||
background: var(--color-neutral100, #FFF); | ||
box-shadow: 0px 6px 7px 0px rgba(30, 33, 52, 0.02), 0px 1.34px 1.564px 0px rgba(30, 33, 52, 0.01), 0px 0.399px 0.466px 0px rgba(30, 33, 52, 0.01) | ||
`; | ||
|
||
export default function ScrollToTopButton({scrollYShowPX = 800}){ | ||
const [showButton, setShowButton] = useState(false); | ||
|
||
useEffect(() => { | ||
const handleScroll = () => { | ||
setShowButton(window.scrollY > scrollYShowPX); | ||
}; | ||
window.addEventListener('scroll', handleScroll); | ||
return () => window.removeEventListener('scroll', handleScroll); | ||
}, []); | ||
|
||
const handleClick = () => { | ||
scroll.scrollToTop(); | ||
}; | ||
|
||
return ( | ||
showButton && ( | ||
<ScrollToTopDiv className={'w-10 h-10'} onClick={handleClick}> | ||
<SystemTop /> | ||
</ScrollToTopDiv> | ||
) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters