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/#91] 캐러셀 라우팅 및 자잘한 변경 #101

Merged
merged 28 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
62b9744
merge develop
namdaeun Jan 14, 2024
43954d9
fix: import 경로 수정
namdaeun Jan 14, 2024
1761c62
feat: 받아온 이미지 border-radius 값 부여
namdaeun Jan 14, 2024
d0d6dee
fix: 여러 줄일 때 말줄임표 처리
namdaeun Jan 14, 2024
3e35a80
feat: 글모임 순서 보장
namdaeun Jan 14, 2024
e731777
fix: 이미지 fit 속성 변경
namdaeun Jan 14, 2024
29fd7f4
fix: svg 교체
namdaeun Jan 14, 2024
d34c166
fix: 변수명 변경
namdaeun Jan 14, 2024
a37a000
chore: 불필요한 콘솔 제거 및 임포트 경로 수정
namdaeun Jan 14, 2024
0be8cab
feat: 작미 소개 더미에서 불러오기
namdaeun Jan 14, 2024
ea97849
chore: 임포트 수정
namdaeun Jan 14, 2024
b8ec9de
feat: 버튼에 groupId 넘겨주기
namdaeun Jan 14, 2024
15d198b
feat: groupId 넘겨서 navigate
namdaeun Jan 14, 2024
e5d5872
feat: 인터페이스 새롭게 지정
namdaeun Jan 14, 2024
1d89427
fix: 버튼 누르면 groupId로 이동하도록
namdaeun Jan 14, 2024
12f3d1c
feat: api 연결 코드 타입 지정
namdaeun Jan 14, 2024
0b96ca1
fix: 인터페이스 타입 파일 제거
namdaeun Jan 14, 2024
edb50a9
chore: 임포트 수정
namdaeun Jan 14, 2024
53cf64b
fix: 인터페이스 타입 수정
namdaeun Jan 14, 2024
17dc53a
merge develop
namdaeun Jan 14, 2024
385b911
fix: 인터페이스 타입 에러 해결
namdaeun Jan 14, 2024
cde5d7e
chore: 인터페이스 이름 변경
namdaeun Jan 14, 2024
0613407
fix: 오늘의 글감 width 조정
namdaeun Jan 14, 2024
537c111
feat: 로그인과 로그아웃 라우팅
namdaeun Jan 15, 2024
5254d16
chore: 경로 수정
namdaeun Jan 15, 2024
3012f62
fix: 인터페이스명 변경
namdaeun Jan 15, 2024
df2ee88
fix: 로그아웃 함수 호출 수정
namdaeun Jan 15, 2024
b2f29ca
fix: 헤더 네이밍 변경
namdaeun Jan 16, 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
16 changes: 8 additions & 8 deletions src/assets/svgs/mainManualLook.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 18 additions & 2 deletions src/pages/main/apis/getGroupContent.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import { moimPostTypes } from '../components/Carousel';

import { client } from '../../../utils/apis/axios';

interface groupPropTypes {
moimId: number;
moimName: string;
moimPosts: moimPostTypes[];
}

interface getGroupContentResponseTypes {
status: number;
message: string;
data: {
moim: groupPropTypes[];
};
}

