Skip to content

Commit 2acb3b8

Browse files
committed
created PostAction button
1 parent 56023bd commit 2acb3b8

File tree

6 files changed

+43
-4
lines changed

6 files changed

+43
-4
lines changed

velog-frontend/src/components/base/UserMenu/UserMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const UserMenu = ({ onClick, onLogout, username }: Props) => {
2121
<UserMenuItem to={`/@${username}`}>내 벨로그</UserMenuItem>
2222
<div className="separator" />
2323
<UserMenuItem to="/write">새 글 작성</UserMenuItem>
24-
<UserMenuItem>임시 글</UserMenuItem>
24+
<UserMenuItem to="/saves">임시 글</UserMenuItem>
2525
<div className="separator" />
2626
<UserMenuItem>설정</UserMenuItem>
2727
<UserMenuItem onClick={onLogout}>로그아웃</UserMenuItem>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// @flow
2+
import React from 'react';
3+
import './PostActionButtons.scss';
4+
5+
type Props = {};
6+
7+
const PostActionButtons = (props: Props) => (
8+
<div className="PostActionButtons">
9+
<button className="btn">수정</button>
10+
<button className="btn">삭제</button>
11+
</div>
12+
);
13+
14+
export default PostActionButtons;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@import 'utils';
2+
.PostActionButtons {
3+
margin-right: -0.4rem;
4+
margin-top: -2rem;
5+
display: flex;
6+
justify-content: flex-end;
7+
.btn {
8+
font-size: 0.875rem;
9+
color: $oc-gray-6;
10+
font-weight: 500;
11+
padding: 0.125rem 0.5rem;
12+
cursor: pointer;
13+
&:hover {
14+
color: $oc-violet-5;
15+
}
16+
}
17+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// @flow
2+
export { default } from './PostActionButtons';

velog-frontend/src/components/post/PostHead/PostHead.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Categories } from 'store/modules/posts';
55
import PostLikeButton from 'components/post/PostLikeButton';
66
import { Link } from 'react-router-dom';
77
import defaultThumbnail from 'static/images/default_thumbnail.png';
8+
import PostActionButtons from '../PostActionButtons';
89
import './PostHead.scss';
910

1011
type Props = {
@@ -18,10 +19,11 @@ type Props = {
1819
},
1920
likes: number,
2021
liked: boolean,
22+
ownPost: boolean,
2123
onToggleLike: () => void,
2224
};
2325

24-
const PostHead = ({ title, categories, user, likes, liked, onToggleLike }: Props) => {
26+
const PostHead = ({ title, categories, user, likes, liked, ownPost, onToggleLike }: Props) => {
2527
const userLink = `/@${user.username}`;
2628

2729
return (
@@ -44,6 +46,7 @@ const PostHead = ({ title, categories, user, likes, liked, onToggleLike }: Props
4446
<PostLikeButton onClick={onToggleLike} liked={liked} likes={likes} />
4547
</div>
4648
<div className="separator" />
49+
{ownPost && <PostActionButtons />}
4750
</div>
4851
);
4952
};

velog-frontend/src/containers/post/PostViewer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type Props = {
1616
toc: ?(TocItem[]),
1717
activeHeading: ?string,
1818
likeInProcess: boolean,
19+
currentUsername: ?string,
1920
};
2021

2122
class PostViewer extends Component<Props> {
@@ -56,7 +57,7 @@ class PostViewer extends Component<Props> {
5657
}
5758

5859
render() {
59-
const { post, toc, activeHeading } = this.props;
60+
const { post, toc, activeHeading, username, currentUsername } = this.props;
6061
const { onSetToc, onActivateHeading } = this;
6162
if (!post) return null;
6263

@@ -71,6 +72,7 @@ class PostViewer extends Component<Props> {
7172
likes={post.likes}
7273
liked={post.liked}
7374
onToggleLike={this.onToggleLike}
75+
ownPost={currentUsername === username}
7476
/>
7577
<PostContent
7678
thumbnail={post.thumbnail}
@@ -85,7 +87,8 @@ class PostViewer extends Component<Props> {
8587
}
8688

8789
export default connect(
88-
({ posts, pender }: State) => ({
90+
({ posts, pender, user }: State) => ({
91+
currentUsername: user.user && user.user.username,
8992
post: posts.post,
9093
toc: posts.toc,
9194
activeHeading: posts.activeHeading,

0 commit comments

Comments
 (0)