Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#88/commentAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
hoyyChoi authored Nov 23, 2023
2 parents 2ceef2d + dae6ecc commit 980bd41
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 34 deletions.
15 changes: 15 additions & 0 deletions src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,18 @@ export const getgetget = async (topic: string) => {
});
return res;
};

export const getMainBottom = async () => {
const res = await GwangjangAxios.get("/keyword/topic/all");
return res;
};

export const getMainTop = async () => {
const res = await GwangjangAxios.get("/member/subscribe/issue");
return res;
};

export const getPopularContents = async () => {
const res = await GwangjangAxios.get("/contents/contents/like");
return res;
};
8 changes: 7 additions & 1 deletion src/components/atoms/tag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ export const TopicTag = ({ category }: { category: string | undefined }) => {
return <Tag $category={category}>{category}</Tag>;
};

export const KeywordTag = ({ category, children }: { category: string; children: string }) => {
export const KeywordTag = ({
category,
children,
}: {
category: string | undefined;
children: string | undefined;
}) => {
return <Keyword $category={category}>{children}</Keyword>;
};
2 changes: 1 addition & 1 deletion src/components/atoms/tag/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Tag = styled.div<{ $category: string | undefined }>`
letter-spacing: -0.18px;
`;

export const Keyword = styled.div<{ $category: string }>`
export const Keyword = styled.div<{ $category: string | undefined }>`
display: inline-flex;
padding: 3px 10px;
justify-content: center;
Expand Down
14 changes: 9 additions & 5 deletions src/components/molecules/main/communitybox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// import { useState, useEffect } from "react";

import { useRecoilValue } from "recoil";
import styled from "styled-components";
import { Swiper, SwiperSlide } from "swiper/react";

import { CommentButton, LikeButton } from "@/components/atoms/button";
import { Profile } from "@/components/atoms/profile";
import { KeywordTag, TopicTag } from "@/components/atoms/tag";
import { mainCommunityData } from "@/dummy/mainCommunityData";
import { PopularCommunityState } from "@/recoil/atoms";

import { CommunityContainer } from "./style";

Expand All @@ -29,6 +29,10 @@ export const CommunityBox = () => {
// };
// }, []);

const communityData = useRecoilValue(PopularCommunityState);

console.log(communityData, 22);

return (
<TempContainer>
<Swiper
Expand Down Expand Up @@ -127,13 +131,13 @@ export const CommunityBox = () => {
},
}}
>
{mainCommunityData.map((item, idx) => (
{communityData.map((item, idx) => (
<SwiperSlide key={idx}>
<CommunityContainer>
<div className="community-content">
<div className="community-tag-wrapper">
<TopicTag category={item.area} />
<KeywordTag category={item.area}>{item.topic}</KeywordTag>
<KeywordTag category={item.area}>{item.subject}</KeywordTag>
<KeywordTag category={item.area}>{item.keyword}</KeywordTag>
</div>
<div className="content-wrapper">
Expand All @@ -153,7 +157,7 @@ export const CommunityBox = () => {
</div>
<div className="quotation">
<div className="quot-title">인용한 콘텐츠</div>
<div className="quot-text">{item.quotText}</div>
<div className="quot-text">{item.contentsTitle}</div>
</div>
</CommunityContainer>
</SwiperSlide>
Expand Down
19 changes: 10 additions & 9 deletions src/components/molecules/main/contentbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@ import { useState } from "react";

import nextIcon from "@/assets/nextIcon.svg";
import { KeywordTag, TopicTag } from "@/components/atoms/tag";
import { ContentDataProps } from "@/types";
import { ContentsMainProps } from "@/types";

import { ContentContainer, EdgeContainer, HoverContent } from "./style";

export const ContentBox = ({ data, category }: { data: ContentDataProps; category: string }) => {
export const ContentBox = ({ data, category }: { data?: ContentsMainProps; category: string }) => {
console.log(category);
const containerStyle = {
backgroundImage: `linear-gradient(180deg, rgba(34, 34, 34, 0.2) 57.24%, rgba(34,34,34,0.95) 87.86%),url(${data.imgUrl})`,
backgroundImage: `linear-gradient(180deg, rgba(34, 34, 34, 0.2) 57.24%, rgba(34,34,34,0.95) 87.86%),url(${data?.imgUrl})`,
backgroundSize: "cover",
// boxShadow: "0px 15px 34px 0px rgba(207, 207, 207, 0.1)",
};

const [hover, setHover] = useState<boolean>(false);

const onClick = () => {
window.open(`${data.link}`, "_blank");
window.open(`${data?.link}`, "_blank");
};

return (
Expand All @@ -27,7 +28,7 @@ export const ContentBox = ({ data, category }: { data: ContentDataProps; categor
onMouseOut={() => setHover(false)}
>
<HoverContent $hover={hover}>
<div className="article-text">{data.content}</div>
<div className="article-text">{data?.title}</div>
<div className="article-img">
<img
src={nextIcon}
Expand All @@ -42,15 +43,15 @@ export const ContentBox = ({ data, category }: { data: ContentDataProps; categor
>
<div className="tag-box">
<div>
<TopicTag category={category} />
<TopicTag category={data?.topic} />
</div>
<div>
<KeywordTag category={category}>{data.keyword[1]}</KeywordTag>
<KeywordTag category={data?.topic}>{data?.keyword}</KeywordTag>
</div>
</div>
<div className="text-box">
<p>{data.type}</p>
<div className="content-title">{data.title}</div>
<p>{data?.type}</p>
<div className="content-title">{data?.title}</div>
</div>
</ContentContainer>
</EdgeContainer>
Expand Down
6 changes: 6 additions & 0 deletions src/components/organisms/Home/DiscussedTopics.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { useRecoilValue } from "recoil";
import styled from "styled-components";

import { Title } from "@/components/atoms/title";
import Topic from "@/components/molecules/discussedTopic";
import { topicData } from "@/dummy/topicData";
import { TalkingTopicState } from "@/recoil/atoms";
// import { TalkingTopicState } from "@/recoil/atoms";

const title = "광장이 이야기하는\n사회 이슈";
const DiscussedTopics = () => {
const bottomData = useRecoilValue(TalkingTopicState);
console.log("bbb", bottomData);

return (
<Container>
<div className="inner">
Expand Down
20 changes: 14 additions & 6 deletions src/components/organisms/Home/MainContent.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { useRecoilValue } from "recoil";
import styled from "styled-components";

import { SeeMore } from "@/components/atoms/more";
import { Title } from "@/components/atoms/title";
import { ContentBox } from "@/components/molecules/main/contentbox";
import { contentData } from "@/dummy/ContentData";
// import { contentData } from "@/dummy/ContentData";
import { ContentsPopularState } from "@/recoil/atoms";
import { Inner } from "@/style/global";

export const MainContent = () => {
const firstData = contentData[0];
const title = "지금 가장\n인기있는 콘텐츠";

// const firstData = contentData[0];
const title = "지금 사람들이\n가장 많이 본 콘텐츠";


const contentsData = useRecoilValue(ContentsPopularState);
console.log("dfdf", contentsData);
const firstData = contentsData[0];

return (
<Background>
Expand All @@ -22,15 +30,15 @@ export const MainContent = () => {
<ContentBox
key={0}
data={firstData}
category={firstData.category}
category={""} // category={contentsData[0].topic}
/>
</div>
<div className="content-grid">
{contentData.slice(1).map((data, idx) => (
{contentsData.slice(1).map((data, idx) => (
<ContentBox
key={idx}
data={data}
category={data.category}
category={""} // category={data.topic}
/>
))}
</div>
Expand Down
17 changes: 11 additions & 6 deletions src/components/organisms/Home/MainTopic.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { useRecoilValue } from "recoil";
import styled from "styled-components";

import { SeeMore } from "@/components/atoms/more";
import { Title } from "@/components/atoms/title";
import { TopicBox } from "@/components/molecules/main/topicbox";
import { subjectData } from "@/dummy/subjectData";
// import { subjectData } from "@/dummy/subjectData";
import { MainTopState } from "@/recoil/atoms";
import { Inner } from "@/style/global";

export const MainTopic = () => {
const title = " 광장에서 가장\n인기 있는 사회 이슈";

const mainTopicData = useRecoilValue(MainTopState);
console.log(mainTopicData);

return (
<Background>
<Inner>
Expand All @@ -17,13 +22,13 @@ export const MainTopic = () => {
<Title title={title} />
</div>
<TopicWrapper>
{subjectData.map((data, idx) => (
{mainTopicData.map((data, idx) => (
<TopicBox
key={idx}
title={data.title}
subscribeCount={data.subscribeCount}
imgUrl={data.imgUrl}
category={data.category}
title={data?.title}
subscribeCount={data?.subscribeCount}
imgUrl={data?.imgUrl}
category={data?.category}
/>
))}
</TopicWrapper>{" "}
Expand Down
8 changes: 4 additions & 4 deletions src/dummy/topicData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

export const topicData = [
{
title: "일자리 노동1",
title: "일자리-노동",
subTitles: ["SPC", "쿠팡 노동자 사망", "주 69시간 근로시간 제도 개편"],
},
{
title: "일자리 노동2",
title: "주거-사회안전망",
subTitles: ["SPC", "쿠팡 노동자 사망", "주 69시간 근로시간 제도 개편"],
},
{
title: "일자리 노동3",
title: "환경",
subTitles: ["SPC", "쿠팡 노동자 사망", "주 69시간 근로시간 제도 개편"],
},
{
title: "일자리 노동4",
title: "교육",
subTitles: ["SPC", "쿠팡 노동자 사망", "주 69시간 근로시간 제도 개편"],
},
];
67 changes: 65 additions & 2 deletions src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,40 @@ import { useEffect } from "react";

import { useSetRecoilState } from "recoil";

import { getMainBubbleChart } from "@/apis";
import {
getCommunityTop5,
getMainBottom,
getMainBubbleChart,
getMainTop,
getPopularContents,
} from "@/apis";
import BubbleChart from "@/components/organisms/Home/BubbleChart";
import DiscussedTopics from "@/components/organisms/Home/DiscussedTopics";
// import { LoginTopic } from "@/components/organisms/Home/LoginTopic";
import { MainCommunity } from "@/components/organisms/Home/MainCommunity";
import { MainContent } from "@/components/organisms/Home/MainContent";
import { MainTopic } from "@/components/organisms/Home/MainTopic";
import { packbubbleDummydata } from "@/dummy/packBubbleData";
import { BubbleChartState } from "@/recoil/atoms";
import {
BubbleChartState,
ContentsPopularState,
MainTopState,
PopularCommunityState,
TalkingHoverState,
TalkingTopicState,
} from "@/recoil/atoms";
import { DragContainer } from "@/style/global";
import { CommunityMainProps, ContentsMainProps, TopicMainProps, mainTopicBottom } from "@/types";
const Home = () => {
const setBubbleChartData = useSetRecoilState(BubbleChartState);
const setMainBottomData = useSetRecoilState<mainTopicBottom[]>(TalkingTopicState);
const setHoverData = useSetRecoilState(TalkingHoverState);
const setMainTopData = useSetRecoilState<TopicMainProps[]>(MainTopState);

const setPopularContents = useSetRecoilState<ContentsMainProps[]>(ContentsPopularState);

const setCommunityData = useSetRecoilState<CommunityMainProps[]>(PopularCommunityState);

useEffect(() => {
getMainBubbleChart()
.then((res) => {
Expand All @@ -28,7 +50,48 @@ const Home = () => {
console.log(err);
setBubbleChartData(packbubbleDummydata);
});

//메인 하단
getMainBottom()
.then((res) => {
console.log("res.data.data:", res.data.data);
setMainBottomData(res.data.data);
setHoverData(res.data.data.issueList);
})
.catch((err) => {
console.log(err);
});

//메인 상단 주제4개
getMainTop()
.then((res) => {
// console.log("top4:", res.data);
setMainTopData(res.data.data.slice(0, 4));
})
.catch((err) => {
console.log(err);
});

//
getPopularContents()
.then((res) => {
// console.log(res.data);
setPopularContents(res.data.data.slice(0, 5));
})
.catch((err) => {
console.log(err);
});

getCommunityTop5()
.then((res) => {
// console.log(res.data);
setCommunityData(res.data.data);
})
.catch((err) => {
console.log(err);
});
}, [setBubbleChartData]);

return (
<DragContainer>
<BubbleChart />
Expand Down
Loading

0 comments on commit 980bd41

Please sign in to comment.