From b63296266ba41d87f0e0ec7714325bc420f9af8b Mon Sep 17 00:00:00 2001
From: kangminguu <131148077+kangminguu@users.noreply.github.com>
Date: Wed, 30 Oct 2024 08:53:44 +0900
Subject: [PATCH] =?UTF-8?q?feat=20:=20moveTopButton=20=EA=B5=AC=ED=98=84?=
=?UTF-8?q?=20(#62)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/arrow_up.svg | 1 +
.../MoveTopButton/MoveTopButton.stories.tsx | 13 +++
.../ui/MoveTopButton/MoveTopButton.styled.ts | 97 +++++++++++++++++++
src/shared/ui/MoveTopButton/MoveTopButton.tsx | 25 +++++
4 files changed, 136 insertions(+)
create mode 100644 public/arrow_up.svg
create mode 100644 src/shared/ui/MoveTopButton/MoveTopButton.stories.tsx
create mode 100644 src/shared/ui/MoveTopButton/MoveTopButton.styled.ts
create mode 100644 src/shared/ui/MoveTopButton/MoveTopButton.tsx
diff --git a/public/arrow_up.svg b/public/arrow_up.svg
new file mode 100644
index 0000000..21f76e1
--- /dev/null
+++ b/public/arrow_up.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/shared/ui/MoveTopButton/MoveTopButton.stories.tsx b/src/shared/ui/MoveTopButton/MoveTopButton.stories.tsx
new file mode 100644
index 0000000..bb25c31
--- /dev/null
+++ b/src/shared/ui/MoveTopButton/MoveTopButton.stories.tsx
@@ -0,0 +1,13 @@
+import type { Meta, StoryObj } from '@storybook/react';
+import MoveTopButton from './MoveTopButton';
+
+const meta: Meta = {
+ title: 'shared/UI/MoveTopButton',
+ component: MoveTopButton,
+ tags: ['autodocs']
+};
+
+export default meta;
+type Story = StoryObj;
+
+export const Default: Story = {};
diff --git a/src/shared/ui/MoveTopButton/MoveTopButton.styled.ts b/src/shared/ui/MoveTopButton/MoveTopButton.styled.ts
new file mode 100644
index 0000000..246b47f
--- /dev/null
+++ b/src/shared/ui/MoveTopButton/MoveTopButton.styled.ts
@@ -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;
+`;
diff --git a/src/shared/ui/MoveTopButton/MoveTopButton.tsx b/src/shared/ui/MoveTopButton/MoveTopButton.tsx
new file mode 100644
index 0000000..36236e2
--- /dev/null
+++ b/src/shared/ui/MoveTopButton/MoveTopButton.tsx
@@ -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 (
+
+
+
+ Top
+
+
+ );
+};
+
+export default MoveTopButton;