Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit f3ce6e8

Browse files
authored
style(comments): some idea on header & footer (#1057)
* style(comments): some idea on header & footer * style(comments): adjust upvote look
1 parent c173b61 commit f3ce6e8

File tree

15 files changed

+154
-117
lines changed

15 files changed

+154
-117
lines changed
Lines changed: 1 addition & 0 deletions
Loading

src/containers/unit/Comments/Comment/Actions.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import React from 'react'
22

33
import type { TAccount, TComment } from '@/spec'
44

5+
import DotDivider from '@/components/DotDivider'
6+
import { SpaceGrow } from '@/components/Common'
7+
58
import { Wrapper, ReplyAction } from '../styles/comment/actions'
69
import { openUpdateEditor, openReplyEditor, onDelete } from '../logic'
710

@@ -23,6 +26,14 @@ const Actions: React.FC<TProps> = ({ data, accountInfo }) => {
2326
return (
2427
<Wrapper>
2528
<ReplyAction onClick={() => openReplyEditor(data)}>回复</ReplyAction>
29+
<SpaceGrow />
30+
<ReplyAction>分享</ReplyAction>
31+
<DotDivider radius={3} space={6} />
32+
<ReplyAction>引用</ReplyAction>
33+
<DotDivider radius={3} space={6} />
34+
<ReplyAction>折叠</ReplyAction>
35+
<DotDivider radius={3} space={6} />
36+
<ReplyAction>举报</ReplyAction>
2637
</Wrapper>
2738
)
2839
}

src/containers/unit/Comments/Comment/DesktopView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Global } from '@/utils'
66

77
import MarkDownRender from '@/components/MarkDownRender'
88

