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

Commit cd76d9f

Browse files
committed
chore(links): header links re-org & related pages content, footer
1 parent ed17c20 commit cd76d9f

File tree

28 files changed

+302
-496
lines changed

28 files changed

+302
-496
lines changed

.huskyrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"hooks": {
3+
"pre-commit": "pretty-quick --staged && npm run lint:staged",
34
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
45
}
56
}

src/containers/content/SubscribeContent/Actions/Detail.js renamed to src/containers/content/SubscribeContent/Actions/Detail.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import { FC, memo } from 'react'
22

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

@@ -7,18 +7,16 @@ import EmailSubscriber from '@/widgets/EmailSubscriber'
77
import { Br, SpaceGrow } from '@/widgets/Common'
88
// TODO: extract to Email Subscriber
99

10-
import { Wrapper, Title, Desc, Dot, CopyIcon } from '../styles/actions/detail'
10+
import { Wrapper, Title, Desc, CopyIcon } from '../styles/actions/detail'
1111
import { notifyCopy } from '../logic'
1212

13-
const Detail = () => {
13+
const Detail: FC = () => {
1414
const [copyState, copyToClipboard] = useCopyToClipboard()
1515

16-
const rss = 'https://coderplanets.com/rss/javascript'
16+
const rss = 'https://coderplanets.com/javascript/rss'
1717
return (
1818
<Wrapper>
19-
<Title>
20-
<Dot /> Email 订阅
21-
</Title>
19+
<Title>Email 订阅</Title>
2220
<Desc>
2321
<EmailSubscriber
2422
activeByDefault
@@ -28,7 +26,6 @@ const Detail = () => {
2826
</Desc>
2927
<Br top={50} />
3028
<Title>
31-
<Dot />
3229
RSS 订阅
3330
<SpaceGrow />
3431
<div
@@ -45,4 +42,4 @@ const Detail = () => {
4542
)
4643
}
4744

48-
export default Detail
45+
export default memo(Detail)

src/containers/content/SubscribeContent/Actions/index.js

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { FC, memo } from 'react'
2+
3+
import Detail from './Detail'
4+
5+
import { Wrapper, InnerWrapper } from '../styles/actions'
6+
7+
const Actions: FC = () => {
8+
return (
9+
<Wrapper>
10+
<InnerWrapper>
11+
<Detail />
12+
</InnerWrapper>
13+
</Wrapper>
14+
)
15+
}
16+
17+
export default memo(Actions)

src/containers/content/SubscribeContent/Content/index.js

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* eslint-disable max-len */
2+
import { FC, memo } from 'react'
3+
4+
import Linker from '@/widgets/Linker'
5+
6+
import { Wrapper, Title, P, Bold, Ul, Li } from '../styles/content'
7+
8+
const Content: FC = () => {
9+
return (
10+
<Wrapper>
11+
<Title>关于内容订阅</Title>
12+
<P>
13+
CoderPlanets 子社区以及版块的内容可通过邮件或者 RSS
14+
订阅。但目前因为社区内容较少以及开发精力受限,
15+
<Bold>相关功能还未开始开发</Bold>
16+
。如果你有这方面的建议,
17+
<Linker
18+
src="/feedback"
19+
external={false}
20+
text="欢迎参与共建"
21+
inline
22+
left={4}
23+
right={4}
24+
/>
25+
</P>
26+
<br />
27+
<br />
28+
<Title>一些基本承诺</Title>
29+
<Ul>
30+
<Li>所有内容均可订阅。</Li>
31+
<Li>会尽量遵循最新的 RSS 协议标准。</Li>
32+
<Li>可以自定义订阅内容的粒度。</Li>
33+
</Ul>
34+
</Wrapper>
35+
)
36+
}
37+
38+
export default memo(Content)
Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,49 @@
1-
//
2-
31
/*
42
*
53
* SubscribeContent
64
*
75
*/
6+
import { FC } from 'react'
87

9-
import React from 'react'
10-
import T from 'prop-types'
11-
8+
import type { TMetric } from '@/spec'
9+
import { METRIC } from '@/constant'
1210
import { buildLog } from '@/utils/logger'
1311
import { pluggedIn } from '@/utils/mobx'
1412

1513
import Content from './Content'
1614
import Actions from './Actions'
1715

16+
import type { TStore } from './store'
1817
import { Wrapper, InnerWrapper, StickyWrapper } from './styles'
1918
import { useInit } from './logic'
2019

2120
/* eslint-disable-next-line */
2221
const log = buildLog('C:SubscribeContent')
2322

24-
const SubscribeContentContainer = ({ subscribeContent: store, testid }) => {
25-
useInit(store)
23+
type TProps = {
24+
subscribeContent?: TStore
25+
testid?: string
26+
metric?: TMetric
27+
}
2628

27-
const { subscribeView } = store
29+
const SubscribeContentContainer = ({
30+
subscribeContent: store,
31+
testid = 'subscribe-content',
32+
metric = METRIC.SUBSCRIBE,
33+
}) => {
34+
useInit(store)
2835

2936
return (
3037
<Wrapper testid={testid}>
31-
<InnerWrapper>
38+
<InnerWrapper metric={metric}>
3239
<Content />
3340
<StickyWrapper offsetTop={200}>
34-
<Actions view={subscribeView} />
41+
<Actions />
3542
</StickyWrapper>
3643
</InnerWrapper>
3744
</Wrapper>
3845
)
3946
}
4047

41-
SubscribeContentContainer.propTypes = {
42-
subscribeContent: T.any.isRequired,
43-
testid: T.string,
44-
}
45-
46-
SubscribeContentContainer.defaultProps = {
47-
testid: 'subscribe-content',
48-
}
49-
50-
export default pluggedIn(SubscribeContentContainer)
48+
// @ts-ignore
49+
export default pluggedIn(SubscribeContentContainer) as FC<TProps>

src/containers/content/SubscribeContent/logic.js renamed to src/containers/content/SubscribeContent/logic.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { useEffect } from 'react'
22
// import { } from 'ramda'
33

4-
import { cutRest } from '@/utils/helper'
4+
import { CopyToClipboardState } from 'react-use/lib/useCopyToClipboard'
5+
import { cutRest, toast } from '@/utils/helper'
56
import { buildLog } from '@/utils/logger'
67
// import S from './service'
78

8-
let store = null
9+
import type { TStore } from './store'
10+
11+
let store: TStore | undefined
912

1013
/* eslint-disable-next-line */
1114
const log = buildLog('L:SubscribeContent')
@@ -15,7 +18,7 @@ const log = buildLog('L:SubscribeContent')
1518
*
1619
* @param {String} view - view type default | detail
1720
*/
18-
export const changeView = (view) => {
21+
export const changeView = (view: string): void => {
1922
store.mark({ subscribeView: view })
2023
}
2124

@@ -24,19 +27,18 @@ export const changeView = (view) => {
2427
*
2528
* @param {*} { error, value }
2629
*/
27-
export const notifyCopy = ({ error, value }) => {
28-
const type = !error ? 'info' : 'error'
29-
const title = !error ? '已复制到剪切板' : '复制到剪切板出错'
30-
const msg = !error ? cutRest(value, 10) : error
30+
export const notifyCopy = ({ error, value }: CopyToClipboardState): void => {
31+
const toastTitle = !error ? '已复制到剪切板' : '复制到剪切板出错'
32+
const toastDesc = !error ? cutRest(value, 10) : error
3133

32-
store.toast(type, { title, msg, position: 'topCenter' })
34+
toast('info', toastTitle, toastDesc as string)
3335
}
3436

3537
// ###############################
3638
// init & uninit handlers
3739
// ###############################
3840

39-
export const useInit = (_store) => {
41+
export const useInit = (_store: TStore): void => {
4042
useEffect(() => {
4143
store = _store
4244
log('useInit: ', store)

src/containers/content/SubscribeContent/store.js renamed to src/containers/content/SubscribeContent/store.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,20 @@
33
*
44
*/
55

6-
import { types as T, getParent } from 'mobx-state-tree'
6+
import { types as T, Instance } from 'mobx-state-tree'
77
// import {} from 'ramda'
88

99
import { markStates } from '@/utils/mobx'
1010

1111
const SubscribeContent = T.model('SubscribeContent', {
1212
subscribeView: T.optional(T.enumeration(['default', 'detail']), 'default'),
1313
})
14-
.views((self) => ({
15-
get root() {
16-
return getParent(self)
17-
},
18-
}))
14+
.views((self) => ({}))
1915
.actions((self) => ({
20-
toast(type, options) {
21-
self.root.toast(type, options)
22-
},
23-
mark(sobj) {
16+
mark(sobj: Record<string, unknown>): void {
2417
markStates(sobj, self)
2518
},
2619
}))
2720

21+
export type TStore = Instance<typeof SubscribeContent>
2822
export default SubscribeContent

src/containers/content/SubscribeContent/styles/actions/detail.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
import styled from 'styled-components'
22

33
import Img from '@/Img'
4-
import DotDivider from '@/widgets/DotDivider'
54

65
import { theme } from '@/utils/themes'
76
import css from '@/utils/css'
87

98
export const Wrapper = styled.div`
109
${css.flexColumn()};
10+
margin-top: 100px;
1111
`
1212
export const Title = styled.div`
1313
${css.flex('align-center')};
1414
color: ${theme('thread.articleTitle')};
1515
font-weight: bold;
16-
font-size: 16px;
17-
margin-bottom: 8px;
18-
padding-left: 8px;
19-
`
20-
export const Dot = styled(DotDivider)`
21-
background: ${theme('thread.articleTitle')};
22-
margin-right: 8px;
16+
font-size: 14px;
17+
margin-bottom: 12px;
2318
`
2419
export const Desc = styled.div`
2520
color: ${theme('thread.articleDigest')};
26-
padding-left: 25px;
2721
word-break: break-all;
2822
`
2923
export const CopyIcon = styled(Img)`

0 commit comments

Comments
 (0)