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.

Commit207e4a7

Browse files
committed
feat(JobPage): add JobPage with refactor whole-chain
1 parent779e104 commit207e4a7

File tree

32 files changed

+584
-164
lines changed

32 files changed

+584
-164
lines changed

‎containers/PostBanner/ReactionNumbers.js‎renamed to ‎components/ContentBanner/ReactionNumbers.js‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
NumberItem,
99
}from'./styles/reaction_numbers'
1010

11-
import{prettyNum}from'../../utils'
11+
import{prettyNum,numberWithCommas}from'../../utils'
1212

1313
constReactionNumbers=({data:{ views, favoritedCount, starredCount}})=>(
1414
<NumbersInfo>
@@ -17,15 +17,21 @@ const ReactionNumbers = ({ data: { views, favoritedCount, starredCount } }) => (
1717
<NumberItemdead>{prettyNum(views)}</NumberItem>
1818
</NumberSection>
1919
<NumberDivider/>
20-
<NumberSection>
21-
<NumberTitle>喜欢</NumberTitle>
22-
<NumberItem>{prettyNum(starredCount)}</NumberItem>
23-
</NumberSection>
24-
<NumberDivider/>
25-
<NumberSection>
26-
<NumberTitle>收藏</NumberTitle>
27-
<NumberItem>{prettyNum(favoritedCount)}</NumberItem>
28-
</NumberSection>
20+
{starredCount>=0 ?(
21+
<React.Fragment>
22+
<NumberSection>
23+
<NumberTitle>喜欢</NumberTitle>
24+
<NumberItem>{numberWithCommas(starredCount)}</NumberItem>
25+
</NumberSection>
26+
<NumberDivider/>
27+
</React.Fragment>
28+
) :null}
29+
{favoritedCount>=0 ?(
30+
<NumberSection>
31+
<NumberTitle>收藏</NumberTitle>
32+
<NumberItem>{numberWithCommas(favoritedCount)}</NumberItem>
33+
</NumberSection>
34+
) :null}
2935
{/*
3036
<NumberDivider />
3137
<NumberSection>

‎components/ContentBanner/index.js‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
*
3+
* ContentBanner
4+
*
5+
*/
6+
7+
importReactfrom'react'
8+
importPropTypesfrom'prop-types'
9+
importRfrom'ramda'
10+
importTimeAgofrom'timeago-react'
11+
12+
importDotDividerfrom'../DotDivider'
13+
14+
import{
15+
BannerContainer,
16+
BannerContentWrapper,
17+
PostBrief,
18+
Title,
19+
Desc,
20+
MarkTag,
21+
}from'./styles'
22+
23+
importReactionNumbersfrom'./ReactionNumbers'
24+
25+
import{makeDebugger}from'../../utils'
26+
27+
/* eslint-disable no-unused-vars */
28+
constdebug=makeDebugger('c:ContentBanner:index')
29+
/* eslint-enable no-unused-vars */
30+
31+
constContentBanner=({ data})=>(
32+
<BannerContainer>
33+
{R.isNil(data.id) ?null :(
34+
<BannerContentWrapper>
35+
<PostBrief>
36+
<Title>{data.title}</Title>
37+
<Desc>
38+
<MarkTag>精华帖</MarkTag>
39+
<TimeAgodatetime={data.insertedAt}locale="zh_CN"/>
40+
<DotDivider/>
41+
字数:{data.length}
42+
</Desc>
43+
</PostBrief>
44+
<ReactionNumbersdata={data}/>
45+
</BannerContentWrapper>
46+
)}
47+
</BannerContainer>
48+
)
49+
50+
ContentBanner.propTypes={
51+
data:PropTypes.shape({
52+
id:PropTypes.string,
53+
title:PropTypes.string,
54+
insertedAt:PropTypes.string,
55+
updatedAt:PropTypes.string,
56+
views:PropTypes.number,
57+
favoritedCount:PropTypes.number,
58+
starredCount:PropTypes.number,
59+
viewerHasFavorited:PropTypes.bool,
60+
viewerHasStarred:PropTypes.bool,
61+
}),
62+
}
63+
64+
ContentBanner.defaultProps={
65+
data:{
66+
id:'',
67+
title:'',
68+
views:0,
69+
favoritedCount:-1,
70+
starredCount:-1,
71+
viewerHasFavorited:false,
72+
viewerHasStarred:false,
73+
},
74+
}
75+
76+
exportdefaultContentBanner
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
importstyledfrom'styled-components'
2+
3+
import{theme}from'../../../utils'
4+
5+
exportconstBaseBanner=styled.nav`
6+
position: relative;
7+
min-height: 140px;
8+
border-bottom: 1px solid tomato;
9+
display: flex;
10+
flex-direction: column;
11+
justify-content: center;
12+
background:${theme('banner.bg')};
13+
border-bottom:${theme('banner.spliter')};
14+
@media (max-height: 800px) {
15+
min-height: 130px;
16+
}
17+
`
18+
exportconstBaseBannerContent=styled.div`
19+
display: flex;
20+
margin-left: 8%;
21+
margin-right: 8%;
22+
`
23+
exportconstBannerContainer=styled(BaseBanner)`
24+
height: 100px;
25+
min-height: 100px;
26+
`
27+
exportconstBannerContentWrapper=styled(BaseBannerContent)`
28+
display: flex;
29+
`
30+
exportconstPostBrief=styled.div`
31+
width: 60%;
32+
flex-grow: 1;
33+
display: flex;
34+
flex-direction: column;
35+
`
36+
37+
exportconstTitle=styled.div`
38+
font-size: 1.6em;
39+
color:${theme('thread.articleTitle')};
40+
width: 100%;
41+
white-space: nowrap;
42+
overflow: hidden;
43+
text-overflow: ellipsis;
44+
`
45+
exportconstDesc=styled.div`
46+
display: flex;
47+
align-items: center;
48+
margin-top: 5px;
49+
display: flex;
50+
font-size: 0.9rem;
51+
color:${theme('thread.articleDigest')};
52+
`
53+
exportconstAvatar=styled.img`
54+
width: 25px;
55+
height: 25px;
56+
border-radius: 100%;
57+
margin-right: 5px;
58+
`
59+
exportconstMarkTag=styled.div`
60+
font-size: 0.8em;
61+
padding: 1px 8px;
62+
border-radius: 3px;
63+
border: 1px solid;
64+
border-color: tomato;
65+
color: tomato;
66+
margin-right: 8px;
67+
`

‎containers/PostBanner/styles/reaction_numbers.js‎renamed to ‎components/ContentBanner/styles/reaction_numbers.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export const NumbersWrapper = styled.div`
77
text-align: center;
88
margin-top: -2.1rem;
99
`
10-
1110
exportconstNumbersInfo=styled(NumbersWrapper)`
1211
margin-top: 0;
1312
`
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// import React from 'react'
2+
// import { shallow } from 'enzyme'
3+
4+
// import ContentBanner from '../index'
5+
6+
describe('TODO <ContentBanner />',()=>{
7+
it('Expect to have unit tests specified',()=>{
8+
expect(true).toEqual(true)
9+
})
10+
})

‎components/index.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export { default as VideoItem } from './VideoItem'
1818

1919
// Utils component
2020
export{withGuardian}from'./HOC'
21+
export{defaultasContentBanner}from'./ContentBanner'
2122
export{defaultasArticleHeader}from'./ArticleHeader'
2223
export{defaultasMaybe}from'./Maybe'
2324
export{defaultasDotDivider}from'./DotDivider'

‎containers/Comments/schema.js‎

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
importgqlfrom'graphql-tag'
2+
import{F}from'../schemas'
23

34
constpagedComments=gql`
45
query pagedComments(
@@ -9,44 +10,26 @@ const pagedComments = gql`
910
) {
1011
pagedComments(id: $id, filter: $filter, thread: $thread) {
1112
entries {
12-
id
13-
body
14-
floor
15-
author {
16-
id
17-
nickname
18-
avatar
19-
}
13+
${F.comment}
2014
viewerHasLiked @include(if: $userHasLogin)
2115
viewerHasDisliked @include(if: $userHasLogin)
2216
replyTo {
2317
id
2418
body
2519
floor
2620
author {
27-
id
28-
avatar
29-
nickname
21+
${F.author}
3022
}
3123
}
3224
replies(filter: { first: 5 }) {
3325
id
3426
author {
35-
id
36-
avatar
37-
nickname
27+
${F.author}
3828
}
3929
}
4030
repliesCount
41-
likesCount
42-
dislikesCount
43-
insertedAt
44-
updatedAt
4531
}
46-
pageNumber
47-
pageSize
48-
totalCount
49-
totalPages
32+
${F.pagedCounts}
5033
}
5134
}
5235
`

‎containers/Content/index.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { inject, observer } from 'mobx-react'
1010
importCommunitiesContentfrom'../CommunitiesContent'
1111
importCheatSheetContentfrom'../CheatSheetContent'
1212
importPostContentfrom'../PostContent'
13+
importJobContentfrom'../JobContent'
1314
importUserContentfrom'../UserContent'
1415

1516
importCommunityContentfrom'../../components/CommunityContent'
@@ -34,6 +35,9 @@ const renderContent = curRoute => {
3435
caseROUTE.POST:{
3536
return<PostContent/>
3637
}
38+
caseROUTE.JOB:{
39+
return<JobContent/>
40+
}
3741
caseROUTE.USER:{
3842
return<UserContent/>
3943
}

‎containers/JobBanner/index.js‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
/*
2-
*
3-
* JobBanner
4-
*
5-
*/
2+
*
3+
* JobBanner
4+
*
5+
*/
66

77
importReactfrom'react'
88
import{inject,observer}from'mobx-react'
99

10-
//import { } from './styles'
10+
import{ContentBanner}from'../../components'
1111

1212
import{makeDebugger,storePlug}from'../../utils'
13-
1413
import*aslogicfrom'./logic'
14+
1515
/* eslint-disable no-unused-vars */
1616
constdebug=makeDebugger('C:JobBanner')
1717
/* eslint-enable no-unused-vars */
1818

19-
// NOTE: add me to ../containers/index
2019
classJobBannerContainerextendsReact.Component{
2120
componentWillMount(){
2221
const{ jobBanner}=this.props
2322
logic.init(jobBanner)
2423
}
2524

2625
render(){
27-
return(
28-
<div>
29-
<h2>JobBanner container!</h2>
30-
<div>impress me!</div>
31-
</div>
32-
)
26+
const{ jobBanner}=this.props
27+
const{ viewingJobData}=jobBanner
28+
29+
return<ContentBannerdata={viewingJobData}/>
3330
}
3431
}
3532

‎containers/JobBanner/store.js‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
/*
2-
* JobBanner store
3-
*
4-
*/
2+
* JobBanner store
3+
*
4+
*/
55

66
import{typesast,getParent}from'mobx-state-tree'
77
// import R from 'ramda'
88

9-
import{markStates,makeDebugger}from'../../utils'
9+
import{markStates,makeDebugger,stripMobx}from'../../utils'
1010
/* eslint-disable no-unused-vars */
1111
constdebug=makeDebugger('S:JobBanner')
1212
/* eslint-enable no-unused-vars */
1313

14-
// NOTE: add me to ../../stores/index && ../../stores/RootStore/index
1514
constJobBanner=t
1615
.model('JobBanner',{})
1716
.views(self=>({
1817
getroot(){
1918
returngetParent(self)
2019
},
20+
getcurRoute(){
21+
returnself.root.curRoute
22+
},
23+
getviewingJobData(){
24+
returnstripMobx(self.root.viewing.job)
25+
},
2126
}))
2227
.actions(self=>({
2328
markState(sobj){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp