-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a409ab4
commit b632962
Showing
4 changed files
with
136 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.
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,13 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import MoveTopButton from './MoveTopButton'; | ||
|
||
const meta: Meta<typeof MoveTopButton> = { | ||
title: 'shared/UI/MoveTopButton', | ||
component: MoveTopButton, | ||
tags: ['autodocs'] | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof MoveTopButton>; | ||
|
||
export const Default: Story = {}; |
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,97 @@ | ||
import styled, { keyframes } from 'styled-components'; | ||
|
||
const moveAnimation = keyframes` | ||
0%, 100% { | ||
// transform: translateY(0); | ||
background-color: #ff480e; | ||
} | ||
50% { | ||
// transform: translateY(-5px); | ||
background-color: #ff480ebb; | ||
} | ||
`; | ||
|
||
const moveImgAnimation = keyframes` | ||
0%, 100% { | ||
transform: translateY(0) rotate(-45deg); | ||
} | ||
50% { | ||
transform: translateY(-5px) rotate(-45deg); | ||
} | ||
`; | ||
|
||
export const StyledButton = styled.button` | ||
position: fixed; | ||
bottom: 20px; | ||
right: 20px; | ||
width: 91px; | ||
height: 91px; | ||
border: none; | ||
border-radius: 100px; | ||
background-color: #ff480e; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
gap: -20px; | ||
cursor: pointer; | ||
z-index: 1000; | ||
&::before { | ||
content: ''; | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
width: 85%; | ||
height: 85%; | ||
border: 1px solid #ffffff; | ||
border-radius: 100px; | ||
transform: translate(-50%, -50%); | ||
z-index: -1; | ||
} | ||
&::after { | ||
content: ''; | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
width: 70%; | ||
height: 70%; | ||
border: 1px solid #ffffff4c; | ||
border-radius: 100px; | ||
transform: translate(-50%, -50%); | ||
z-index: -1; | ||
} | ||
&:hover { | ||
animation: ${moveAnimation} 1s ease-in-out infinite; | ||
} | ||
// &:hover text { | ||
// animation: ${moveAnimation} 1s ease-in-out infinite; | ||
// } | ||
&:hover img { | ||
animation: ${moveImgAnimation} 1s ease-in-out infinite; | ||
} | ||
`; | ||
|
||
export const StyledText = styled.span` | ||
color: #ffffff; | ||
font-weight: bold; | ||
font-size: 14px; | ||
font-family: 'Pretendard', sans-serif; | ||
`; | ||
|
||
export const Container = styled.div` | ||
width: 100%; | ||
height: 1200px; | ||
`; | ||
|
||
export const StyledImg = styled.img` | ||
height: 25px; | ||
width: 25px; | ||
transform: rotate(-45deg); | ||
display: inline-block; | ||
cursor: pointer; | ||
`; |
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,25 @@ | ||
import React from 'react'; | ||
import { | ||
StyledButton, | ||
Container, | ||
StyledImg, | ||
StyledText | ||
} from './MoveTopButton.styled'; | ||
|
||
const MoveTopButton = () => { | ||
/** ํ๋ฉด ์ต์๋จ์ผ๋ก ์ด๋ํ๋ ์ด๋ฒคํธ */ | ||
const handleClick = () => { | ||
window.scrollTo({ top: 0, behavior: 'smooth' }); | ||
}; | ||
|
||
return ( | ||
<Container> | ||
<StyledButton onClick={handleClick}> | ||
<StyledImg src="/arrow_up.svg" /> | ||
<StyledText>Top</StyledText> | ||
</StyledButton> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default MoveTopButton; |