Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit620fa6b

Browse files
committed
refactor(ArticleHeader): clean up
1 parent68bf38b commit620fa6b

File tree

4 files changed

+66
-39
lines changed

4 files changed

+66
-39
lines changed

‎components/ArticleHeader/index.js‎

Lines changed: 58 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import TimeAgo from 'timeago-react'
1111

1212
import{ICON_CMD}from'../../config'
1313

14+
importMaybefrom'../Maybe'
15+
1416
import{
1517
Wrapper,
1618
UserInfo,
@@ -32,7 +34,13 @@ import { makeDebugger, TYPE, THREAD } from '../../utils'
3234
constdebug=makeDebugger('c:ArticleHeader:index')
3335
/* eslint-enable no-unused-vars */
3436

35-
constArticleHeader=({ thread, data, onReaction})=>(
37+
constArticleHeader=({
38+
thread,
39+
data,
40+
onReaction,
41+
showFavorite,
42+
showStar,
43+
})=>(
3644
<Wrapper>
3745
<UserInfo>
3846
<Avatarsrc={data.author.avatar}alt="user_avatar"/>
@@ -44,40 +52,50 @@ const ArticleHeader = ({ thread, data, onReaction }) => (
4452
</div>
4553
</UserInfo>
4654
<ReactionWrapper>
47-
<Reaction>
48-
<ReactionAction
49-
onClick={onReaction.bind(
50-
this,
51-
thread,
52-
TYPE.FAVORITE,
53-
data.viewerHasFavorited,
54-
data
55-
)}
56-
>
57-
<CollectIconsrc={`${ICON_CMD}/uncollect.svg`}/>
58-
<ReactionName>
59-
{data.viewerHasFavorited ?<span>已收藏</span> :<span>收藏</span>}
60-
</ReactionName>
61-
</ReactionAction>
62-
<ReactionUserNum>{data.favoritedCount}</ReactionUserNum>
63-
<Divider/>
64-
</Reaction>
65-
<Reaction>
66-
<ReactionAction
67-
onClick={onReaction.bind(
68-
this,
69-
thread,
70-
TYPE.STAR,
71-
data.viewerHasStarred,
72-
data
73-
)}
74-
>
75-
<LikeIconsrc={`${ICON_CMD}/like.svg`}/>
76-
<ReactionName></ReactionName>
77-
</ReactionAction>
78-
<ReactionUserNum>{data.starredCount}</ReactionUserNum>
79-
<Divider/>
80-
</Reaction>
55+
<Maybetext={showFavorite}>
56+
<Reaction>
57+
<ReactionAction
58+
onClick={onReaction.bind(
59+
this,
60+
thread,
61+
TYPE.FAVORITE,
62+
data.viewerHasFavorited,
63+
data
64+
)}
65+
>
66+
<CollectIconsrc={`${ICON_CMD}/uncollect.svg`}/>
67+
<ReactionName>
68+
{data.viewerHasFavorited ?(
69+
<span>已收藏</span>
70+
) :(
71+
<span>收藏</span>
72+
)}
73+
</ReactionName>
74+
</ReactionAction>
75+
<ReactionUserNum>{data.favoritedCount}</ReactionUserNum>
76+
<Divider/>
77+
</Reaction>
78+
</Maybe>
79+
80+
<Maybetest={showStar}>
81+
<Reaction>
82+
<ReactionAction
83+
onClick={onReaction.bind(
84+
this,
85+
thread,
86+
TYPE.STAR,
87+
data.viewerHasStarred,
88+
data
89+
)}
90+
>
91+
<LikeIconsrc={`${ICON_CMD}/like.svg`}/>
92+
<ReactionName></ReactionName>
93+
</ReactionAction>
94+
<ReactionUserNum>{data.starredCount}</ReactionUserNum>
95+
<Divider/>
96+
</Reaction>
97+
</Maybe>
98+
8199
<Reaction>
82100
<ReactionAction>
83101
<ReactionName>浏览:</ReactionName>
@@ -110,11 +128,16 @@ ArticleHeader.propTypes = {
110128
// handler
111129
}).isRequired,
112130
onReaction:PropTypes.func,
131+
// ui
132+
showFavorite:PropTypes.bool,
133+
showStar:PropTypes.bool,
113134
}
114135

115136
ArticleHeader.defaultProps={
116137
thread:THREAD.POST,
117138
onReaction:debug,
139+
showFavorite:true,
140+
showStar:true,
118141
}
119142

120143
exportdefaultArticleHeader

‎containers/ArticleViwer/JobViewer.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const JobViewer = ({ data, loading, accountInfo }) => (
1515
data={data}
1616
author={data.author}
1717
onReaction={logic.onReaction}
18-
THREAD={THREAD.JOB}
18+
thread={THREAD.JOB}
19+
showStar={false}
1920
/>
2021
<Body
2122
data={data}

‎containers/ArticleViwer/index.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ const Viwer = ({ type, data, loading, accountInfo }) => {
3030
<JobViewerdata={data}loading={loading}accountInfo={accountInfo}/>
3131
)
3232
}
33-
case'typewriter':{
34-
return<div>typewriter</div>
35-
}
3633
default:{
3734
return<div>default</div>
3835
}

‎containers/ArticleViwer/logic.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ let store = null
2828
letsub$=null
2929

3030
exportfunctiononReaction(thread,action,userDid,{ id}){
31+
/*
32+
debug('onReaction thread: ', thread)
33+
debug('onReaction action: ', action)
34+
debug('onReaction userDid: ', userDid)
35+
debug('onReaction id: ', id)
36+
*/
3137
constargs={ id, thread, action}
3238

3339
returnuserDid

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp