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

Feature: Post detail 페이지 UI 구성 #103

Merged
merged 8 commits into from
Oct 18, 2023
Binary file added public/default-user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/common/searchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const SearchBar = () => {
<div css={searchBarCSS}>
<input css={inputCSS} value={searchText} onChange={changeHandler} onKeyPress={keyPressHandler} type="text" placeholder="search" />
<button css={buttonCSS} type="button" onClick={clickHandler}>
<SearchIcon />
<SearchIcon color={color.greenGray} />
</button>
{toastMessages.map((toast) => (
<Toast
Expand Down
2 changes: 1 addition & 1 deletion src/components/community/BoardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const BoardList = () => {
linkUrl={`/community/${characterInfo.code}`}
>
<FriendInfo
characterName={characterInfo.name}
characterName={`${characterInfo.name} 게시판`}
// TODO: 백엔드는 이미지를 뿌려라!
// imageUrl={characterInfo.profileUrl}
message={`임시 정보 입니다. ${characterInfo.hashtags}`}
Expand Down
2 changes: 1 addition & 1 deletion src/components/community/CommunityHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const CommunityHeader = () => {
? (
<CharacterInfo
imageUrl="/leeyj.png"
characterName={characterInfo.name}
characterName={`${characterInfo.name} 게시판`}
hashTag={characterInfo.hashtags}
link="/community"
/>
Expand Down
64 changes: 64 additions & 0 deletions src/components/community/PostHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { useEffect, useState } from 'react';
import { css } from '@emotion/react';
import color from '@/styles/color';
import { useRouter } from 'next/router';
import { findCharacterById } from '@/utils/api/character';
import { CharacterInfo as CharacterInfoType } from '@/types/characterInfo';
import CharacterInfo from '@/components/chat/characterHeader/CharacterInfo';
import Loading from '../common/dialog/Loading';

const PostHeader = () => {
const router = useRouter();
const { character_id: characterId } = router.query;
const [characterInfo, setCharacterInfo] = useState<CharacterInfoType>();
useEffect(() => {
if (characterId && typeof characterId === 'string') {
findCharacterById(characterId)
.then((data) => setCharacterInfo(data))
.catch((error) => {
console.error('Error fetching post:', error);
});
}
}, [characterId]);
return (
<header css={headerCSS}>
{/* TODO: 캐릭터의 정보, 이미지가 필요합니다. */}
<span css={characterInfoCSS}>
{
characterInfo
? (
<CharacterInfo
imageUrl="/leeyj.png"
characterName={`${characterInfo.name} 게시판`}
hashTag={characterInfo.hashtags}
link={`/community/${characterInfo.code}`}
/>
)
: <Loading />
}
</span>
</header>
);
};

export default PostHeader;

const headerCSS = css`
position: sticky;
top: 0;
z-index: 100; // 채팅보다 위에 존재해야하기 때문에 필요함
width: 100%;
max-width: 400px;
padding: 1rem 1rem;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
background-color: ${color.white};
`;

const characterInfoCSS = css`
display: flex;
flex-direction: row;
align-items: center;
`;
45 changes: 45 additions & 0 deletions src/components/community/postDetail/PostStatus.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { css } from '@emotion/react';
import HeartIcon from '@/components/icons/HeartIcon';
import CommentIcon from '@/components/icons/CommentIcon';
import ReportIcon from '@/components/icons/ReportIcon';
import color from '@/styles/color';

const PostStatus = () => (
<ul css={ulCSS}>
<li title="좋아요" css={liCSS}>
<HeartIcon color={color.black} />
<div css={statusCSS}>1</div>
</li>
<li title="댓글" css={liCSS}>
<CommentIcon color={color.black} />
<div css={statusCSS}>3</div>
</li>
<li title="신고" css={liCSS}>
<ReportIcon color={color.black} />
<div css={statusCSS}>신고</div>
</li>
</ul>
);

export default PostStatus;

const ulCSS = css`
display: flex;
flex-direction: row;
align-items: center;
gap: 0.25rem;
padding-top: 1rem;
`;

const liCSS = css`
display: flex;
flex-direction: row;
align-items: center;
gap: 0.25rem;
`;

const statusCSS = css`
font-size: 0.75rem;
font-weight: bold;
color: ${color.black};
`;
5 changes: 1 addition & 4 deletions src/components/icons/BackwordIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { FC } from 'react';

interface IconProps {
color: string
}
import { IconProps } from '@/types/icon';

const BackwordIcon: FC<IconProps> = ({ color }) => (
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down
5 changes: 1 addition & 4 deletions src/components/icons/ChatIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { FC } from 'react';

interface IconProps {
color: string
}
import { IconProps } from '@/types/icon';

const ChatIcon: FC<IconProps> = ({ color }) => (
<svg width="26" height="26" viewBox="0 0 21 21" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down
4 changes: 1 addition & 3 deletions src/components/icons/CommentIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { FC } from 'react';
import { IconProps } from '@/types/icon';

interface IconProps {
color: string
}
const CommentIcon: FC<IconProps> = ({ color }) => (
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="Comment">
Expand Down
5 changes: 1 addition & 4 deletions src/components/icons/CommunityIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { FC } from 'react';

interface IconProps {
color: string
}
import { IconProps } from '@/types/icon';

const CommunityIcon: FC<IconProps> = ({ color }) => (
<svg width="26" height="26" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down
4 changes: 1 addition & 3 deletions src/components/icons/HeartIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { FC } from 'react';
import { IconProps } from '@/types/icon';

interface IconProps {
color: string
}
const HeartIcon: FC<IconProps> = ({ color }) => (
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="Heart">
Expand Down
5 changes: 1 addition & 4 deletions src/components/icons/HomeIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { FC } from 'react';

interface IconProps {
color: string
}
import { IconProps } from '@/types/icon';

const HomeIcon: FC<IconProps> = ({ color }) => (
<svg width="26" height="26" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down
4 changes: 1 addition & 3 deletions src/components/icons/ProfileIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { FC } from 'react';
import { IconProps } from '@/types/icon';

interface IconProps {
color: string
}
const ProfileIcon: FC<IconProps> = ({ color }) => (
<svg width="26" height="26" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M21.2926 10.0235C22.0826 10.8136 22.0826 12.0944 21.2926 12.8845C20.5026 13.6745 19.2217 13.6745 18.4316 12.8845C17.6416 12.0944 17.6416 10.8136 18.4316 10.0235C19.2217 9.23349 20.5026 9.23349 21.2926 10.0235" stroke={color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
Expand Down
10 changes: 10 additions & 0 deletions src/components/icons/ReportIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { IconProps } from '@/types/icon';
import { FC } from 'react';

const ReportIcon: FC<IconProps> = ({ color }) => (
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<path id="Icon Shape" fillRule="evenodd" clipRule="evenodd" d="M15 7.5C15 11.6421 11.6421 15 7.5 15C3.35786 15 0 11.6421 0 7.5C0 3.35786 3.35786 0 7.5 0C11.6421 0 15 3.35786 15 7.5ZM11.4561 12.3388C10.3786 13.2208 9.00108 13.75 7.5 13.75C4.04822 13.75 1.25 10.9518 1.25 7.5C1.25 5.99892 1.77918 4.62144 2.66116 3.54393C2.66823 3.55174 2.67553 3.55941 2.68306 3.56694L11.4331 12.3169C11.4406 12.3245 11.4483 12.3318 11.4561 12.3388ZM12.3388 11.4561C12.3318 11.4483 12.3245 11.4406 12.3169 11.4331L3.56694 2.68306C3.55941 2.67553 3.55174 2.66823 3.54393 2.66116C4.62144 1.77918 5.99892 1.25 7.5 1.25C10.9518 1.25 13.75 4.04822 13.75 7.5C13.75 9.00108 13.2208 10.3786 12.3388 11.4561Z" fill={color} />
</svg>
);

export default ReportIcon;
9 changes: 6 additions & 3 deletions src/components/icons/SearchIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const SearchIcon = () => (
import { FC } from 'react';
import { IconProps } from '@/types/icon';

const SearchIcon: FC<IconProps> = ({ color }) => (
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="6.05928" cy="6.0594" r="3.69331" stroke="#949BA5" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
<path d="M10.7373 10.7374L8.67065 8.67072" stroke="#949BA5" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
<circle cx="6.05928" cy="6.0594" r="3.69331" stroke={color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
<path d="M10.7373 10.7374L8.67065 8.67072" stroke={color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
</svg>
);

Expand Down
5 changes: 1 addition & 4 deletions src/components/icons/SettingIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { FC } from 'react';

interface IconProps {
color: string
}
import { IconProps } from '@/types/icon';

const SettingIcon: FC<IconProps> = ({ color }) => (
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down
32 changes: 23 additions & 9 deletions src/pages/community/[character_id]/[post_id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import Loading from '@/components/common/dialog/Loading';
import color from '@/styles/color';
import { postDetailDateParse } from '@/utils/services/date';
import { PostData } from '@/types/post';
import PostHeader from '@/components/community/PostHeader';
import Image from 'next/image';
import PostStatus from '@/components/community/postDetail/PostStatus';
import DivideLine from '@/components/common/divideLine/DivideLine';

const Post = () => {
const router = useRouter();
Expand All @@ -17,6 +21,7 @@ const Post = () => {
if (typeof characterId === 'string' && typeof postId === 'string') {
findPostById(characterId, postId).then((data) => {
setPost(data);
console.log(data);
}).catch((error) => {
console.error('Error fetching post:', error);
});
Expand All @@ -26,23 +31,30 @@ const Post = () => {
return (
<>
<SEO title="Community - Post" />
<PostHeader />
<section css={pageCSS}>
<div css={postCSS}>
{post ? (
<div>
{/* TODO: 게시글 쓴 사람의 이미지가 필요함 */}
<div css={postInfoCSS}>
<div css={writerNameCSS}>{post.writerName}</div>
<div css={dateCSS}>{postDetailDateParse(post.createdAt)}</div>
<Image src="/default-user.png" alt="user-profile" width={26} height={26} />
<div css={css`padding-left: 0.5rem;`}>
<div css={writerNameCSS}>{post.writerName}</div>
<div css={dateCSS}>{postDetailDateParse(post.createdAt)}</div>
</div>
</div>
<div css={postMainCSS}>
<div css={titleCSS}>{post.title}</div>
<div css={contentCSS}>{post.content}</div>
</div>
<PostStatus />
</div>
)
: <Loading />}
</div>
<DivideLine />
<div css={css`font-size:0.8rem;`}>덧글은 추후에 제공될 예정입니다 :)</div>
</section>
<BottomNavBar pageName="Community" />
</>
Expand All @@ -54,20 +66,21 @@ const pageCSS = css`
height: 100vh;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
padding: 0.5rem;
padding: 0 3rem;
`;

const postCSS = css`
width: 100%;
padding: 1rem 0;
`;

const titleCSS = css`
font-size: 1rem;
font-weight:bold;
font-weight: bold;
color:${color.black};

padding-bottom: 0.3rem
padding-bottom: 1rem;
`;

const contentCSS = css`
Expand All @@ -77,11 +90,12 @@ const contentCSS = css`

const postInfoCSS = css`
padding: 0.2rem 0 0.2rem 0;
display: flex;
flex-direction: row;
`;

const writerNameCSS = css`
font-size: 0.75rem;
font-weight:bold;
font-size: 0.9rem;
color:${color.black};
padding-bottom: 0.2rem;
`;
Expand All @@ -92,5 +106,5 @@ const dateCSS = css`
`;

const postMainCSS = css`
padding: 0.2rem 0 0.2rem 0;
padding: 1.25rem 0 0.2rem 0;
`;
3 changes: 3 additions & 0 deletions src/types/icon.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface IconProps {
color: string
}
Loading