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.

Commit6bf47ad

Browse files
committed
Merge branch 'reaction-header' into dev
2 parents6dc546e +b27f50b commit6bf47ad

File tree

27 files changed

+218
-208
lines changed

27 files changed

+218
-208
lines changed

‎components/ArticleHeader/index.js‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ import {
1616
Wrapper,
1717
ReactionWrapper,
1818
Reaction,
19+
PlainAction,
1920
ReactionAction,
2021
ReactionName,
2122
CollectIcon,
2223
LikeIcon,
24+
PlainUserNum,
2325
ReactionUserNum,
2426
Divider,
2527
}from'./styles'
@@ -57,6 +59,7 @@ const ArticleHeader = ({
5759
<Maybetext={showFavorite}>
5860
<Reaction>
5961
<ReactionAction
62+
active={data.viewerHasFavorited}
6063
onClick={onReaction.bind(
6164
this,
6265
thread,
@@ -82,6 +85,7 @@ const ArticleHeader = ({
8285
<Maybetest={showStar}>
8386
<Reaction>
8487
<ReactionAction
88+
active={data.viewerHasStarred}
8589
onClick={onReaction.bind(
8690
this,
8791
thread,
@@ -91,18 +95,20 @@ const ArticleHeader = ({
9195
)}
9296
>
9397
<LikeIconsrc={`${ICON_CMD}/like.svg`}/>
94-
<ReactionName></ReactionName>
98+
<ReactionName>
99+
{data.viewerHasStarred ?<span>已赞</span> :<span></span>}
100+
</ReactionName>
95101
</ReactionAction>
96102
<ReactionUserNum>{data.starredCount}</ReactionUserNum>
97103
<Divider/>
98104
</Reaction>
99105
</Maybe>
100106

101107
<Reaction>
102-
<ReactionAction>
108+
<PlainAction>
103109
<ReactionName>浏览:</ReactionName>
104-
</ReactionAction>
105-
<ReactionUserNum>{data.views}</ReactionUserNum>
110+
</PlainAction>
111+
<PlainUserNum>{data.views}</PlainUserNum>
106112
</Reaction>
107113
</ReactionWrapper>
108114
</Wrapper>

‎components/ArticleHeader/styles/index.js‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,31 @@ export const Reaction = styled.div`
2828
align-items: center;
2929
display: flex;
3030
`
31-
exportconstReactionAction=styled.div`
31+
exportconstPlainAction=styled.div`
3232
display: flex;
3333
align-items: center;
34-
padding: 2px 3px;
34+
border-radius: 5px;
35+
`
36+
exportconstReactionAction=styled(PlainAction)`
37+
background-color:${({ active})=>
38+
active ?theme('article.reactionHoverBg') :''};
39+
padding:${({ active})=>(active ?'2px 5px' :'2px 3px')};
3540
&:hover {
3641
cursor: pointer;
3742
font-weight: bold;
3843
background:${theme('article.reactionHoverBg')};
39-
border-radius: 6px;
4044
}
4145
`
4246
exportconstReactionName=styled.div`
4347
color:${theme('article.reactionTitle')};
4448
font-size: 0.9rem;
4549
`
46-
exportconstReactionUserNum=styled.div`
50+
exportconstPlainUserNum=styled.div`
4751
color:${theme('article.reactionTitle')};
4852
font-size: 1rem;
4953
margin-left: 2px;
50-
54+
`
55+
exportconstReactionUserNum=styled(PlainUserNum)`
5156
&:hover {
5257
cursor: pointer;
5358
text-decoration: underline;

‎components/ContentFilter/FilterPanel.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import VideoSourceFilter from './VideoSourceFilter'
1717

1818
import{THREAD}from'../../utils'
1919

20-
constFilterPanel=({ activeFilter, onSelect})=>{
21-
constthread=THREAD.VIDEO
20+
constFilterPanel=({ thread, activeFilter, onSelect})=>{
2221
switch(thread){
2322
caseTHREAD.POST:{
2423
return(

‎components/ContentFilter/index.js‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
importReactfrom'react'
88
importPropTypesfrom'prop-types'
99
import{Button,Tag}from'antd'
10+
importRfrom'ramda'
1011

1112
import{ICON_CMD}from'../../config'
1213

1314
importPopoverfrom'../Popover'
1415
import{Wrapper,InnerBtnWrapper,FilterIcon}from'./styles'
1516
importFilterPanelfrom'./FilterPanel'
1617

17-
import{makeDebugger,isEmptyValue}from'../../utils'
18+
import{makeDebugger,isEmptyValue,THREAD}from'../../utils'
1819
/* eslint-disable no-unused-vars */
1920
constdebug=makeDebugger('c:ContentFilter:index')
2021
/* eslint-enable no-unused-vars */
@@ -39,12 +40,18 @@ const FilterTag = ({ onSelect, active, type }) =>
3940
</Tag>
4041
)
4142

42-
constContentFilter=({ activeFilter, onSelect})=>(
43+
constContentFilter=({thread,activeFilter, onSelect})=>(
4344
<Wrapper>
4445
<Popover
4546
placement="bottomLeft"
4647
trigger="click"
47-
content={<FilterPanelonSelect={onSelect}activeFilter={activeFilter}/>}
48+
content={
49+
<FilterPanel
50+
thread={thread}
51+
onSelect={onSelect}
52+
activeFilter={activeFilter}
53+
/>
54+
}
4855
>
4956
<Buttonsize="small"type="primary"ghost>
5057
<InnerBtnWrapper>
@@ -72,6 +79,7 @@ ContentFilter.propTypes = {
7279
wordLength:PropTypes.string,
7380
}),
7481
onSelect:PropTypes.func.isRequired,
82+
thread:PropTypes.oneOf(R.values(THREAD)),
7583
}
7684

7785
ContentFilter.defaultProps={
@@ -80,6 +88,7 @@ ContentFilter.defaultProps = {
8088
sort:'',
8189
wordLength:'',
8290
},
91+
thread:THREAD.POST,
8392
}
8493

8594
exportdefaultContentFilter

‎components/ContentFilter/styles/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const FilterIcon = styled(Img)`
2121
`
2222
exportconstFiltrPanelWrapper=styled.div`
2323
display: flex;
24-
min-width:280px;
24+
min-width:200px;
2525
padding: 12px;
2626
`
2727
exportconstColumnWrapper=styled.div`

‎components/RepoItem/styles/index.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export const Wrapper = styled.article`
1010
1111
padding-left: 8px;
1212
padding-right: 8px;
13-
padding-top:22px;
14-
padding-bottom:22px;
13+
padding-top:18px;
14+
padding-bottom:18px;
1515
border-radius: 4px;
1616
border-bottom: 1px solid;
1717
border-bottom-color:${theme('thread.articleSpliter')};

‎containers/ArticleViwer/logic.js‎

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
importRfrom'ramda'
12
importSR71from'../../utils/network/sr71'
23

34
import{
@@ -28,13 +29,12 @@ let store = null
2829
letsub$=null
2930

3031
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-
*/
37-
constargs={ id, thread, action}
32+
/* debug('onReaction thread: ', thread) */
33+
/* debug('onReaction action: ', action) */
34+
// debug('onReaction userDid: ', store.isLogin)
35+
/* debug('onReaction id: ', id) */
36+
37+
constargs={ id,thread:R.toUpper(thread), action}
3838

3939
returnuserDid
4040
?sr71$.mutate(S.undoReaction,args)
@@ -62,21 +62,23 @@ function loadJob({ id }) {
6262
constuserHasLogin=store.isLogin
6363
constvariables={ id, userHasLogin}
6464
loading()
65+
debug('loadJob variables: ',variables)
6566
sr71$.query(S.job,variables)
6667
}
6768

68-
functionreloadReactions(article){
69-
constvariables={
70-
id:article.id,
69+
functionreloadReactions({ id}){
70+
switch(store.activeThread){
71+
caseTHREAD.JOB:{
72+
returnsr71$.query(S.jobReactionRes,{ id})
73+
}
74+
default:{
75+
returnsr71$.query(S.postReactionRes,{ id})
76+
}
7177
}
72-
debug('reloadReactions: ',variables)
73-
74-
sr71$.query(S.reactionResult,variables)
7578
}
7679

7780
exportfunctiononEdit(thread){
7881
/* debug('onEdit', store.viewingPost) */
79-
debug('onEdit viewingData: ',store.viewingData)
8082
switch(thread){
8183
caseTHREAD.POST:{
8284
returndispatchEvent(EVENT.PREVIEW_OPEN,{
@@ -118,44 +120,38 @@ const openAttachment = att => {
118120
// ###############################
119121
// Data & Error handlers
120122
// ###############################
121-
122-
functioncontentLoaded(content){
123-
store.setViewing(content)
124-
loading(false)
125-
}
126-
127123
constDataSolver=[
128124
{
129125
match:asyncRes('reaction'),
130126
action:({ reaction})=>{
131-
// TODO: should be trigger
132127
debug('get reaction: ',reaction)
133-
reloadReactions(reaction)
128+
returnreloadReactions(reaction)
134129
},
135130
},
136131
{
137132
match:asyncRes('undoReaction'),
138-
action:({ undoReaction})=>{
139-
debug('get undoReaction: ',undoReaction)
140-
/* const info = res[TYPE.UNDO_REACTION] */
141-
reloadReactions(undoReaction)
142-
},
133+
action:({ undoReaction})=>reloadReactions(undoReaction),
143134
},
144135
{
145136
match:asyncRes(EVENT.PREVIEW_CLOSED),
146137
action:()=>{
147138
sr71$.stop()
148-
/* store.load(TYPE.POST, {}) */
149139
loading(false)
150140
},
151141
},
152142
{
153143
match:asyncRes('post'),
154-
action:({ post})=>contentLoaded({ post}),
144+
action:({ post})=>{
145+
store.setViewing({post:R.merge(store.viewingData,post)})
146+
loading(false)
147+
},
155148
},
156149
{
157150
match:asyncRes('job'),
158-
action:({ job})=>contentLoaded({ job}),
151+
action:({ job})=>{
152+
store.setViewing({job:R.merge(store.viewingData,job)})
153+
loading(false)
154+
},
159155
},
160156
]
161157

‎containers/ArticleViwer/schema.js‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,19 @@ const post = gql`
2222
}
2323
}
2424
`
25-
constjob=gql`
25+
constpostReactionRes=gql`
2626
query($id: ID!) {
27+
post(id: $id) {
28+
id
29+
favoritedCount
30+
starredCount
31+
viewerHasFavorited
32+
viewerHasStarred
33+
}
34+
}
35+
`
36+
constjob=gql`
37+
query($id: ID!, $userHasLogin: Boolean!) {
2738
job(id: $id) {
2839
id
2940
title
@@ -40,22 +51,20 @@ const job = gql`
4051
linkAddr
4152
insertedAt
4253
updatedAt
54+
favoritedCount
55+
viewerHasFavorited @include(if: $userHasLogin)
4356
}
4457
}
4558
`
46-
constreactionResult=gql`
59+
constjobReactionRes=gql`
4760
query($id: ID!) {
48-
post(id: $id) {
61+
job(id: $id) {
4962
id
50-
title
5163
favoritedCount
52-
starredCount
5364
viewerHasFavorited
54-
viewerHasStarred
5565
}
5666
}
5767
`
58-
5968
constreaction=gql`
6069
mutation($id: ID!, $action: String!, $thread: CmsThread!) {
6170
reaction(id: $id, action: $action, thread: $thread) {
@@ -74,11 +83,12 @@ const undoReaction = gql`
7483

7584
constschema={
7685
post,
86+
postReactionRes,
7787
job,
88+
jobReactionRes,
7889
// viewerReactions,
7990
reaction,
8091
undoReaction,
81-
reactionResult,
8292
}
8393

8494
exportdefaultschema

‎containers/ArticleViwer/store.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ const ArticleViwerStore = t
3838
getviewingData(){
3939
returnself.root.viewingData
4040
},
41+
getactiveThread(){
42+
const{ activeThread}=self.root.viewing
43+
returnactiveThread
44+
},
4145
}))
4246
.actions(self=>({
4347
setViewing(sobj){

‎containers/JobsThread/index.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class JobsThreadContainer extends React.Component {
104104
<Maybetest={totalCount!==0}>
105105
<FilterWrappershow={curView===TYPE.RESULT}>
106106
<ContentFilter
107+
thread={THREAD.JOB}
107108
onSelect={logic.onFilterSelect}
108109
activeFilter={filtersData}
109110
/>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp