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

Commit b23318d

Browse files
authored
refactor(comments): with real data (#1158)
* refactor(article-thread): extract ReadableDate Comp * refactor(comments): debug wip * refactor(article): add align judage on fixedheader * refactor(article): add align judage on fixedheader * refactor(comment): debug emotion * refactor(comments): debug emotion * refactor(comment): emotion display make nice * refactor(comment): comment sticker use real participants * refactor(article-label): re-org code * refactor(comments): replies with real data * refactor(comments): indent & schema debug * refactor(comments): fold/expand enhance * refactor(comments): foldAll/expandAll done * refactor(comments): mode switch * refactor(comments): text adjust * refactor(comments): text adjust * refactor(comments): add DateDivider for timeline mode * fix(footer): post particle layout * refactor(comment): adjust reply bar
1 parent 1da0473 commit b23318d

File tree

158 files changed

+1278
-920
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+1278
-920
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
"jest": "26.2.2",
161161
"npm-run-all": "^4.1.1",
162162
"plop": "2.7.4",
163-
"prettier": "2.2.1",
163+
"prettier": "2.3.2",
164164
"pretty-quick": "^1.10.0",
165165
"react-test-renderer": "16.10.0",
166166
"shelljs": "0.8.4",

src/components/ArchivedSign/DetailPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const DetailPanel: FC<TProps> = ({ date }) => {
1111
return (
1212
<Wrapper>
1313
<Title>本帖已于 {date} 存档</Title>
14-
<Text>存档后无法编辑,删除及评论</Text>
14+
<Text>存档后无法编辑,删除及讨论</Text>
1515

1616
<LinksWrapper>
1717
<Button size="tiny" ghost noBorder>

src/components/ArticleItemPrefixLabel/index.tsx

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
*
3+
* ArticlePinLabel
4+
*
5+
*/
6+
7+
import { FC, memo } from 'react'
8+
9+
import { buildLog } from '@/utils/logger'
10+
import { PinIcon } from './styles'
11+
12+
/* eslint-disable-next-line */
13+
const log = buildLog('c:ArticlePinLabel:index')
14+
15+
export type TProps = {
16+
top?: number
17+
left?: number
18+
entry: {
19+
isPinned?: boolean
20+
}
21+
}
22+
const ArticlePinLabel: FC<TProps> = ({ entry, top = 24, left = -30 }) => {
23+
if (entry.isPinned) return <PinIcon top={top} left={left} />
24+
25+
return null
26+
}
27+
28+
export default memo(ArticlePinLabel)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import styled from 'styled-components'
2+
3+
import { theme } from '@/utils/themes'
4+
import css from '@/utils/css'
5+
import PinSVG from '@/icons/Pin'
6+
import { pixelAdd } from '@/utils/dom'
7+
8+
type TPos = { top: number; left: number }
9+
10+
export const PinIcon = styled(PinSVG)<TPos>`
11+
fill: ${theme('thread.articleDigest')};
12+
position: absolute;
13+
${css.size(18)};
14+
top: ${({ top }) => pixelAdd(`${top}px`, -4)};
15+
left: ${({ left }) => `${left}px`};
16+
opacity: 0.8;
17+
transform: rotate(-30deg);
18+
`
19+
20+
export const holder = 1

src/components/ArticleItemPrefixLabel/tests/index.test.ts renamed to src/components/ArticlePinLabel/tests/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// import React from 'react'
22
// import { shallow } from 'enzyme'
33

4-
// import ArticleItemPrefixLabel from '../index'
4+
// import ArticlePinLabel from '../index'
55

6-
describe('TODO <ArticleItemPrefixLabel />', () => {
6+
describe('TODO <ArticlePinLabel />', () => {
77
it('Expect to have unit tests specified', () => {
88
expect(true).toEqual(true)
99
})

src/components/ArticleItemPrefixLabel/ReadLabel.tsx renamed to src/components/ArticleReadLabel/ReadLabel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { useAccount } from '@/hooks'
44
import { ReadedLabel } from './styles'
55
import type { TProps } from './index'
66

7-
const ReadLabel: FC<TProps> = ({ entry, topOffset = '20px' }) => {
7+
const ReadLabel: FC<TProps> = ({ entry, top, left }) => {
88
const { c11n } = useAccount()
99
const { isLogin, markViewed } = c11n
1010

1111
const { viewerHasViewed } = entry
1212

1313
if (!isLogin) return null
1414
if (markViewed && viewerHasViewed) {
15-
return <ReadedLabel topOffset={topOffset} />
15+
return <ReadedLabel top={top} left={left} />
1616
}
1717

1818
return null
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* ArticleReadLabel
3+
*/
4+
5+
import { FC, memo } from 'react'
6+
7+
import { buildLog } from '@/utils/logger'
8+
import { useAccount } from '@/hooks'
9+
10+
import { ReadedLabel } from './styles'
11+
12+
/* eslint-disable-next-line */
13+
const log = buildLog('c:ArticleReadLabel:index')
14+
15+
export type TProps = {
16+
top?: number
17+
left?: number
18+
entry: {
19+
viewerHasViewed?: boolean
20+
pin?: boolean
21+
}
22+
}
23+
const ArticleReadLabel: FC<TProps> = ({ entry, top = 24, left = -30 }) => {
24+
const { c11n } = useAccount()
25+
const { isLogin, markViewed } = c11n
26+
27+
const { viewerHasViewed } = entry
28+
29+
if (entry.pin) return null
30+
// return <ReadedLabel top={top} left={left} />
31+
if (!isLogin) return null
32+
if (markViewed && viewerHasViewed) {
33+
return <ReadedLabel top={top} left={left} />
34+
}
35+
36+
return null
37+
}
38+
39+
export default memo(ArticleReadLabel)

src/components/ArticleItemPrefixLabel/styles/index.ts renamed to src/components/ArticleReadLabel/styles/index.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,26 @@ import css from '@/utils/css'
55
import PinSVG from '@/icons/Pin'
66
import { pixelAdd } from '@/utils/dom'
77

8-
export const ReadedLabel = styled.div<{ topOffset: string }>`
8+
type TPos = { top: number; left: number }
9+
10+
export const ReadedLabel = styled.div<TPos>`
911
background: ${theme('thread.articleDigest')};
10-
width: 8px;
11-
height: 3px;
12-
border-radius: 3px;
12+
${css.circle(8)};
1313
position: absolute;
14-
top: ${({ topOffset }) => topOffset};
15-
left: -30px;
14+
top: ${({ top }) => `${top}px`};
15+
left: ${({ left }) => `${left}px`};
1616
opacity: 0.5;
1717
${css.media.mobile`
1818
left: -12px;
1919
font-size: 0.8rem;
2020
`};
2121
`
22-
export const PinIcon = styled(PinSVG)<{ top: string }>`
22+
export const PinIcon = styled(PinSVG)<TPos>`
2323
fill: ${theme('thread.articleDigest')};
2424
position: absolute;
2525
${css.size(18)};
26-
top: ${({ top }) => pixelAdd(top, -4)};
27-
left: -35px;
26+
top: ${({ top }) => pixelAdd(`${top}px`, -4)};
27+
left: ${({ left }) => `${left}px`};
2828
opacity: 0.8;
2929
transform: rotate(-30deg);
30-
31-
${css.media.mobile`
32-
${css.size(16)};
33-
top: 35px;
34-
left: -20px;
35-
`};
3630
`
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 ArticleReadLabel from '../index'
5+
6+
describe('TODO <ArticleReadLabel />', () => {
7+
it('Expect to have unit tests specified', () => {
8+
expect(true).toEqual(true)
9+
})
10+
})

0 commit comments

Comments
 (0)