Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat/#482] 반응형 헤더 구현 #486

Merged
merged 25 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3e925c1
chore/#482 : 모바일용 마일 로고 import
moondda Dec 1, 2024
9e8e435
feat/#482 : 로그아웃된 경우 모바일 헤더
moondda Dec 1, 2024
fc72717
feat/#482 : 로고만 있는 헤더(GroupInvite,congrats)
moondda Dec 1, 2024
a9493d5
chore/#482 : 모바일 로고를 기존 로고 사이즈 조절해서 사용하는 것으로 변경
moondda Dec 1, 2024
0a40f6b
feat/#482 : 관리자페이지 헤더
moondda Dec 1, 2024
6e3bcca
feat/#482 : 모바일 버튼용 공통 컴포넌트
moondda Dec 1, 2024
bf05172
chore/#482 : 필요한 공통 버튼 export
moondda Dec 3, 2024
73dddeb
feat/#482 : useOutsideClick 적용
moondda Dec 3, 2024
96eddcf
fix/#482 : 사이드바 mobile 환경에서만 보이게 이동
moondda Dec 3, 2024
460d773
feat/#482 : 로그인/비로그인 사이드헤더 분기
moondda Dec 3, 2024
0640f41
feat/#482 : 헤더버튼 공통css 빼서 정리
moondda Dec 4, 2024
83ecadd
chore/#482 : import build error
moondda Dec 4, 2024
7f80b2b
Feat/#482 : 내 글모임 list
moondda Dec 4, 2024
b45d7f4
feat/#482 : 햄버거바 클릭시 사이드바
moondda Dec 4, 2024
1d31398
Feat/#482 : 초대 링크 복사
moondda Dec 4, 2024
c53f2a8
fix/#482/다은이 코리 반영
moondda Dec 6, 2024
4fb9fc2
chore/#482 : delete stat.html
moondda Dec 6, 2024
5561560
fix/#482 : 서진언니 코리 반영
moondda Dec 6, 2024
e2038e4
chore/#482 : delete stats.html
moondda Dec 6, 2024
ead1158
chore/#482 : stat html gitignore
moondda Dec 6, 2024
804df4a
feat/#482 : groupInvite 에서 받아오는 값 수정
moondda Dec 6, 2024
0d7e7f8
fix/#492: groupLeaderInfoPage 렌더링 1번으로 변경
moondda Dec 17, 2024
6ee146d
fix/#492 : 옵셔널 체이닝
moondda Dec 17, 2024
b36424d
Merge branch 'develop' into feat/#482/responsiveHeader
moondda Dec 17, 2024
ea8f2b3
fix/#482 : 관리자페이지 conflict
moondda Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/assets/svgs/hamburgerIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/svgs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,6 @@ export { default as GroupCuriousIc } from './groupCuriousIcn.svg?react';
export { default as GroupViewIc } from './groupViewIcn.svg?react';

// export { default as LoadingIc } from './loadingSvg.svg?react';

export { default as LinkIc } from './linkIcon.svg?react';
export { default as HamburgerIc } from './hamburgerIcon.svg?react';
3 changes: 3 additions & 0 deletions src/assets/svgs/linkIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
186 changes: 167 additions & 19 deletions src/components/commons/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import styled from '@emotion/styled';
import { useEffect, useState } from 'react';

import Button from './Button';
import LogInOutBtn from './LogInOutBtn';
import { LogInOutBtn } from './HeaderButton';

