-
Notifications
You must be signed in to change notification settings - Fork 7
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
[SP2] 블로그 탭 게시물 목록 구현 #232
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9ad969a
feat: 블로그 글 목록 컴포넌트 구현
e437d10
asset: 빈 하트 svg 추가
60e183b
feat: 블로그 글 컴포넌트 구현
8edccd2
feat: 기본 프로필 이미지 컴포넌트 구현
94c6f8c
feat: 블로그 글 리스펀스 타입 선언
f50da90
feat: 블로그 글 헤더, 좋아요 컴포넌트 분리
42e6afb
feat: 선택한 탭 props 받기
bf1f2f9
feat: 블로그 글 공통 타입 선언
7ee3cee
chore: 컴포넌트명 및 위치 수정
10e9171
fix: re-export용 index.ts 파일 제거
ec63b70
fix: 기본 내보내기 코드 컨벤션에 맞춰 수정
7969059
Merge branch 'develop' into feat/#221-blog-tab-post
5fbb739
chore: colors 파일 제거
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export type BlogPostListType = { | ||
limit: number; | ||
totalCount: number; | ||
totalPage: number; | ||
currentPage: number; | ||
data: BlogPostType[]; | ||
hasNextPage: boolean; | ||
hasPrevPage: boolean; | ||
}; | ||
|
||
export type BlogPostType = { | ||
id: number; | ||
part: string; | ||
generation: number; | ||
thumbnailUrl: string; | ||
title: string; | ||
description: string; | ||
author: string; | ||
authorProfileImageUrl: string | null; | ||
url: string; | ||
uploadedAt: string; | ||
|
||
/* article */ | ||
likeCount?: number; | ||
liked?: boolean; | ||
|
||
/* review */ | ||
subject?: string; | ||
}; |
13 changes: 13 additions & 0 deletions
13
src/views/BlogPage/components/BlogPost/DefaultProfileImage/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Image from 'next/image'; | ||
import icProfileDefault from '@src/assets/icons/ic_profile_default.svg'; | ||
import * as S from './style'; | ||
|
||
function DefaultProfileImage() { | ||
return ( | ||
<S.DefaultProfileImage> | ||
<Image src={icProfileDefault} alt="작성자 프로필 이미지" width={10} height={10} /> | ||
</S.DefaultProfileImage> | ||
); | ||
} | ||
|
||
export default DefaultProfileImage; |
13 changes: 13 additions & 0 deletions
13
src/views/BlogPage/components/BlogPost/DefaultProfileImage/style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import styled from '@emotion/styled'; | ||
import { colors } from '@sopt-makers/colors'; | ||
|
||
export const DefaultProfileImage = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
width: 18px; | ||
height: 18px; | ||
border-radius: 18px; | ||
background-color: ${colors.gray700}; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { BlogPostType } from '@src/lib/types/blog'; | ||
import { formatDate } from '@src/lib/utils/dateFormat'; | ||
import { DefaultProfileImage } from '@src/views/BlogPage/components/BlogPost'; | ||
import * as S from './style'; | ||
|
||
interface HeaderProps { | ||
selectedTap: string; | ||
blogPost: BlogPostType; | ||
} | ||
|
||
function Header({ selectedTap, blogPost }: HeaderProps) { | ||
return ( | ||
<S.Header> | ||
{selectedTap === 'ARTICLE' ? ( | ||
<> | ||
<S.Profile> | ||
{blogPost.authorProfileImageUrl ? ( | ||
<S.ProfileImage | ||
src={blogPost.authorProfileImageUrl} | ||
alt="작성자 프로필 이미지" | ||
width={18} | ||
height={18} | ||
/> | ||
) : ( | ||
<DefaultProfileImage /> | ||
)} | ||
<div>{blogPost.author}</div> | ||
</S.Profile> | ||
<S.Divider>∙</S.Divider> | ||
<div>{formatDate(new Date(blogPost.uploadedAt), 'yyyymmdd', '.')}</div> | ||
</> | ||
) : ( | ||
<div>{blogPost.subject}</div> | ||
)} | ||
</S.Header> | ||
); | ||
} | ||
|
||
export default Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import styled from '@emotion/styled'; | ||
import { colors } from '@sopt-makers/colors'; | ||
import Image from 'next/image'; | ||
|
||
export const Header = styled.div` | ||
display: flex; | ||
height: 23px; | ||
margin-bottom: 4px; | ||
|
||
color: ${colors.gray200}; | ||
font-size: 14px; | ||
font-weight: 400; | ||
line-height: 160%; | ||
letter-spacing: -0.21px; | ||
|
||
/* 모바일 뷰 */ | ||
@media (max-width: 767px) { | ||
height: 16px; | ||
margin-bottom: 0; | ||
|
||
font-size: 12px; | ||
font-weight: 500; | ||
line-height: 135%; /* 16.2px */ | ||
letter-spacing: -0.18px; | ||
} | ||
`; | ||
|
||
export const Profile = styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: 6px; | ||
`; | ||
|
||
export const ProfileImage = styled(Image)` | ||
border-radius: 18px; | ||
|
||
/* 모바일 뷰 */ | ||
@media (max-width: 767px) { | ||
width: 15px; | ||
height: 15px; | ||
} | ||
`; | ||
|
||
export const Divider = styled.div` | ||
padding: 0 2px 0 2px; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Image from 'next/image'; | ||
import icHeartFilled from '@src/assets/icons/ic_heart_filled.svg'; | ||
import icHeartUnfilled from '@src/assets/icons/ic_heart_unfilled.svg'; | ||
import { BlogPostType } from '@src/lib/types/blog'; | ||
import * as S from './style'; | ||
|
||
interface LikeProps { | ||
blogPost: BlogPostType; | ||
} | ||
|
||
function Like({ blogPost }: LikeProps) { | ||
return ( | ||
<S.Like> | ||
<Image | ||
src={blogPost.liked ? icHeartFilled : icHeartUnfilled} | ||
alt="좋아요" | ||
width={16} | ||
height={16} | ||
/> | ||
<span>{blogPost.likeCount}</span> | ||
</S.Like> | ||
); | ||
} | ||
|
||
export default Like; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import styled from '@emotion/styled'; | ||
import { colors } from '@sopt-makers/colors'; | ||
|
||
export const Like = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 3px; | ||
|
||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
|
||
height: 28px; | ||
padding: 2px 8px; | ||
border-radius: 6px; | ||
background: ${colors.grayAlpha100}; | ||
|
||
color: ${colors.gray100}; | ||
font-size: 14px; | ||
font-weight: 400; | ||
line-height: 160%; /* 22.4px */ | ||
letter-spacing: -0.21px; | ||
|
||
transition: opacity 0.1s ease-out; | ||
&:hover { | ||
opacity: 0.8; | ||
} | ||
|
||
/* 모바일 뷰 */ | ||
@media (max-width: 767px) { | ||
display: none; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { default as DefaultProfileImage } from './DefaultProfileImage'; | ||
export { default as Header } from './Header'; | ||
export { default as Like } from './Like'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useEffect, useRef, useState } from 'react'; | ||
import type { BlogPostType } from '@src/lib/types/blog'; | ||
import { parsePartToKorean } from '@src/lib/utils/parsePartToKorean'; | ||
import { Like } from '@src/views/BlogPage/components/BlogPost'; | ||
import * as S from './style'; | ||
import Header from '@src/views/BlogPage/components/BlogPost/Header'; | ||
|
||
const TWO_LINE_TITLE_HEIGHT = 72; | ||
|
||
interface BlogPostProps { | ||
selectedTap: string; | ||
blogPost: BlogPostType; | ||
} | ||
|
||
function BlogPost({ selectedTap, blogPost }: BlogPostProps) { | ||
const titleRef = useRef<HTMLDivElement>(null); | ||
const [descriptionLine, setDescriptionLine] = useState(1); | ||
|
||
useEffect(() => { | ||
if (titleRef.current) { | ||
const titleHeight = titleRef.current.clientHeight; | ||
setDescriptionLine(titleHeight >= TWO_LINE_TITLE_HEIGHT ? 1 : 2); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<S.BlogPost href={blogPost.url}> | ||
<div> | ||
<Header selectedTap={selectedTap} blogPost={blogPost} /> | ||
<S.Body> | ||
<S.Title ref={titleRef}>{blogPost.title}</S.Title> | ||
<S.Description descriptionLine={descriptionLine}>{blogPost.description}</S.Description> | ||
</S.Body> | ||
<S.TagList> | ||
<S.Tag>{blogPost.generation}기</S.Tag> | ||
<S.Tag>{parsePartToKorean(blogPost.part)}</S.Tag> | ||
</S.TagList> | ||
</div> | ||
<S.ThumbnailWrapper> | ||
<S.Thumbnail src={blogPost.thumbnailUrl} alt="게시물 썸네일" width={239} height={160} /> | ||
{selectedTap === 'ARTICLE' && <Like blogPost={blogPost} />} | ||
</S.ThumbnailWrapper> | ||
</S.BlogPost> | ||
); | ||
} | ||
|
||
export default BlogPost; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion;
저희 컨벤션에
export default function~
으로 작업하기로 되어있습니다!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
앗 꼼꼼하게 봐주셔서 감사합니다!!