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

Commit 271e03d

Browse files
committed
feat(Pages): add Video page for SSR
1 parent 0b65059 commit 271e03d

File tree

34 files changed

+686
-72
lines changed

34 files changed

+686
-72
lines changed

components/AuthorCard/ReactonNumbers.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,26 @@ import {
77
Number,
88
} from './styles/reaction_numbers'
99

10-
const ReactionNumbers = ({ user }) => (
11-
<Wrapper>
12-
<ReactionNum>
13-
<NumDesc>声望</NumDesc>
14-
<Number>{user.achievement.reputation}</Number>
15-
</ReactionNum>
16-
<ReactionNum>
17-
<NumDesc>关注者</NumDesc>
18-
<Number>{user.followersCount}</Number>
19-
</ReactionNum>
20-
<ReactionNum>
21-
<NumDesc>关注中</NumDesc>
22-
<Number>{user.followingsCount}</Number>
23-
</ReactionNum>
24-
</Wrapper>
25-
)
10+
const ReactionNumbers = ({ user }) => {
11+
// early user has no reutation
12+
const achievement = user.achievement || { reputation: 0 }
13+
14+
return (
15+
<Wrapper>
16+
<ReactionNum>
17+
<NumDesc>声望</NumDesc>
18+
<Number>{achievement.reputation}</Number>
19+
</ReactionNum>
20+
<ReactionNum>
21+
<NumDesc>关注者</NumDesc>
22+
<Number>{user.followersCount}</Number>
23+
</ReactionNum>
24+
<ReactionNum>
25+
<NumDesc>关注中</NumDesc>
26+
<Number>{user.followingsCount}</Number>
27+
</ReactionNum>
28+
</Wrapper>
29+
)
30+
}
2631

2732
export default ReactionNumbers

