diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index a0097369..addac5dc 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -11,6 +11,7 @@ interface ButtonProps { fontSize?: number; borderRadius?: number; children?: React.ReactNode; + disabled?: boolean; } const Button = ({ @@ -23,7 +24,8 @@ const Button = ({ textColor, fontSize, borderRadius, - children + children, + disabled }: ButtonProps) => ( + borderRadius={borderRadius} + disabled={disabled}> {label} {children} diff --git a/src/components/PostPreview/PostPreview.style.ts b/src/components/PostPreview/PostPreview.style.ts index 9acf7cb6..1fb8ec5c 100644 --- a/src/components/PostPreview/PostPreview.style.ts +++ b/src/components/PostPreview/PostPreview.style.ts @@ -5,12 +5,12 @@ export const PreviewContainer = styled.div` width: 100%; height: 150px; margin: 0 auto; - padding: 15px 60px; + padding: 15px 26px; background-color: transparent; display: flex; flex-direction: column; align-items: center; - border-bottom: 0.5px solid ${({ theme }) => theme.color.greyLight}; + border-bottom: 0.5px solid ${({ theme }) => theme.color.white800}; &:hover { background-color: ${({ theme }) => theme.color.white900}; } diff --git a/src/pages/postDetail/components/PostComment.style.ts b/src/pages/postDetail/components/PostComment.style.ts index 7b0f7a90..b3d1fd8f 100644 --- a/src/pages/postDetail/components/PostComment.style.ts +++ b/src/pages/postDetail/components/PostComment.style.ts @@ -23,6 +23,7 @@ export const PostCommentUserContainer = styled.div` export const PostCommentContentContainer = styled.div` flex: 1; margin-top: 7px; + line-height: 1.5; `; export const PostCommentDeleteContainer = styled.div` diff --git a/src/pages/postDetail/components/PostCommentHeader.style.ts b/src/pages/postDetail/components/PostCommentHeader.style.ts index c4b56a69..ef706538 100644 --- a/src/pages/postDetail/components/PostCommentHeader.style.ts +++ b/src/pages/postDetail/components/PostCommentHeader.style.ts @@ -24,31 +24,7 @@ export const PostLikeContainer = styled.div` transition: transform 0.2s ease-in-out; margin-top: 1px; &:active { - animation: shake 1s infinite; - } - :hover { transform: scale(1.2); } } - - @keyframes shake { - 0% { - transform: rotate(0) scale(1.2); - } - 10% { - transform: rotate(15deg) scale(1.2); - } - 30% { - transform: rotate(-15deg) scale(1.2); - } - 50% { - transform: rotate(15deg) scale(1.2); - } - 70% { - transform: rotate(0) scale(1.2); - } - 100% { - transform: rotate(0) scale(1.2); - } - } `; diff --git a/src/pages/postDetail/components/PostCommentInput.style.ts b/src/pages/postDetail/components/PostCommentInput.style.ts index 5bd9252f..c04743f5 100644 --- a/src/pages/postDetail/components/PostCommentInput.style.ts +++ b/src/pages/postDetail/components/PostCommentInput.style.ts @@ -1,5 +1,9 @@ import styled from '@emotion/styled'; +interface CommentButtonProps { + buttonDisabled: boolean; +} + export const CommentInputSection = styled.section` ${({ theme }) => theme.style.flexCenter} border-top: 1px solid ${({ theme }) => theme.color.greyLight}; @@ -29,10 +33,20 @@ export const CommentInputContainer = styled.div` padding: 0 10px; `; -export const CommentButtonContainer = styled.div` +export const CommentButtonContainer = styled.div` ${({ theme }) => theme.style.flexCenter} width: 50px; height: 100%; + > button { + transition: all 0.2s ease-in-out; + background-color: ${({ buttonDisabled, theme }) => + buttonDisabled ? theme.color.greyLight : theme.color.purpleDark}; + } + + > button:active { + transform: ${({ buttonDisabled }) => + buttonDisabled ? 'none' : 'scale(0.9)'}; + } `; export const CommentInput = styled.input` diff --git a/src/pages/postDetail/components/PostCommentInput.tsx b/src/pages/postDetail/components/PostCommentInput.tsx index e0d3a7be..e3320742 100644 --- a/src/pages/postDetail/components/PostCommentInput.tsx +++ b/src/pages/postDetail/components/PostCommentInput.tsx @@ -11,6 +11,7 @@ import { } from './PostCommentInput.style'; import { Avatar } from '@components/Avatar'; import { postComment } from '@apis/comment'; +import { useState } from 'react'; import { postNotifications } from '@apis/notice'; interface PostCommentInputProps { @@ -29,6 +30,7 @@ const PostCommentInput = ({ refetch }: PostCommentInputProps) => { const COMMENT_PLACEHOLDER = '댓글을 달아보세요.'; + const [commentValue, setCommentValue] = useState(null); const commentRef = useRef(null); const { mutate, isSuccess } = useMutation(postComment, { @@ -46,14 +48,23 @@ const PostCommentInput = ({ const handleCommentSubmit = (event: React.FormEvent) => { event.preventDefault(); - mutate({ - postId, - comment: commentRef.current.value, - token - }); + mutate( + { + postId, + comment: commentValue, + token + }, + { + onSuccess: () => refetch() + } + ); commentRef.current.value = ''; }; + const handleCommentChange = (event: React.ChangeEvent) => { + setCommentValue(event.target.value); + }; + return ( @@ -68,10 +79,11 @@ const PostCommentInput = ({ - + - + ) : ( - <> + myFollowData !== null && ( - + ) )} diff --git a/src/pages/profile/components/ProfileMain.tsx b/src/pages/profile/components/ProfileMain.tsx index 08cb393c..800454be 100644 --- a/src/pages/profile/components/ProfileMain.tsx +++ b/src/pages/profile/components/ProfileMain.tsx @@ -2,7 +2,6 @@ import { ProfileMainSection } from './ProfileMain.style'; import { ProfileHeader, ProfileTabs, - ProfileTabItem, ProfileCarousel } from '@pages/profile/components'; import { TabItems } from '../utils/createTabItems'; @@ -36,16 +35,7 @@ const ProfileMain = ({ openSidebar={openSidebar} refetch={refetch} /> - - {Object.entries(tabItems).map(([label, tabItem], index) => ( - - ))} - + ` - height: 50px; - border-bottom: 3px solid - ${({ selected, theme }) => - selected ? theme.color.purpleVivid : 'transparent'}; + height: 35px; color: ${({ selected, theme }) => selected ? theme.color.black : theme.color.greyLight}; + font-weight: ${({ selected }) => (selected ? 'bold' : 'normal')}; display: flex; align-items: center; justify-content: center; diff --git a/src/pages/profile/components/ProfileTabItem.tsx b/src/pages/profile/components/ProfileTabItem.tsx index cb77b11a..f9e27781 100644 --- a/src/pages/profile/components/ProfileTabItem.tsx +++ b/src/pages/profile/components/ProfileTabItem.tsx @@ -1,22 +1,23 @@ import { ProfileTabItemContainer } from './ProfileTabItem.style'; -import { useRecoilState } from 'recoil'; -import { selectedTabIndexState } from '../states/selectedTabIndex'; + import { Post, Follow } from '@/types'; interface ProfileTabItemProps { title: string; - index: number; + selected: boolean; data: Post[] | Follow[] | number[]; + onTabItemClick: () => void; } -const ProfileTabItem = ({ title, index }: ProfileTabItemProps) => { - const [selectedTabIndex, setSelectedTabIndex] = useRecoilState( - selectedTabIndexState - ); +const ProfileTabItem = ({ + title, + selected, + onTabItemClick +}: ProfileTabItemProps) => { return ( setSelectedTabIndex(index)}> + selected={selected} + onClick={onTabItemClick}> {title} ); diff --git a/src/pages/profile/components/ProfileTabs.style.ts b/src/pages/profile/components/ProfileTabs.style.ts index a1f82e30..aef967ba 100644 --- a/src/pages/profile/components/ProfileTabs.style.ts +++ b/src/pages/profile/components/ProfileTabs.style.ts @@ -1,6 +1,27 @@ import styled from '@emotion/styled'; +interface ProfileTabsProps { + selectedTabIndex: number; +} + export const ProfileTabsContainer = styled.div` display: flex; margin-top: 10px; + width: 100%; + height: 40px; +`; + +export const ProfileTabItemBottomBarContainer = styled.div` + height: 3px; + width: 25%; + padding: 0 10px; + transition: all 0.2s ease-in-out; + transform: ${({ selectedTabIndex }) => + `translateX(${selectedTabIndex * 100}%)`}; +`; + +export const ProfileTabItemBottomBar = styled.div` + height: 3px; + width: 100%; + background-color: ${({ theme }) => theme.color.purpleVivid}; `; diff --git a/src/pages/profile/components/ProfileTabs.tsx b/src/pages/profile/components/ProfileTabs.tsx index 95407964..031a5668 100644 --- a/src/pages/profile/components/ProfileTabs.tsx +++ b/src/pages/profile/components/ProfileTabs.tsx @@ -1,11 +1,44 @@ -import { ProfileTabsContainer } from './ProfileTabs.style'; +import { TabItems } from '../utils/createTabItems'; +import { + ProfileTabItemBottomBar, + ProfileTabItemBottomBarContainer, + ProfileTabsContainer +} from './ProfileTabs.style'; +import { ProfileTabItem } from '@pages/profile/components'; +import { useRecoilState } from 'recoil'; +import { selectedTabIndexState } from '../states/selectedTabIndex'; interface ProfileTabsProps { - children: React.ReactNode; + tabItems: TabItems; } -const ProfileTabs = ({ children }: ProfileTabsProps) => { - return {children}; +const ProfileTabs = ({ tabItems }: ProfileTabsProps) => { + const [selectedTabIndex, setSelectedTabIndex] = useRecoilState( + selectedTabIndexState + ); + + const handleTabItemClick = (index: number) => { + setSelectedTabIndex(index); + }; + + return ( + <> + + {Object.entries(tabItems).map(([label, tabItem], index) => ( + handleTabItemClick(index)} + key={index} + title={`${tabItem.value} ${label}`} + data={tabItem.data} + selected={index === selectedTabIndex} + /> + ))} + + + + + + ); }; export default ProfileTabs; diff --git a/src/pages/profile/components/SettingSideBar.tsx b/src/pages/profile/components/SettingSideBar.tsx index eb19576e..a77dc3ed 100644 --- a/src/pages/profile/components/SettingSideBar.tsx +++ b/src/pages/profile/components/SettingSideBar.tsx @@ -8,6 +8,7 @@ import { SettingLi } from './SettingSideBar.style'; import useSessionStorage from '@hooks/useSessionStorage'; +import { useNavigate } from 'react-router-dom'; interface SettingSideBarProps { closeSidebar: () => void; @@ -28,9 +29,11 @@ const SettingSideBar = ({ token: '' }); + const navigate = useNavigate(); + const handleLogoutClick = () => { deleteUserValue(); - window.location.reload(); + navigate('/'); }; return ( diff --git a/src/pages/profile/hooks/useCarousel.ts b/src/pages/profile/hooks/useCarousel.ts index 9d3d4d3a..3f0a7db5 100644 --- a/src/pages/profile/hooks/useCarousel.ts +++ b/src/pages/profile/hooks/useCarousel.ts @@ -31,10 +31,7 @@ export const useCarousel = ( } else { distanceX = event.pageX - startX; } - if (Math.abs(distanceX) < MIN_DISTANCE) { - carousel.scrollLeft = - carousel.clientWidth * selectedTabIndex - distanceX; - } + carousel.scrollLeft = carousel.clientWidth * selectedTabIndex - distanceX; }; const handlePointerUp = () => { @@ -51,7 +48,6 @@ export const useCarousel = ( ) { setSelectedTabIndex(selectedTabIndex + 1); } - carousel.style.marginLeft = `0px`; carousel.removeEventListener('mousemove', handlePointerMove); carousel.removeEventListener('touchmove', handlePointerMove); }; diff --git a/src/utils/GetMyFollowData.ts b/src/utils/GetMyFollowData.ts index 8b874226..d2e54e04 100644 --- a/src/utils/GetMyFollowData.ts +++ b/src/utils/GetMyFollowData.ts @@ -5,7 +5,7 @@ const GetMyFollowData = ( currentUserId: string ): Follow => { if (followers && followers.length > 0 && currentUserId) { - return followers.find((follow) => follow._id === currentUserId); + return followers.find((follow) => follow.follower === currentUserId); } };