import { HeaderLogoIc } from '../../assets/svgs';
import { HamburgerIc, HeaderLogoIc, LinkIc } from '../../assets/svgs';
import {
default as useNavigateHome,
default as useNavigateToHome,
Expand All @@ -16,6 +16,14 @@ import MyGroupDropDown from '../../pages/groupFeed/components/MyGroupDropDown';
import { useFetchHeaderGroup } from '../../pages/groupFeed/hooks/queries';
import logout from '../../utils/logout';

import { MOBILE_MEDIA_QUERY } from '../../styles/mediaQuery';
import Responsive from './Responsive/Responsive';
import { MobileUnAuthorizedSidebar, MobileAuthorizedSidebar } from './MyMobileSidebar';

import { useParams } from 'react-router-dom';
import { useFetchInvitationLink } from '../../pages/admin/hooks/queries';
import { copyLink } from '../../utils/copyLink';

interface onClickEditProps {
onClickEditSave: () => void;
}
Expand All @@ -33,25 +41,54 @@ interface OnClickTempExistProps {
export const AuthorizationHeader = () => {
const [moims, setMoims] = useState<Moim[]>([]);
const { navigateToHome } = useNavigateToHome();
const { data } = useFetchHeaderGroup();
const { moimsData } = useFetchHeaderGroup();
const handleLogOut = () => {
logout();
navigateToHome();
};
useEffect(() => {
if (data?.data?.moims) setMoims(data?.data.moims);
}, [data?.data?.moims]);
if (moimsData) setMoims(moimsData);
}, [moimsData]);

const [isSidebarOpen, setIsSidebarOpen] = useState(false);
return (
<HeaderWrapper>
<HeaderLogoIcon onClick={navigateToHome} />
<HeaderLayout>
<MyGroupDropDown groupData={moims ?? []} />
<HeaderBtnContainer>
<CreateGroupBtn groupCount={data?.data.moims.length ?? 0} />
<LogInOutBtn onClick={handleLogOut}>로그아웃</LogInOutBtn>
</HeaderBtnContainer>
</HeaderLayout>
</HeaderWrapper>
<>
<Responsive only="desktop">
<HeaderWrapper>
<HeaderLogoIcon onClick={navigateToHome} />
<HeaderLayout>
<MyGroupDropDown groupData={moims ?? []} />
<HeaderBtnContainer>
<CreateGroupWrapper>
<CreateGroupBtn groupCount={moimsData?.length ?? 0} />
</CreateGroupWrapper>
<LogInOutBtn onClick={handleLogOut}>로그아웃</LogInOutBtn>
</HeaderBtnContainer>
</HeaderLayout>
</HeaderWrapper>
</Responsive>
<Responsive only="mobile">
<HeaderWrapper>
<HeaderLogoIcon onClick={navigateToHome} />
<MobileHeaderButtons>
<HamburgerIcon
onClick={() => {
setIsSidebarOpen(true);
}}
/>
</MobileHeaderButtons>
</HeaderWrapper>
{isSidebarOpen && (
<MobileAuthorizedSidebar
onClose={() => {
setIsSidebarOpen(false);
}}
groupCount={moimsData?.length ?? 0}
groupData={moims ?? []}
/>
)}
</Responsive>
</>
);
};

Expand All @@ -60,11 +97,38 @@ export const UnAuthorizationHeader = () => {
const { navigateToHome } = useNavigateHome();
const { navigateToLogin } = useNavigateLoginWithPath();

const [isSidebarOpen, setIsSidebarOpen] = useState(false);

return (
<HeaderWrapper>
<HeaderLogoIcon onClick={navigateToHome} />
<LogInOutBtn onClick={navigateToLogin}>로그인</LogInOutBtn>
</HeaderWrapper>
<>
<Responsive only="desktop">
<HeaderWrapper>
<HeaderLogoIcon onClick={navigateToHome} />
<LogInWrapper>
<LogInOutBtn onClick={navigateToLogin}>로그인</LogInOutBtn>
</LogInWrapper>
</HeaderWrapper>
</Responsive>
<Responsive only="mobile">
<HeaderWrapper>
<HeaderLogoIcon onClick={navigateToHome} />
<MobileHeaderButtons>
<HamburgerIcon
onClick={() => {
setIsSidebarOpen(true);
}}
/>
</MobileHeaderButtons>
</HeaderWrapper>
{isSidebarOpen && (
<MobileUnAuthorizedSidebar
onClose={() => {
setIsSidebarOpen(false);
}}
/>
)}
</Responsive>
</>
);
};

Expand Down Expand Up @@ -124,6 +188,61 @@ export const DefaultHeader = () => {
);
};

// 관리자 헤더
export const AdminHeader = () => {
const { navigateToHome } = useNavigateHome();
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
const [moims, setMoims] = useState<Moim[]>([]);
const { moimsData } = useFetchHeaderGroup();
const { groupId } = useParams();
const { invitationCode } = useFetchInvitationLink(groupId);

const handleCopyLink = (invitationCode: string) => {
copyLink(import.meta.env.VITE_INVITE_URL + `group/${invitationCode}/groupInvite`);
};

const handleInviteBtnClick = () => {
handleCopyLink(invitationCode?.invitationCode || '');
};

useEffect(() => {
if (moimsData) setMoims(moimsData);
}, [moimsData]);
return (
<>
<Responsive only="desktop">
<AuthorizationHeader />
</Responsive>
<Responsive only="mobile">
<HeaderWrapper>
<HeaderLogoIcon onClick={navigateToHome} />
<MobileHeaderButtons>
<LinkIcon type="button" onClick={handleInviteBtnClick} />
<HamburgerIcon
onClick={() => {
setIsSidebarOpen(true);
}}
/>
</MobileHeaderButtons>
</HeaderWrapper>
{isSidebarOpen && (
<MobileAuthorizedSidebar
onClose={() => {
setIsSidebarOpen(false);
}}
groupCount={moimsData?.length ?? 0}
groupData={moims ?? []}
/>
)}
</Responsive>
</>
);
};

const LogInWrapper = styled.div`
width: 8.1rem;
`;

const HeaderWrapper = styled.div`
position: fixed;
top: 0;
Expand All @@ -138,6 +257,26 @@ const HeaderWrapper = styled.div`

background-color: ${({ theme }) => theme.colors.white};
border-bottom: 1px solid ${({ theme }) => theme.colors.gray30};

@media ${MOBILE_MEDIA_QUERY} {
width: 100%;
height: 5.6rem;
padding: 0 2rem;
}
`;

const LinkIcon = styled(LinkIc)`
cursor: pointer;
`;
const HamburgerIcon = styled(HamburgerIc)`
cursor: pointer;
`;

const MobileHeaderButtons = styled.div`
display: flex;
gap: 1.6rem;
align-items: center;
${({ theme }) => theme.fonts.mSubtitle4};
`;

const HeaderLayout = styled.div`
Expand All @@ -158,4 +297,13 @@ const HeaderLogoIcon = styled(HeaderLogoIc)`
flex-shrink: 0;

cursor: pointer;

@media ${MOBILE_MEDIA_QUERY} {
width: 7rem;
height: 1.68rem;
}
`;

const CreateGroupWrapper = styled.div`
width: 13.6rem;
`;
88 changes: 88 additions & 0 deletions src/components/commons/HeaderButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import styled from '@emotion/styled';
import { css } from '@emotion/react';

const basicCSS = css`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p5)굿이여요

display: flex;
align-items: center;
justify-content: center;
height: 4rem;
padding: 1rem 1.6rem;

white-space: nowrap;

cursor: pointer;
border-radius: 0.8rem;

transition:
transform 0.5s,
background-color 0.5s,
color 0.5s;
`;

// 글모임 만들기 버튼
export const CreateGroupBtnWrapper = styled.div`
${basicCSS};
gap: 0.6rem;
width: 100%;

color: ${({ theme }) => theme.colors.white};

background-color: ${({ theme }) => theme.colors.black};

${({ theme }) => theme.fonts.button3};

:hover {
color: ${({ theme }) => theme.colors.mainViolet};

background-color: ${({ theme }) => theme.colors.white};
box-shadow: 0 4px 8px 0 rgb(0 0 0 / 16%);
transform: scale(0.95);
}

:active {
transform: scale(1.1);
}
`;

// 로그인/로그아웃 버튼
export const LogInOutBtn = styled.button`
${basicCSS};
width: 100%;

color: ${({ theme }) => theme.colors.gray70};

${({ theme }) => theme.fonts.button3};

:hover {
color: ${({ theme }) => theme.colors.mainViolet};

background-color: ${({ theme }) => theme.colors.gray10};
transform: scale(0.95);
}

:active {
transform: scale(1.1);
}
`;

// 내 글 모임 버튼
export const MyGroupBtn = styled.button`
${basicCSS};
width: 9.5rem;

color: ${({ theme }) => theme.colors.gray70};

${({ theme }) => theme.fonts.subtitle6};

:hover {
color: ${({ theme }) => theme.colors.mainViolet};

background-color: ${({ theme }) => theme.colors.gray10};
transform: scale(0.95);
border-radius: 0.8rem;
}

:active {
transform: scale(1.1);
}
`;
44 changes: 0 additions & 44 deletions src/components/commons/LogInOutBtn.tsx

This file was deleted.

Loading
Loading