components/ContentBanner/ReactionNumbers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { prettyNum, numberWithCommas } from '../../utils'
1313
const ReactionNumbers = ({ data: { views, favoritedCount, starredCount } }) => (
1414
<NumbersInfo>
1515
<NumberSection dead>
16-
<NumberTitle dead>阅读</NumberTitle>
16+
<NumberTitle dead>浏览</NumberTitle>
1717
<NumberItem dead>{prettyNum(views)}</NumberItem>
1818
</NumberSection>
1919
<NumberDivider />

containers/Banner/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
import UserBanner from '../UserBanner'
1111
import PostBanner from '../PostBanner'
1212
import JobBanner from '../JobBanner'
13+
import VideoBanner from '../VideoBanner'
1314
import CommunitiesBanner from '../CommunitiesBanner'
1415
import CommunityBanner from '../CommunityBanner'
1516

@@ -41,6 +42,9 @@ const BannerContent = ({ curRoute }) => {
4142
case ROUTE.JOB: {
4243
return <JobBanner />
4344
}
45+
case ROUTE.VIDEO: {
46+
return <VideoBanner />
47+
}
4448
case ROUTE.USER: {
4549
return <UserBanner />
4650
}

containers/Content/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import CommunitiesContent from '../CommunitiesContent'
1111
import CheatSheetContent from '../CheatSheetContent'
1212
import PostContent from '../PostContent'
1313
import JobContent from '../JobContent'
14+
import VideoContent from '../VideoContent'
1415
import UserContent from '../UserContent'
1516

1617
import CommunityContent from '../../components/CommunityContent'
@@ -38,6 +39,9 @@ const renderContent = curRoute => {
3839
case ROUTE.JOB: {
3940
return <JobContent />
4041
}
42+
case ROUTE.VIDEO: {
43+
return <VideoContent />
44+
}
4145
case ROUTE.USER: {
4246
return <UserContent />
4347
}

containers/VideoBanner/index.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
*
3+
* VideoBanner
4+
*
5+
*/
6+
7+
import React from 'react'
8+
import { inject, observer } from 'mobx-react'
9+
10+
// import { } from './styles'
11+
import { ContentBanner } from '../../components'
12+
13+
import { makeDebugger, storePlug } from '../../utils'
14+
15+
import * as logic from './logic'
16+
/* eslint-disable no-unused-vars */
17+
const debug = makeDebugger('C:VideoBanner')
18+
/* eslint-enable no-unused-vars */
19+
20+
class VideoBannerContainer extends React.Component {
21+
componentWillMount() {
22+
const { videoBanner } = this.props
23+
logic.init(videoBanner)
24+
}
25+
26+
render() {
27+
const { videoBanner } = this.props
28+
const { viewingVideoData } = videoBanner
29+
30+
return <ContentBanner data={viewingVideoData} />
31+
}
32+
}
33+
34+
export default inject(storePlug('videoBanner'))(observer(VideoBannerContainer))

containers/VideoBanner/logic.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// import R from 'ramda'
2+
3+
import { makeDebugger, $solver, asyncErr, ERR } from '../../utils'
4+
import SR71 from '../../utils/network/sr71'
5+
6+
// import S from './schema'
7+
8+
const sr71$ = new SR71()
9+
let sub$ = null
10+
11+
/* eslint-disable no-unused-vars */
12+
const debug = makeDebugger('L:VideoBanner')
13+
/* eslint-enable no-unused-vars */
14+
15+
let store = null
16+
17+
export function someMethod() {}
18+
19+
// ###############################
20+
// Data & Error handlers
21+
// ###############################
22+
23+
const DataSolver = []
24+
const ErrSolver = [
25+
{
26+
match: asyncErr(ERR.CRAPHQL),
27+
action: ({ details }) => {
28+
debug('ERR.CRAPHQL -->', details)
29+
},
30+
},
31+
{
32+
match: asyncErr(ERR.TIMEOUT),
33+
action: ({ details }) => {
34+
debug('ERR.TIMEOUT -->', details)
35+
},
36+
},
37+
{
38+
match: asyncErr(ERR.NETWORK),
39+
action: ({ details }) => {
40+
debug('ERR.NETWORK -->', details)
41+
},
42+
},
43+
]
44+
45+
export function init(_store) {
46+
if (store) return false
47+
store = _store
48+
49+
debug(store)
50+
if (sub$) sub$.unsubscribe()
51+
sub$ = sr71$.data().subscribe($solver(DataSolver, ErrSolver))
52+
}

containers/VideoBanner/schema.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import gql from 'graphql-tag'
2+
3+
const simpleMutation = gql`
4+
mutation($id: ID!) {
5+
post(id: $id) {
6+
id
7+
}
8+
}
9+
`
10+
const simpleQuery = gql`
11+
query($filter: filter!) {
12+
post(id: $id) {
13+
id
14+
}
15+
}
16+
`
17+
18+
const schema = {
19+
simpleMutation,
20+
simpleQuery,
21+
}
22+
23+
export default schema

containers/VideoBanner/store.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* VideoBanner store
3+
*
4+
*/
5+
6+
import { types as t, getParent } from 'mobx-state-tree'
7+
// import R from 'ramda'
8+
9+
import { markStates, makeDebugger, stripMobx } from '../../utils'
10+
/* eslint-disable no-unused-vars */
11+
const debug = makeDebugger('S:VideoBanner')
12+
/* eslint-enable no-unused-vars */
13+
14+
const VideoBanner = t
15+
.model('VideoBanner', {})
16+
.views(self => ({
17+
get root() {
18+
return getParent(self)
19+
},
20+
get curRoute() {
21+
return self.root.curRoute
22+
},
23+
get viewingVideoData() {
24+
return stripMobx(self.root.viewing.video)
25+
},
26+
}))
27+
.actions(self => ({
28+
markState(sobj) {
29+
markStates(sobj, self)
30+
},
31+
}))
32+
33+
export default VideoBanner
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import styled from 'styled-components'
2+
3+
// import Img from '../../../components/Img'
4+
// import { theme } from '../../../utils'
5+
6+
export const Wrapper = styled.div``
7+
export const Title = styled.div``
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 VideoBanner from '../index'
5+
6+
describe('TODO <VideoBanner />', () => {
7+
it('Expect to have unit tests specified', () => {
8+
expect(true).toEqual(true)
9+
})
10+
})

0 commit comments

Comments
 (0)