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

Commit 9588fc2

Browse files
authored
feat(thread): add changelog, UI only (#1276)
* feat(changelog): basic layout * feat(changelog): tag styles * style(post-item): adjust filter order * style(changelog-item): more bg color for label, re-org * refactor(tags-bar): extract spec & constant for label style * chore: clean up
1 parent 0c1b21a commit 9588fc2

File tree

31 files changed

+503
-42
lines changed

31 files changed

+503
-42
lines changed

src/containers/content/CommunityContent/ThreadContent.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import type { TThread } from '@/spec'
44
import { THREAD } from '@/constant'
55

66
import ArticlesThread from '@/containers//thread/ArticlesThread'
7-
import GtdThread from '@/containers//thread/GtdThread'
7+
// import GtdThread from '@/containers//thread/GtdThread'
8+
// import ChangeThread from '@/containers//thread/ChangelogThread'
89
// import ReposThread from '@/containers/thread/ReposThread'
910
import CperMapThread from '@/containers/thread/CperMapThread'
1011

@@ -47,8 +48,9 @@ const ThreadContent: FC<TProps> = ({ thread }) => {
4748
return <CperMapThread />
4849

4950
default:
50-
return <GtdThread />
51-
// return <ArticlesThread />
51+
// return <GtdThread />
52+
// return <ChangeThread />
53+
return <ArticlesThread />
5254
}
5355
}
5456

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { FC, memo } from 'react'
2+
3+
import { Br } from '@/widgets/Common'
4+
import TagsBar from '@/containers/unit/TagsBar'
5+
import { TAG_MODE } from '@/constant'
6+
7+
import { Wrapper, SearchInput, SearchBox } from './styles/filters'
8+
9+
const Filters: FC = () => {
10+
return (
11+
<Wrapper>
12+
<SearchBox>新增 更新记录</SearchBox>
13+
<Br bottom={15} />
14+
<SearchInput placeholder="搜索内容..." />
15+
<Br bottom={30} />
16+
<TagsBar onSelect={() => console.log} mode={TAG_MODE.LABEL} />
17+
</Wrapper>
18+
)
19+
}
20+
21+
export default memo(Filters)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* *
2+
* ChangelogThread
3+
*
4+
*/
5+
6+
import { FC } from 'react'
7+
8+
// import { buildLog } from '@/utils/logger'
9+
import { bond } from '@/utils/mobx'
10+
11+
import ChangelogItem from '@/widgets/ChangelogItem'
12+
import Filters from './Filters'
13+
14+
import type { TStore } from './store'
15+
import { Wrapper, MainWrapper } from './styles'
16+
import { useInit } from './logic' /* eslint-disable-next-line */
17+
18+
// const log = buildLog('C:ChangelogThread')
19+
20+
type TProps = {
21+
changelogThread?: TStore
22+
testid?: string
23+
}
24+
25+
const ChangelogThreadContainer: FC<TProps> = ({
26+
changelogThread: store,
27+
testid = 'changelog-thread',
28+
}) => {
29+
useInit(store)
30+
31+
return (
32+
<Wrapper testid={testid}>
33+
<MainWrapper>
34+
<ChangelogItem />
35+
<ChangelogItem />
36+
<ChangelogItem />
37+
<ChangelogItem />
38+
</MainWrapper>
39+
<Filters />
40+
</Wrapper>
41+
)
42+
}
43+
44+
export default bond(ChangelogThreadContainer, 'changelogThread') as FC<TProps>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { useEffect } from 'react'
2+
// import { } from 'ramda'
3+
4+
import { buildLog } from '@/utils/logger'
5+
6+
// import S from './schma'
7+
import type { TStore } from './store'
8+
9+
let store: TStore | undefined
10+
11+
/* eslint-disable-next-line */
12+
const log = buildLog('L:ChangelogThread')
13+
14+
export const someMethod = (): void => {
15+
//
16+
}
17+
18+
// ###############################
19+
// init & uninit handlers
20+
// ###############################
21+
22+
export const useInit = (_store: TStore): void => {
23+
useEffect(() => {
24+
store = _store
25+
log('useInit: ', store)
26+
// return () => store.reset()
27+
}, [_store])
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { gql } from '@urql/core'
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
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* ChangelogThread store
3+
*/
4+
5+
import { types as T, getParent, Instance } from 'mobx-state-tree'
6+
// import {} from 'ramda'
7+
8+
import type { TCommunity, TRootStore } from '@/spec'
9+
import { buildLog } from '@/utils/logger'
10+
import { markStates, toJS } from '@/utils/mobx'
11+
12+
/* eslint-disable-next-line */
13+
const log = buildLog('S:ChangelogThread')
14+
15+
const ChangelogThread = T.model('ChangelogThread', {})
16+
.views((self) => ({
17+
get curCommunity(): TCommunity {
18+
const root = getParent(self) as TRootStore
19+
20+
return toJS(root.viewing.community)
21+
},
22+
}))
23+
.actions((self) => ({
24+
mark(sobj: Record<string, unknown>): void {
25+
markStates(sobj, self)
26+
},
27+
}))
28+
29+
export type TStore = Instance<typeof ChangelogThread>
30+
31+
export default ChangelogThread
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import styled from 'styled-components'
2+
3+
import type { TTestable } from '@/spec'
4+
5+
import Input from '@/widgets/Input'
6+
import Button from '@/widgets/Buttons/Button'
7+
8+
import css, { theme } from '@/utils/css'
9+
10+
export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({
11+
'data-test-id': testid,
12+
}))<TTestable>`
13+
${css.flexColumn()};
14+
width: 200px;
15+
min-width: 200px;
16+
color: ${theme('thread.articleDigest')};
17+
padding-top: 25px;
18+
`
19+
export const SearchInput = styled(Input)`
20+
width: 180px;
21+
font-size: 13px;
22+
text-align: center;
23+
border-radius: 15px;
24+
25+
::placeholder {
26+
color: ${theme('form.text')};
27+
opacity: 0.6;
28+
}
29+
`
30+
export const SearchBox = styled(Button)`
31+
width: 180px;
32+
border-radius: 15px;
33+
`
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import styled from 'styled-components'
2+
3+
import type { TTestable } from '@/spec'
4+
import css from '@/utils/css'
5+
6+
export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({
7+
'data-test-id': testid,
8+
}))<TTestable>`
9+
${css.flex()};
10+
width: 100%;
11+
`
12+
export const MainWrapper = styled.div`
13+
flex-grow: 1;
14+
width: 100%;
15+
min-height: 500px;
16+
17+
background: transparent;
18+
border-radius: 6px;
19+
margin-top: 12px;
20+
padding-left: 25px;
21+
padding-right: 80px;
22+
margin-right: 65px;
23+
border-right: 1px solid #eae9e9;
24+
`
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 ChangelogThread from '../index'
5+
6+
describe('TODO <ChangelogThread />', () => {
7+
it('Expect to have unit tests specified', () => {
8+
expect(true).toEqual(true)
9+
})
10+
})
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* ChangelogThread store test
3+
*
4+
*/
5+
6+
// import ChangelogThread from '../index'
7+
8+
it('TODO: store test ChangelogThread', () => {
9+
expect(1 + 1).toBe(2)
10+
})

0 commit comments

Comments
 (0)