Skip to content

Commit

Permalink
Refactor/206 markdown (#212)
Browse files Browse the repository at this point in the history
* feat(FE): 마크다운 blockquote 수정

* chore(FE): 테스트를 위한 기능 활성화

* feat(FE): ArticleCard에 마크다운 문법 제거, 썸네일 추가

* fix(FE): 연속으로 첨부된 이미지가 보이지 않음

* design(FE): 아이콘 정리(긴급)

* chore(FE): 테스트 기능 비활성화
  • Loading branch information
prayinforrain authored Dec 8, 2022
1 parent 11d70e4 commit f64e745
Show file tree
Hide file tree
Showing 26 changed files with 124 additions and 74 deletions.
14 changes: 11 additions & 3 deletions client/components/MainSection/Articlecard/index.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,24 @@ export const ArticleContent = styled.div`
export const Content = styled.div`
overflow-x: hidden;
overflow-y: hidden;
height: 120px;
height: 125px;
line-height: 25px;
flex: 1;
display: block;
display: -webkit-box;
word-break: break-all;
padding-right: 10px;
word-break: break-word;
text-overflow: ellipsis;
line-clamp: 5;
-webkit-line-clamp: 5;
box-orient: vertical;
-webkit-box-orient: vertical;
`;

export const ArticleImage = styled.div`
export const ArticleImageContainer = styled.div`
width: 130px;
height: 130px;
background-color: ${COLORS.GRAY4};
border: 1px solid ${COLORS.GRAY3};
position: relative;
`;
12 changes: 9 additions & 3 deletions client/components/MainSection/Articlecard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { calcTime } from '../../../utils/calctime';
import {
ArticleContent,
ArticleHeader,
ArticleImage,
ArticleImageContainer,
Comments,
Content,
HeaderInfo,
Expand All @@ -22,10 +22,11 @@ interface Props {
profileimg: string;
nickname: string;
author?: string;
thumbnail?: string | null;
}

export const ArticleCard = React.forwardRef<HTMLInputElement, Props>(
({ id, description, author, nickname, date, comments, profileimg }: Props, ref) => (
({ id, description, author, nickname, date, comments, profileimg, thumbnail }: Props, ref) => (
<Link href={`/post/${id}`}>
<Wrapper ref={ref}>
<ArticleHeader>
Expand All @@ -40,7 +41,11 @@ export const ArticleCard = React.forwardRef<HTMLInputElement, Props>(
</ArticleHeader>
<ArticleContent>
<Content>{description || '글 내용이 없어용!'}</Content>
<ArticleImage />
{thumbnail && (
<ArticleImageContainer>
<Image src={thumbnail} layout="fill" alt="post thumbnail" />
</ArticleImageContainer>
)}
</ArticleContent>
<hr />
</Wrapper>
Expand All @@ -51,4 +56,5 @@ export const ArticleCard = React.forwardRef<HTMLInputElement, Props>(
ArticleCard.defaultProps = {
description: '',
author: '',
thumbnail: null,
};
8 changes: 6 additions & 2 deletions client/components/MainSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ArticlesSection, FakeButton, NewArticleSection, Placeholder, Wrapper, N
import { MainTopBar } from '../../styles/common';

import usePaginator, { NEXT } from '../../hooks/usePaginator';
import { renderMarkdownWithoutStyle } from '../../utils/markdown';

export default function MainSection() {
const [nextCursor, setNextCursor] = useState(NEXT.START);
Expand Down Expand Up @@ -40,17 +41,19 @@ export default function MainSection() {
</Link>
<ArticlesSection>
{pages.map((item: any, index: number) => {
const parsed = renderMarkdownWithoutStyle(item.description);
if (pages.length === index + 1)
return (
<ArticleCard
author={item.authorDetail.userid}
profileimg={item.authorDetail.profileimg}
id={item._id}
description={item.description}
description={parsed.content}
date={item.createdAt}
comments={item.childPosts}
nickname={item.authorDetail.nickname}
key={item._id}
thumbnail={parsed.thumbnail}
ref={lastFollowElementRef}
/>
);
Expand All @@ -59,11 +62,12 @@ export default function MainSection() {
author={item.authorDetail.userid}
profileimg={item.authorDetail.profileimg}
id={item._id}
description={item.description}
description={parsed.content}
date={item.createdAt}
comments={item.childPosts}
nickname={item.authorDetail.nickname}
key={item._id}
thumbnail={parsed.thumbnail}
/>
);
})}
Expand Down
2 changes: 1 addition & 1 deletion client/components/ReadPost/Comment/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useRef } from 'react';
import Link from 'next/link';
import UserProfile from '../../UserProfile';
import renderMarkdown from '../../../utils/markdown';
import { renderMarkdown } from '../../../utils/markdown';
import { CommentItem, CommentContentBox } from './index.style';

export interface commentItem {
Expand Down
2 changes: 1 addition & 1 deletion client/components/ReadPost/MainPost/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useRecoilValue } from 'recoil';
import { httpDelete } from '../../../utils/http';
import { authedUser } from '../../../atom';
import type PostProps from '../../../types/Post';
import renderMarkdown from '../../../utils/markdown';
import { renderMarkdown } from '../../../utils/markdown';
import UserProfile from '../../UserProfile';
import {
ContentBox,
Expand Down
2 changes: 1 addition & 1 deletion client/components/ReadPost/ParentPost/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { calcTime } from '../../../utils/calctime';
import { Author, AuthorDetail, Wrapper, ContentBox, HeaderBox, ParentTree, ParentTreeContainer } from './index.style';
import ProfileImg from '../../UserProfile/ProfileImg';
import type { Parent } from '../../../types/Post';
import renderMarkdown from '../../../utils/markdown';
import { renderMarkdown } from '../../../utils/markdown';

export default function ParentPost({ post }: { post: Parent }) {
const contentRef = useRef<HTMLDivElement>(null);
Expand Down
8 changes: 6 additions & 2 deletions client/components/Search/PostResult/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useCallback, useRef, useState } from 'react';
import COLORS from '../../../styles/color';
import usePaginator, { NEXT } from '../../../hooks/usePaginator';
import { ArticleCard } from '../../MainSection/Articlecard';
import { renderMarkdownWithoutStyle } from '../../../utils/markdown';

export default function PostResult({ keyword }: { keyword: string }) {
const [nextCursor, setNextCursor] = useState('START');
Expand All @@ -26,17 +27,19 @@ export default function PostResult({ keyword }: { keyword: string }) {
return (
<ResultContainer>
{pages.map((item: any, index: number) => {
const parsed = renderMarkdownWithoutStyle(item.description);
if (pages.length === index + 1)
return (
<ArticleCard
author={item.authorDetail.userid}
profileimg={item.authorDetail.profileimg}
id={item._id}
description={item.description}
description={parsed.content}
date={item.createdAt}
comments={item.childPosts}
nickname={item.authorDetail.nickname}
key={item._id}
thumbnail={parsed.thumbnail}
ref={lastFollowElementRef}
/>
);
Expand All @@ -45,11 +48,12 @@ export default function PostResult({ keyword }: { keyword: string }) {
author={item.authorDetail.userid}
profileimg={item.authorDetail.profileimg}
id={item._id}
description={item.description}
description={parsed.content}
date={item.createdAt}
comments={item.childPosts}
nickname={item.authorDetail.nickname}
key={item._id}
thumbnail={parsed.thumbnail}
/>
);
})}
Expand Down
2 changes: 1 addition & 1 deletion client/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function SearchSection() {
<Wrapper>
<TopBar>
<TopBarContainer>
<Image alt="search button" width={30} height={30} src="/search.svg" />
<Image alt="search button" width={30} height={30} src="/ico_search.svg" />
<SearchInputBar type="text" placeholder="검색어를 입력하세요." onKeyDown={handleEnter} ref={inputRef} />
</TopBarContainer>
</TopBar>
Expand Down
5 changes: 5 additions & 0 deletions client/components/SideBar/Menu/index.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export const Wrapper = styled.div`
color: ${COLORS.BLACK};
user-select: none;
background-color: ${COLORS.PRIMARY_LIGHT};
&:hover {
font-weight: 600;
}
&:hover > span {
width: 100%;
}
Expand Down
8 changes: 4 additions & 4 deletions client/components/SideBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { Setting, SideMenuBox, Wrapper } from './index.style';
import SideBarDropdown from './SideBarDropdown';

const menuList = [
{ routeSrc: '/', imgSrc: '/home.svg', text: '홈', avatar: false },
{ routeSrc: '/notification', imgSrc: '/announce.svg', text: '알림', avatar: false },
{ routeSrc: '/search', imgSrc: '/search.svg', text: '검색', avatar: false },
{ routeSrc: '/', imgSrc: '/ico_home.svg', text: '홈', avatar: false },
{ routeSrc: '/notification', imgSrc: '/ico_notification.svg', text: '알림', avatar: false },
{ routeSrc: '/search', imgSrc: '/ico_search.svg', text: '검색', avatar: false },
];

type SideBarProps = {
Expand Down Expand Up @@ -58,7 +58,7 @@ export default function SideBar({ notiState }: React.PropsWithChildren<SideBarPr
</SideMenuBox>
{dropdownState && <SideBarDropdown />}
<Setting onClick={showSettingdropdown}>
<Menu imgSrc="/setting.svg" text="설정" avatar={false} noti={false} />
<Menu imgSrc="/ico_setting.svg" text="설정" avatar={false} noti={false} />
</Setting>
</Wrapper>
);
Expand Down
8 changes: 6 additions & 2 deletions client/components/User/PostList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ArticleCard } from '../../MainSection/Articlecard';
import { PostLabel, SectionDivider } from './index.style';
import usePaginator, { NEXT } from '../../../hooks/usePaginator';
import { UserPostProps } from '../../../types/Post';
import { renderMarkdownWithoutStyle } from '../../../utils/markdown';

export default function PostList({ userData }: { userData: UserPostProps }) {
const [nextCursor, setNextCursor] = useState('START');
Expand All @@ -29,17 +30,19 @@ export default function PostList({ userData }: { userData: UserPostProps }) {
<PostLabel>게시글</PostLabel>
<SectionDivider />
{pages.map((item: any, index: number) => {
const parsed = renderMarkdownWithoutStyle(item.description);
if (pages.length === index + 1)
return (
<ArticleCard
author={item.authorDetail.userid}
profileimg={item.authorDetail.profileimg}
id={item._id}
description={item.description}
description={parsed.content}
date={item.createdAt}
comments={item.childPosts}
nickname={item.authorDetail.nickname}
key={item._id}
thumbnail={parsed.thumbnail}
ref={lastFollowElementRef}
/>
);
Expand All @@ -48,11 +51,12 @@ export default function PostList({ userData }: { userData: UserPostProps }) {
author={item.authorDetail.userid}
profileimg={item.authorDetail.profileimg}
id={item._id}
description={item.description}
description={parsed.content}
date={item.createdAt}
comments={item.childPosts}
nickname={item.authorDetail.nickname}
key={item._id}
thumbnail={parsed.thumbnail}
/>
);
})}
Expand Down
12 changes: 9 additions & 3 deletions client/components/Write/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Link from 'next/link';
import { useRecoilValue } from 'recoil';
import { authedUser } from '../../../atom';
import { httpPost, httpGet, httpPatch } from '../../../utils/http';
import renderMarkdown from '../../../utils/markdown';
import { renderMarkdown } from '../../../utils/markdown';
import UserDropDown from './UserDropDown';
import { getLeftWidth } from '../../../styles/theme';
import UserProfile from '../../UserProfile';
Expand Down Expand Up @@ -67,6 +67,12 @@ export default function Editor({ parentPostData, modifyPostData }: Props) {
const [inputUserId, setInputUserId] = useState<string>('');
const [selectUser, setSelectUser] = useState<number>(0);

// 실시간 미리보기를 활성화하려면 이걸 키고 preview element의 렌더링 조건을 tabIndex === 0 으로 바꿔주세요
// useEffect(() => {
// if (!previewRef.current) return;
// previewRef.current.innerHTML = renderMarkdown(content);
// }, [content]);

const submitHandler = async () => {
const removeDup = new Set(mentionList);
const target = contentRef.current;
Expand Down Expand Up @@ -251,7 +257,7 @@ export default function Editor({ parentPostData, modifyPostData }: Props) {
contentRef.current.innerHTML = '<div><br/></div>';
}
}
setContent(contentRef.current.innerText.replace(/\n\n/g, '\n'));
setContent(contentRef.current.innerText);
};

const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
Expand Down Expand Up @@ -464,7 +470,7 @@ export default function Editor({ parentPostData, modifyPostData }: Props) {
<br />
</div>
</EditorTextBox>
<PreviewTextBox ref={previewRef} style={{ display: `${tabIndex === 1 ? 'block' : 'none'}` }} />
<PreviewTextBox ref={previewRef} style={{ display: `${tabIndex === 1 ? 'block' : 'none'}`, width: '50%' }} />
<input type="file" id="fileUpload" style={{ display: 'none' }} />
{followList.length !== 0 && (
<UserDropDown
Expand Down
3 changes: 0 additions & 3 deletions client/public/announce.svg

This file was deleted.

3 changes: 0 additions & 3 deletions client/public/home.svg

This file was deleted.

4 changes: 1 addition & 3 deletions client/public/ico_comment.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/public/ico_home.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/public/ico_notification.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/public/ico_search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/public/ico_setting.svg
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 client/public/moheyum.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 0 additions & 21 deletions client/public/profile_img.svg

This file was deleted.

3 changes: 0 additions & 3 deletions client/public/search.svg

This file was deleted.

Loading

0 comments on commit f64e745

Please sign in to comment.