9-
import UpInfo from './UpInfo'
9+
import Upvote from './Upvote'
1010
import Header from './Header'
1111
import ReplyBar from './ReplyBar'
1212
import DeleteMask from './DeleteMask'
@@ -37,7 +37,7 @@ const Comment: React.FC<TProps> = ({ data, tobeDeleteId, accountInfo }) => {
3737
<Wrapper>
3838
<DeleteMask show={data.id === tobeDeleteId} />
3939
<CommentWrapper tobeDelete={data.id === tobeDeleteId}>
40-
<UpInfo data={data} />
40+
<Upvote data={data} />
4141

4242
<CommentBodyInfo onMouseUp={getSelection}>
4343
<Header data={data} />
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react'
2+
3+
import { ICON } from '@/config'
4+
5+
import { Wrapper, SelectorIcon } from '../styles/comment/emotion'
6+
7+
const Emotion: React.FC = () => (
8+
<Wrapper>
9+
<SelectorIcon src={`${ICON}/emotion/alien-fill.svg`} />
10+
</Wrapper>
11+
)
12+
13+
export default React.memo(Emotion)

src/containers/unit/Comments/Comment/Footer.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React from 'react'
2-
import TimeAgo from 'timeago-react'
32

43
import type { TAccount, TComment } from '@/spec'
5-
import { SpaceGrow } from '@/components/Common'
4+
65
import DotDivider from '@/components/DotDivider'
6+
import { SpaceGrow } from '@/components/Common'
77

8+
import Emotion from './Emotion'
89
import Actions from './Actions'
910

10-
import { Wrapper, PublishDateWrapper } from '../styles/comment/footer'
11+
import { Wrapper } from '../styles/comment/footer'
1112

1213
type TProps = {
1314
data: TComment
@@ -16,9 +17,7 @@ type TProps = {
1617

1718
const Footer: React.FC<TProps> = ({ data, accountInfo }) => (
1819
<Wrapper>
19-
<PublishDateWrapper>
20-
<TimeAgo datetime={data.insertedAt} locale="zh_CN" />
21-
</PublishDateWrapper>
20+
<Emotion />
2221
<DotDivider radius={3} space={6} />
2322
<Actions data={data} accountInfo={accountInfo} />
2423
<SpaceGrow />

src/containers/unit/Comments/Comment/Header.tsx

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,23 @@
11
import React from 'react'
2-
import { forEach, clone, pluck } from 'ramda'
2+
import TimeAgo from 'timeago-react'
33

44
import type { TComment } from '@/spec'
55

66
import ImgFallback from '@/components/ImgFallback'
7-
import AvatarsRow from '@/components/AvatarsRow'
87
import DotDivider from '@/components/DotDivider'
98

109
import {
1110
Wrapper,
1211
FloorNum,
12+
CreateDate,
1313
Avatar,
1414
HeaderBaseInfo,
15-
CommentUserName,
16-
CommentHeaderFirst,
17-
ReplyUsers,
18-
ReplyTitle,
15+
BaseInfo,
16+
UserName,
17+
AuthorTag,
18+
ShortIntro,
1919
} from '../styles/comment/header'
2020

21-
import { previewReply } from '../logic'
22-
23-
const getAuthors = (comment) => {
24-
/* eslint-disable no-return-assign */
25-
const replies = forEach((reply) => {
26-
/* @ts-ignore */
27-
return (reply.author.extraId = reply.id)
28-
}, clone(comment.replies))
29-
/* eslint-enable */
30-
31-
/* @ts-ignore */
32-
return pluck('author', replies)
33-
}
34-
3521
type TProps = {
3622
data: TComment
3723
}
@@ -44,23 +30,18 @@ const CommentHeader: React.FC<TProps> = ({ data }) => {
4430
fallback={<ImgFallback user={data.author} size={22} right={10} />}
4531
/>
4632
<HeaderBaseInfo>
47-
<CommentHeaderFirst>
48-
<CommentUserName>
49-
{data.author.nickname}
50-
<DotDivider radius={3} space={10} />
51-
<FloorNum>#{data.floor}</FloorNum>
52-
</CommentUserName>
53-
{data.repliesCount !== 0 && (
54-
<ReplyUsers>
55-
<ReplyTitle>收到回复:</ReplyTitle>
56-
<AvatarsRow
57-
users={getAuthors(data)}
58-
onUserSelect={previewReply}
59-
total={data.repliesCount}
60-
/>
61-
</ReplyUsers>
62-
)}
63-
</CommentHeaderFirst>
33+
<BaseInfo>
34+
<UserName>
35+
<div>{data.author.nickname}</div>
36+
<AuthorTag>作者</AuthorTag>
37+
</UserName>
38+
<FloorNum>#{data.floor}</FloorNum>
39+
<DotDivider radius={3} space={10} />
40+
<CreateDate>
41+
<TimeAgo datetime={data.insertedAt} locale="zh_CN" />
42+
</CreateDate>
43+
</BaseInfo>
44+
<ShortIntro>1 号员工 / CEO at coderplanets</ShortIntro>
6445
</HeaderBaseInfo>
6546
</Wrapper>
6647
)

src/containers/unit/Comments/Comment/MobileView/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react'
33
import { Br } from '@/components/Common'
44
import MarkDownRender from '@/components/MarkDownRender'
55

6-
import UpInfo from '../UpInfo'
6+
import Upvote from '../Upvote'
77
import ReplyBar from '../ReplyBar'
88
import DeleteMask from '../DeleteMask'
99
import Footer from '../Footer'
@@ -40,7 +40,7 @@ const MobileView = ({ data, tobeDeleteId, accountInfo }) => {
4040
<Footer data={data} accountInfo={accountInfo} />
4141
</CommentBodyInfo>
4242
</CommentWrapper>
43-
<UpInfo data={data} />
43+
<Upvote data={data} />
4444
</Wrapper>
4545
)
4646
}

src/containers/unit/Comments/Comment/UpInfo.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react'
2+
3+
import type { TComment } from '@/spec'
4+
import { ICON } from '@/config'
5+
import { prettyNum } from '@/utils'
6+
7+
import { Wrapper, InnerWrapper, Icon } from '../styles/comment/upvote'
8+
9+
import { toggleLikeComment } from '../logic'
10+
11+
type TProps = {
12+
data: TComment
13+
}
14+
15+
const Upvote: React.FC<TProps> = ({ data }) => (
16+
<Wrapper>
17+
<InnerWrapper>
18+
<div onClick={() => toggleLikeComment(data)}>
19+
<Icon
20+
src={`${ICON}/shape/upvote.svg`}
21+
viewerDid={data.viewerHasLiked}
22+
/>
23+
</div>
24+
<div>{prettyNum(data.likesCount)}</div>
25+
</InnerWrapper>
26+
</Wrapper>
27+
)
28+
29+
export default React.memo(Upvote)

src/containers/unit/Comments/styles/comment/actions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { theme, css } from '@/utils'
44
// import { CommentBodyInfo } from './index'
55

66
export const Wrapper = styled.div`
7-
${css.flex()};
7+
${css.flex('align-center')};
8+
width: 100%;
89
910
${css.media.mobile`
1011
font-size: 12px;
@@ -13,7 +14,6 @@ export const Wrapper = styled.div`
1314
export const ReplyAction = styled.div`
1415
${css.flex()};
1516
color: ${theme('comment.action')};
16-
margin-right: 12px;
1717
cursor: pointer;
1818
font-weight: bold;
1919
opacity: 1;

0 commit comments

Comments
 (0)