export const getGroupContent = async () => {
try {
const { data } = await client.get('/api/moim/best');
return { data: data.data };
const { data } = await client.get<getGroupContentResponseTypes>('/api/moim/best');
return data.data.moim;
} catch (error) {
console.error(error);
}
Expand Down
62 changes: 38 additions & 24 deletions src/pages/main/components/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@ import GroupNameButton from './GroupNameButton';

import Spacing from './../../../components/commons/Spacing';
import { getGroupContent } from './../apis/getGroupContent';
import { MoimPropTypes } from './../types/moimPost';

const Carousel = () => {
const [groupData, setGroupData] = useState<MoimPropTypes[]>([]);
interface groupPropTypes {
moimId: number;
moimName: string;
moimPosts: groupPostTypes[];
}

export interface groupPostTypes {
topicName: string;
imageUrl: string;
postTitle: string;
postContent: string;
}

const Carousel = () => {
const [groupData, setGroupData] = useState<groupPropTypes[]>();
const settings = {
arrow: false,
dots: false,
Expand All @@ -29,7 +40,7 @@ const Carousel = () => {
const getData = async () => {
try {
const response = await getGroupContent();
setGroupData(response?.data?.moim);
setGroupData(response);
} catch (error) {
console.log(error);
}
Expand All @@ -42,26 +53,29 @@ const Carousel = () => {
<Spacing marginBottom="3.6" />
{groupData && (
<section>
{groupData.map((moim) => (
<CarouselWithButtonLayout key={moim.moimId}>
<GroupNameButton buttonName={moim.moimName} />
<Spacing marginBottom="1.6" />
<CarouselContainer>
<CarouselBox {...settings} className="main">
{moim.moimPosts.map((post, index) => (
<GroupContent
key={index}
topicName={post.topicName}
imageUrl={post.imageUrl}
postTitle={post.postTitle}
postContent={post.postContent}
isLast={index === moim.moimPosts.length - 1}
/>
))}
</CarouselBox>
</CarouselContainer>
</CarouselWithButtonLayout>
))}
{groupData
.sort((previous, current) => previous.moimId - current.moimId)
.map((moim) => (
<CarouselWithButtonLayout key={moim.moimId}>
<GroupNameButton groupName={moim.moimName} groupId={moim.moimId} />
<Spacing marginBottom="1.6" />
<CarouselContainer>
<CarouselBox {...settings} className="main">
{moim.moimPosts.map((post, index) => (
<GroupContent
key={index}
topicName={post.topicName}
imageUrl={post.imageUrl}
postTitle={post.postTitle}
postContent={post.postContent}
groupId={moim.moimId}
isLast={index === moim.moimPosts.length - 1}
/>
))}
</CarouselBox>
</CarouselContainer>
</CarouselWithButtonLayout>
))}
</section>
)}
</CarouselWrapper>
Expand Down
10 changes: 7 additions & 3 deletions src/pages/main/components/CuriousGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import styled from '@emotion/styled';
import { useNavigate } from 'react-router-dom';

import { groupContentPropTypes } from './GroupContent';

import { MainGroupRoutingBtn as MainGroupRoutingBtnIcon } from '../../../assets/svgs';
import Spacing from '../../../components/commons/Spacing';

const Curious = () => {
const CuriousGroup = ({ groupId }: groupContentPropTypes) => {
const navigate = useNavigate();
const handleOnClick = () => {
alert('Button Clicked!');
navigate(`/group/${groupId}`);
};

return (
Expand All @@ -22,7 +26,7 @@ const Curious = () => {
);
};

export default Curious;
export default CuriousGroup;

const CuriousContentContainer = styled.section`
display: flex;
Expand Down
4 changes: 2 additions & 2 deletions src/pages/main/components/FaqDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';

import styled from '@emotion/styled';

import React, { useState } from 'react';

import { MainToggleArrowOpenedIc, MainTogglearrowClosedIc } from './../../../assets/svgs';
import { faqDataPropTypes } from './../constants/faqData';

Expand Down
36 changes: 31 additions & 5 deletions src/pages/main/components/GroupContent.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import styled from '@emotion/styled';

import CuriousGroup from './CuriousGroup';

import Spacing from './.././../../components/commons/Spacing';
import { MoimPostPropTypes } from './../constants/constants';
import Curious from './CuriousGroup';

export interface groupContentPropTypes {
topicName: string;
imageUrl: string | null;
postTitle: string;
postContent: string;
groupId: number;
isLast: boolean;
}

const GroupContent = ({
topicName,
imageUrl,
postTitle,
postContent,
groupId,
isLast,
}: MoimPostPropTypes & { isLast: boolean }) => {
}: groupContentPropTypes) => {
const hasImage = () => {
return imageUrl !== null;
};
Expand All @@ -26,7 +36,16 @@ const GroupContent = ({
</SubText>
</TextContainer>
{imageUrl && <Image src={imageUrl} isLast={isLast} alt="group-content-image" />}
{isLast && <Curious />}
{isLast && (
<CuriousGroup
groupId={groupId}
topicName={topicName}
imageUrl={imageUrl}
postTitle={postTitle}
postContent={postContent}
isLast={isLast}
/>
)}
</ContentLayout>
);
};
Expand Down Expand Up @@ -57,7 +76,7 @@ const TextContainer = styled.div`
`;

const SubText = styled.p<{ isImage: boolean; isLast: boolean }>`
flex-shrink: 0;
display: -webkit-box;
width: ${({ isImage, isLast }) =>
isImage && isLast
? '47.8rem'
Expand All @@ -71,10 +90,17 @@ const SubText = styled.p<{ isImage: boolean; isLast: boolean }>`

color: ${({ theme }) => theme.colors.gray80};
text-overflow: ellipsis;

-webkit-line-clamp: 4;
-webkit-box-orient: vertical;

${({ theme }) => theme.fonts.body3};
`;

const Image = styled.img<{ isLast: boolean }>`
width: ${({ isLast }) => (isLast ? '16.8rem' : '22.4rem')};
height: 16.8rem;
object-fit: cover;

border-radius: 8px;
`;
11 changes: 7 additions & 4 deletions src/pages/main/components/GroupNameButton.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import styled from '@emotion/styled';
import { useNavigate } from 'react-router-dom';

import { MainIcnArrowPurple as MainIcnArrowPurpleIcon } from '../../../assets/svgs';

interface ButtonPropTypes {
buttonName: string;
groupName: string;
groupId: number;
}
const GroupNameButton = ({ buttonName }: ButtonPropTypes) => {
const GroupNameButton = ({ groupId, groupName }: ButtonPropTypes) => {
const navigate = useNavigate();
const handleButtonOnClick = () => {
alert('button clicked');
navigate(`/group/${groupId}`);
};

return (
<GroupNameButtonWrapper onClick={handleButtonOnClick}>
{buttonName}
{groupName}
<MainIcnArrowPurpleIcon />
</GroupNameButtonWrapper>
);
Expand Down
14 changes: 6 additions & 8 deletions src/pages/main/components/Introduction.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import styled from '@emotion/styled';

import { INTRODUCTION_DATA } from '../constants/introductionData';

import {
MainIcnArrowWhite as MainArrowWhiteIc,
MainGraphicLogo as MainGraphicLogoIc,
Expand All @@ -21,23 +23,19 @@ const Introduction = () => {
마일 메이커들의 에피소드
</MainText>
<Spacing marginBottom="0.8" />
<SubText>메이커들의 글 모임에서 확인해 보세요</SubText>
<SubText>{INTRODUCTION_DATA[0].subText}</SubText>
<Spacing marginBottom="8" />
<GroupRoutingButtonBox onClick={handleOnClick}>
마일 글 모임 바로가기
<MainArrowWhiteIc />
</GroupRoutingButtonBox>
</MileMakersTextLayout>
<IntroduceZakmiBox>
<HookText>마일의 첫 번째 에피소드</HookText>
<HookText>{INTRODUCTION_DATA[0].hookText}</HookText>
<Spacing marginBottom="0.4" />
<GreetingText>우리가 글쓰기 모임에 주목한 이유</GreetingText>
<GreetingText>{INTRODUCTION_DATA[0].greetingText}</GreetingText>
<Spacing marginBottom="3" />
<DiscriptionText>
“체취가 느껴지는 글은 오랜만에 읽어보는 것 같아. 솔직담백해서 좋다!” 내가 처음으로 올린
블로그 글에 친구가 달아준 댓글이었다. 사실 글쓰기에 중요한 건, ‘잘’ 쓰는 것이 아니라 그냥
내 마음을 담아 쓰는 것이라는 걸 알게 됐었다. 그리고 그렇게 마음을 담은 글...
</DiscriptionText>
<DiscriptionText>{INTRODUCTION_DATA[0].discriptionText}</DiscriptionText>
</IntroduceZakmiBox>
</IntroductionWrapper>
);
Expand Down
18 changes: 10 additions & 8 deletions src/pages/main/components/MainHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
import styled from '@emotion/styled';
import { useNavigate } from 'react-router-dom';

import { HeaderLogoIc } from '../../../assets/svgs';
import LogInOutBtn from '../../../components/commons/LogInOutBtn';
import theme from '../../../styles/theme';
import logout from '../../../utils/logout';
import MakeGroupBtn from '../../groupFeed/components/MakeGroupBtn';
import MyGroupBtn from '../../groupFeed/components/MyGroupBtn';

interface OnClickProps {
onClick: () => void;
}

// 메인 페이지 헤더
export const MainHeader = ({ onClick }: OnClickProps) => {
export const MainHeader = () => {
return (
<HeaderWrapper>
<HeaderLogoIc />
<HeaderBtnLayout>
<MyGroupBtn />
<CommonBtnLayout>
<MakeGroupBtn />
<LogInOutBtn onClick={onClick}>로그아웃</LogInOutBtn>
<LogInOutBtn onClick={logout}>로그아웃</LogInOutBtn>
</CommonBtnLayout>
</HeaderBtnLayout>
</HeaderWrapper>
);
};

//아직 로그인을 하지 않았을 때 헤더
export const LogOutHeader = ({ onClick }: OnClickProps) => {
export const LogOutHeader = () => {
const navigate = useNavigate();
const handleLogIn = () => {
navigate(`/login`);
};
Copy link
Member

Choose a reason for hiding this comment

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

[P3]
헤더네이밍이 unAuthorizationHeader 면 좋을 것 같아요

Copy link
Member Author

Choose a reason for hiding this comment

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

넵 수정하겠습니다!

return (
<HeaderWrapper>
<HeaderLogoIc />
<LogInOutBtn onClick={onClick}>로그인</LogInOutBtn>
<LogInOutBtn onClick={handleLogIn}>로그인</LogInOutBtn>
</HeaderWrapper>
);
};
Expand Down
11 changes: 7 additions & 4 deletions src/pages/main/components/Ruler.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import styled from '@emotion/styled';

import { useEffect, useState } from 'react';

import styled from '@emotion/styled';
import { getRecommendTopic } from '../apis/getRecommendTopic';
import { recommendPropsTypes } from '../types/recommendTopic';

import { MainGraphicGradationIc } from '../../../assets/svgs';
import Spacing from '../../../components/commons/Spacing';
import { getRecommendTopic } from '../apis/getRecommendTopic';
import { recommendPropsTypes } from '../types/recommendTopic';

const Ruler = () => {
const [recommendTopicData, setRecommendTopicData] = useState<recommendPropsTypes>();
Expand Down Expand Up @@ -78,7 +79,9 @@ const RulerContentBox = styled.div`
`;

const TodayKeyWord = styled.span`
width: 30rem;
width: fit-content;

white-space: nowrap;
`;

const Pipe = styled.div`
Expand Down
16 changes: 16 additions & 0 deletions src/pages/main/constants/introductionData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
interface introductionPropTypes {
subText: string;
hookText: string;
greetingText: string;
discriptionText: string;
}

export const INTRODUCTION_DATA: introductionPropTypes[] = [
{
subText: '메이커들의 글 모임에서 확인해 보세요',
hookText: '마일의 첫 번째 에피소드',
greetingText: '우리가 글쓰기 모임에 주목한 이유',
discriptionText:
'“체취가 느껴지는 글은 오랜만에 읽어보는 것 같아. 솔직담백해서 좋다!” 내가 처음으로 올린 블로그 글에 친구가 달아준 댓글이었다. 사실 글쓰기에 중요한 건, ‘잘’ 쓰는 것이 아니라 그냥 내 마음을 담아 쓰는 것이라는 걸 알게 됐었다. 그리고 그렇게 마음을 담은 글...',
},
];
16 changes: 0 additions & 16 deletions src/pages/main/types/moimPost.ts

This file was deleted.