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

Commit e75f0a9

Browse files
committed
Merge branch 'wiki-thread' into dev
2 parents 3931327 + f7d206b commit e75f0a9

File tree

19 files changed

+547
-1
lines changed

19 files changed

+547
-1
lines changed

components/CommunityContent/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import PropTypes from 'prop-types'
1010
import PostsThread from '../../containers/PostsThread'
1111
import VideosThread from '../../containers/VideosThread'
1212
import ReposThread from '../../containers/ReposThread'
13+
import WikiThread from '../../containers/WikiThread'
1314
import JobsThread from '../../containers/JobsThread'
1415
import UsersThread from '../../containers/UsersThread'
1516
import CheatSheetPaper from '../../containers/CheatSheetPaper'
@@ -38,6 +39,9 @@ const ComunityContent = ({ curRoute }) => {
3839
case ROUTE.JOBS: {
3940
return <JobsThread />
4041
}
42+
case ROUTE.WIKI: {
43+
return <WikiThread />
44+
}
4145
case 'cheatsheet': {
4246
return <CheatSheetPaper />
4347
}

containers/VideoViewer/BodyHeader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22

33
import { ICON_CMD } from '../../config'
44

5-
import { Labeler } from '..'
5+
import Labeler from '../Labeler'
66
import { Popover } from '../../components'
77

88
// import ArticleOptions from '../../containers/ArticleViwer/ArticleOptions'

containers/WikiThread/Contributors.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import React from 'react'
2+
3+
import { ICON_CMD } from '../../config'
4+
import { Popover, Maybe, Space } from '../../components'
5+
6+
import {
7+
Wrapper,
8+
NoteWrapper,
9+
NoteTitle,
10+
NoteDivider,
11+
NoteDesc,
12+
AvatarListWrapper,
13+
AvatarLink,
14+
Avatar,
15+
UserPopWrapper,
16+
PopAvatarWrapper,
17+
PopAvatar,
18+
UserPopInfo,
19+
Username,
20+
UserBio,
21+
UserLocation,
22+
UserCompany,
23+
LabelIcon,
24+
LabelText,
25+
SycNote,
26+
} from './styles/contributors'
27+
28+
import fakeUser from './fakeUser'
29+
30+
import { uid } from '../../utils'
31+
32+
const Note = () => (
33+
<NoteWrapper>
34+
<NoteTitle>本页贡献者</NoteTitle>
35+
<NoteDivider />
36+
<NoteDesc>参与编辑后你的 GitHub 头像会同步在这里, 感谢参与.</NoteDesc>
37+
</NoteWrapper>
38+
)
39+
40+
const AvatarPopInfo = ({ user }) => (
41+
<UserPopWrapper>
42+
<PopAvatarWrapper>
43+
<PopAvatar src={user.avatar} />
44+
</PopAvatarWrapper>
45+
<UserPopInfo>
46+
<Username>{user.nickname}</Username>
47+
<UserBio>{user.bio}</UserBio>
48+
<Maybe test={user.location}>
49+
<UserLocation>
50+
<LabelIcon src={`${ICON_CMD}/city_map.svg`} />
51+
<LabelText> {user.location}</LabelText>
52+
</UserLocation>
53+
</Maybe>
54+
<Maybe test={user.company}>
55+
<UserCompany>
56+
<LabelIcon src={`${ICON_CMD}/profile_company.svg`} />
57+
<LabelText> {user.company}</LabelText>
58+
</UserCompany>
59+
</Maybe>
60+
</UserPopInfo>
61+
</UserPopWrapper>
62+
)
63+
64+
const AvatarList = () => (
65+
<AvatarListWrapper>
66+
{fakeUser.map(user => (
67+
<Popover
68+
content={<AvatarPopInfo user={user} />}
69+
placement="bottom"
70+
trigger="hover"
71+
key={uid.gen()}
72+
>
73+
<AvatarLink>
74+
<Avatar src={user.avatar} />
75+
</AvatarLink>
76+
</Popover>
77+
))}
78+
</AvatarListWrapper>
79+
)
80+
81+
const Contributors = () => (
82+
<Wrapper>
83+
<Note />
84+
<AvatarList />
85+
86+
<SycNote>
87+
<LabelIcon src={`${ICON_CMD}/sync.svg`} />
88+
<LabelText>最后同步:</LabelText>
89+
<Space right="5px" />
90+
<LabelText>3天前</LabelText>
91+
</SycNote>
92+
</Wrapper>
93+
)
94+
95+
export default Contributors

containers/WikiThread/fakeUser.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
const users = [
2+
{
3+
avatar: 'https://avatars3.githubusercontent.com/u/1875350?s=40&v=4 ',
4+
nickname: 'nickname 1',
5+
location: 'location',
6+
bio: 'a very long text a very long text a very long text a very long text',
7+
company: 'company info',
8+
},
9+
{
10+
avatar: 'https://avatars2.githubusercontent.com/u/74385?s=40&v=4',
11+
nickname: 'nickname',
12+
location: 'location',
13+
bio: 'a very long text a very long text a very long text a very long text',
14+
company: 'company info',
15+
},
16+
{
17+
avatar: 'https://avatars1.githubusercontent.com/u/381213?s=40&v=4',
18+
nickname: 'nickname',
19+
location: 'location',
20+
bio: 'a very long text a very long text a very long text a very long text',
21+
company: 'company info',
22+
},
23+
{
24+
avatar: 'https://avatars1.githubusercontent.com/u/300631?s=40&v=4',
25+
nickname: 'nickname',
26+
location: 'location',
27+
bio: 'a very long text a very long text a very long text a very long text',
28+
company: 'company info',
29+
},
30+
{
31+
avatar: 'https://avatars3.githubusercontent.com/u/1237203?s=40&v=4',
32+
nickname: 'nickname',
33+
location: 'location',
34+
bio: 'a very long text a very long text a very long text a very long text',
35+
company: 'company info',
36+
},
37+
{
38+
avatar: 'https://avatars3.githubusercontent.com/u/7498434?s=40&v=4',
39+
nickname: 'nickname',
40+
location: 'location',
41+
company: 'company info',
42+
},
43+
//
44+
{
45+
avatar: 'https://avatars1.githubusercontent.com/u/381213?s=40&v=4',
46+
nickname: 'nickname',
47+
location: 'location',
48+
bio: 'a very long text a very long text a very long text a very long text',
49+
},
50+
{
51+
avatar: 'https://avatars1.githubusercontent.com/u/300631?s=40&v=4',
52+
nickname: 'nickname',
53+
location: 'location',
54+
bio: 'a very long text a very long text a very long text a very long text',
55+
company: 'company info',
56+
},
57+
{
58+
avatar: 'https://avatars3.githubusercontent.com/u/1237203?s=40&v=4',
59+
nickname: 'nickname',
60+
bio: 'a very long text a very long text a very long text a very long text',
61+
company: 'company info',
62+
},
63+
]
64+
65+
export default users

containers/WikiThread/index.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
*
3+
* WikiThread
4+
*
5+
*/
6+
7+
import React from 'react'
8+
import { inject, observer } from 'mobx-react'
9+
10+
import { ICON_CMD } from '../../config'
11+
12+
import { PublishLabel, MarkDownRender } from '../../components'
13+
14+
import {
15+
Wrapper,
16+
LeftPart,
17+
LeftPadding,
18+
RightPart,
19+
RightPadding,
20+
PublishBtn,
21+
} from './styles'
22+
23+
import Contributors from './Contributors'
24+
25+
import { makeDebugger, storePlug } from '../../utils'
26+
27+
import * as logic from './logic'
28+
/* eslint-disable no-unused-vars */
29+
const debug = makeDebugger('C:WikiThread')
30+
/* eslint-enable no-unused-vars */
31+
32+
class WikiThreadContainer extends React.Component {
33+
componentWillMount() {
34+
const { wikiThread } = this.props
35+
logic.init(wikiThread)
36+
}
37+
38+
render() {
39+
return (
40+
<Wrapper>
41+
<LeftPadding />
42+
<LeftPart>
43+
<MarkDownRender body="## this is a wiki demo" />
44+
</LeftPart>
45+
<RightPart>
46+
<React.Fragment>
47+
<PublishBtn type="primary" onClick={debug}>
48+
<PublishLabel
49+
text="参与编辑"
50+
iconSrc={`${ICON_CMD}/github.svg`}
51+
/>
52+
</PublishBtn>
53+
<Contributors />
54+
</React.Fragment>
55+
</RightPart>
56+
<RightPadding />
57+
</Wrapper>
58+
)
59+
}
60+
}
61+
62+
export default inject(storePlug('wikiThread'))(observer(WikiThreadContainer))

containers/WikiThread/lang.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* WikiThread Langs
3+
*
4+
* This contains all the text for the WikiThread component.
5+
*/
6+
import { defineMessages } from 'react-intl'
7+
8+
export default defineMessages({
9+
header: {
10+
id: 'containers.WikiThread.header',
11+
defaultMessage: 'This is the WikiThread component !',
12+
},
13+
})

containers/WikiThread/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:WikiThread')
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/WikiThread/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/WikiThread/store.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* WikiThread store
3+
*
4+
*/
5+
6+
import { types as t, getParent } from 'mobx-state-tree'
7+
// import R from 'ramda'
8+
9+
import { markStates, makeDebugger } from '../../utils'
10+
/* eslint-disable no-unused-vars */
11+
const debug = makeDebugger('S:WikiThread')
12+
/* eslint-enable no-unused-vars */
13+
14+
// NOTE: add me to ../../stores/index && ../../stores/RootStore/index
15+
const WikiThread = t
16+
.model('WikiThread', {})
17+
.views(self => ({
18+
get root() {
19+
return getParent(self)
20+
},
21+
}))
22+
.actions(self => ({
23+
markState(sobj) {
24+
markStates(sobj, self)
25+
},
26+
}))
27+
28+
export default WikiThread

0 commit comments

Comments
 (0)