@@ -2,11 +2,10 @@ import { useRef, useState, useEffect } from 'react';
22import useAxios from '../../hooks/useAxios' ;
33import styled from 'styled-components' ;
44
5- function SectionTitle ( { fishSizeAll, isMyPage, logout, user, saveUser } ) {
5+ function SectionTitle ( { fishSizeAll, isMyPage, logout, user, saveUser, isLoggedUser } ) {
66 const [ isEditMode , setIsEditMode ] = useState ( false ) ;
77 const [ userName , setUserName ] = useState ( user ?. nickname ) ;
88 const [ newUserName , setNewUserName ] = useState ( ) ;
9- const [ randomComment , setRandomCommnet ] = useState ( ) ;
109 const copyUrlRef = useRef ( ) ;
1110 const { requestApi } = useAxios ( ) ;
1211
@@ -58,38 +57,6 @@ function SectionTitle({ fishSizeAll, isMyPage, logout, user, saveUser }) {
5857 alert ( '복사되었습니다.' ) ;
5958 } ;
6059
61- const twoCatsRandomComment = [
62- '어서오라냥~' ,
63- '날마다 오는 붕어빵이 아니다냥' ,
64- '맛있는 붕어빵이 있다냥!' ,
65- '친구랑 나눠먹어도 맛있다냥' ,
66- '붕어빵 사가라냥!' ,
67- '붕어빵 만들지 않겠냥?' ,
68- '재료도 고를 수 있다냥!' ,
69- '천원도 카드 된다냥!' ,
70- ] ;
71-
72- let timeout ;
73- const refreshComment = ( ) => {
74- let currentComment = (
75- < CatsComment >
76- { twoCatsRandomComment [ Math . floor ( Math . random ( ) * twoCatsRandomComment . length ) ] }
77- </ CatsComment >
78- ) ;
79- setRandomCommnet ( currentComment ) ;
80-
81- // timeout = setTimeout(() => {
82- // clearTimeout(timeout);
83-
84- // refreshComment();
85- // }, 5000);
86- } ;
87-
88- useEffect ( ( ) => {
89- refreshComment ( ) ;
90- // return () => clearTimeout(timeout);
91- } , [ ] ) ;
92-
9360 return (
9461 < SectionTitleWrap >
9562 { /* 붕어빵이 n개 있습니다냥 */ }
@@ -111,10 +78,14 @@ function SectionTitle({ fishSizeAll, isMyPage, logout, user, saveUser }) {
11178 붕어빵이 < span className = "sizeAll" > { fishSizeAll } </ span > 개 있다냥
11279 </ NickNameChangeForm >
11380 ) : (
114- < TwoCatsCommentBubble > { randomComment } </ TwoCatsCommentBubble >
81+ < OtherUserWrap >
82+ < span className = "otherUserName" > 비 로그인 유저의</ span >
83+ < br />
84+ 붕어빵이 < span className = "sizeAll" > 3</ span > 개 있다냥
85+ </ OtherUserWrap >
11586 ) }
11687
117- < div className = "right" >
88+ < RightButtonsWrap >
11889 { /* url 복사 */ }
11990 < CopyUrlWrap >
12091 < input id = "copyUrl" type = "text" ref = { copyUrlRef } defaultValue = { window . location . href } />
@@ -123,39 +94,42 @@ function SectionTitle({ fishSizeAll, isMyPage, logout, user, saveUser }) {
12394 alt = "링크 복사 버튼"
12495 onClick = { copyUrl }
12596 />
126-
127- < img
128- src = "./assets/images/member/logout_button.png"
129- alt = "로그아웃 버튼"
130- onClick = { logout }
131- />
13297 </ CopyUrlWrap >
133- </ div >
98+ { isLoggedUser && isMyPage && (
99+ < LogoutWrap >
100+ < img
101+ src = "./assets/images/member/logout_button.png"
102+ alt = "로그아웃 버튼"
103+ onClick = { logout }
104+ />
105+ </ LogoutWrap >
106+ ) }
107+ </ RightButtonsWrap >
134108 </ SectionTitleWrap >
135109 ) ;
136110}
137111
138112export default SectionTitle ;
139113
140114const SectionTitleWrap = styled . section `
141- min-height: 20%;
142115 display: flex;
143116 position: relative;
117+ min-height: 20%;
118+ ` ;
144119
145- .right {
146- flex: 1;
147- }
120+ const RightButtonsWrap = styled . div `
121+ flex: 1;
148122` ;
149123
150124const NickNameChangeForm = styled . form `
125+ position: relative;
151126 flex: 1;
152127 font-family: 'EF_jejudoldam';
153128 font-size: 30px;
154129 line-height: 1.3;
155130 word-break: keep-all;
156- position: relative;
157- z-index: 99;
158131 text-shadow: -1px 0 #e3edf2, 0 1px #e3edf2, 1px 0 #e3edf2, 0 -1px #e3edf2;
132+ z-index: 99;
159133
160134 @media (max-width: 500px) {
161135 font-size: 28px;
@@ -168,13 +142,13 @@ const NickNameChangeForm = styled.form`
168142 }
169143
170144 .username {
171- width: 100%;
172145 display: block;
173- padding: 5px 0;
174- white-space: nowrap;
175146 position: absolute;
176147 top: -7px;
177148 left: 50%;
149+ width: 100%;
150+ padding: 5px 0;
151+ white-space: nowrap;
178152 transform: translateX(-50%);
179153 }
180154
@@ -219,7 +193,7 @@ const CopyUrlWrap = styled.div`
219193 width: 66px;
220194 height: 36px;
221195 margin-left: auto;
222- position: relative ;
196+ position: absolute ;
223197 right: 0;
224198 top: 0;
225199 cursor: pointer;
@@ -268,57 +242,77 @@ const CopyUrlWrap = styled.div`
268242 }
269243` ;
270244
271- const TwoCatsCommentBubble = styled . div `
272- width: 100%;
273- height: 80px;
245+ //로그아웃 버튼
246+ const LogoutWrap = styled . div `
247+ width: 66px;
248+ height: 36px;
249+ margin-left: auto;
274250 position: absolute;
275- bottom: 20px;
276- display: flex;
277- align-items: center;
278- justify-content: center;
279- background-color: #d4dde2;
280- border-radius: 10px;
281- overflow: hidden;
282- animation: up 0.5s 0.2s forwards;
283- opacity: 0;
251+ right: 0;
252+ top: 50px;
253+ cursor: pointer;
254+ transition: all 0.3s;
284255
285- @keyframes up {
286- 0% {
287- transform: translateY(10px);
288- opacity: 0;
289- }
290- 100% {
291- transform: translateY(0);
292- opacity: 1;
293- }
256+ @media (max-width: 500px) {
257+ width: 60px;
258+ }
259+ @media (max-width: 400px) {
260+ width: 55px;
261+ }
262+ @media (max-width: 300px) {
263+ width: 50px;
264+ }
265+
266+ &:hover {
267+ transform: translateY(-3px) rotate(0);
294268 }
295269` ;
296270
297- const CatsComment = styled . div `
298- width: 100%;
299- object-fit: cover;
271+ const OtherUserWrap = styled . div `
272+ flex: 1;
273+ font-family: 'EF_jejudoldam';
274+ font-size: 30px;
275+ line-height: 1.3;
276+ word-break: keep-all;
277+ position: relative;
278+ z-index: 99;
279+ text-shadow: -1px 0 #e3edf2, 0 1px #e3edf2, 1px 0 #e3edf2, 0 -1px #e3edf2;
300280
301- font-size: 18px;
302- line-height: 28px;
303- font-weight: 700;
281+ @media (max-width: 500px) {
282+ font-size: 28px;
283+ }
284+ @media (max-width: 400px) {
285+ font-size: 26px;
286+ }
287+ @media (max-width: 300px) {
288+ font-size: 18px;
289+ }
304290
305- position: absolute;
306- top: 50%;
307- left: 50%;
308- transform: translate(-50%, -50%);
291+ .otherUserName {
292+ width: 100%;
293+ display: block;
294+ padding: 5px 0;
295+ white-space: nowrap;
296+ position: absolute;
297+ top: -7px;
298+ left: 50%;
299+ transform: translateX(-50%);
300+ }
309301
310- font-family: 'kotra';
311- font-size: 20px ;
312- text-align: center;
302+ .sizeAll {
303+ color: #ed9a00 ;
304+ }
313305
314- animation: fadeIn 0.5s forwards;
306+ animation: up 0.5s 0.2s forwards;
315307 opacity: 0;
316308
317- @keyframes fadeIn {
309+ @keyframes up {
318310 0% {
311+ transform: translateY(10px);
319312 opacity: 0;
320313 }
321314 100% {
315+ transform: translateY(0);
322316 opacity: 1;
323317 }
324318 }
0 commit comments