-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from Team-INSERT/refactor/scroll-button
refactor : scroll button
- Loading branch information
Showing
3 changed files
with
27 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,43 @@ | ||
"use client"; | ||
|
||
import { ArrowIcon } from "@/assets"; | ||
import { theme } from "@/styles"; | ||
import * as styles from "./style.css"; | ||
|
||
const ScrollButton = () => { | ||
const scrollToTop = () => window.scroll({ top: 0, behavior: "smooth" }); | ||
const scrollToBottom = () => | ||
window.scroll({ | ||
top: document.documentElement.scrollHeight, | ||
behavior: "smooth", | ||
}); | ||
const scrollToTop = () => { | ||
window.scroll({ top: 0, behavior: "smooth" }); | ||
}; | ||
const scrollToBottom = () => { | ||
const { scrollHeight } = document.documentElement; | ||
window.scroll({ top: scrollHeight, behavior: "smooth" }); | ||
}; | ||
|
||
return ( | ||
<div className={styles.scrollButtonWrap}> | ||
<figure className={styles.container}> | ||
<button | ||
className={styles.scrollButton} | ||
onClick={scrollToTop} | ||
aria-label="최상단으로 올라가기" | ||
> | ||
<ArrowIcon direction="up" width={25} height={11} viewBox="0 0 28 18" fill="white" /> | ||
<ArrowIcon direction="up" {...config} /> | ||
</button> | ||
<button | ||
className={styles.scrollButton} | ||
onClick={scrollToBottom} | ||
aria-label="최하단으로 내려가기" | ||
> | ||
<ArrowIcon direction="down" width={25} height={11} viewBox="0 0 28 18" fill="white" /> | ||
<ArrowIcon direction="down" {...config} /> | ||
</button> | ||
</div> | ||
</figure> | ||
); | ||
}; | ||
|
||
const config = { | ||
width: 25, | ||
height: 11, | ||
viewBox: "0 0 28 18", | ||
fill: theme.white, | ||
}; | ||
|
||
export default ScrollButton; |
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