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

Commit 742570e

Browse files
authored
refactor(comments): create/update/reply with new editor workflow (#1170)
* refactor(comment-editor): wip * refactor(comment-editor): re-org wip * refactor(comment-editor): re-org wip * refactor(comment-editor): re-org & ssr cookie logic * refactor(comment-editor): publish workflow done & style dajust * refactor(update): put isAuthorUptoved into workflow * refactor(comment-editor): update logic wip * refactor(comment-editor): update logic done * refactor(comment-editor): show action when hover * refactor(comment-editor): reply, update, create workflow done * refactor(comment-editor): re-org update method * refactor: re-org all editor to Editor * refactor(comment-list): replies states debug * refactor(comment-list): replies logic & upvote style * refactor(comment-list): replies pagi logic * refactor(comment-list): remove tobeDelete concept * refactor(comment-list): pagi logic & adjust style * refactor(comment-list): wip * refactor(comment-list): adjust upvote & indent-line size/margin * refactor(comments): new comment state api
1 parent dcc6aed commit 742570e

File tree

117 files changed

+1594
-1811
lines changed

Some content is hidden

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

117 files changed

+1594
-1811
lines changed

package-lock.json

Lines changed: 44 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"dependencies": {
4343
"@babel/core": "^7.13.14",
44-
"@groupher/react-editor": "^1.1.28",
44+
"@groupher/react-editor": "^1.1.29",
4545
"@next/bundle-analyzer": "^9.4.4",
4646
"@sentry/browser": "5.17.0",
4747
"@sentry/node": "5.17.0",
@@ -56,14 +56,14 @@
5656
"chalk": "^2.4.1",
5757
"compatible-debug": "^1.0.0",
5858
"cookie-parser": "^1.4.4",
59+
"cookies-next": "^2.0.3",
5960
"core-js": "3.6.5",
6061
"cross-env": "^7.0.2",
6162
"express": "^4.16.4",
6263
"glob": "^7.1.2",
6364
"graphql": "^15.5.1",
6465
"graphql-request": "3.5.0",
6566
"graphql-voyager": "^1.0.0-rc.31",
66-
"js-cookie": "^2.2.0",
6767
"mastani-codehighlight": "0.0.7",
6868
"mobx": "6.3.2",
6969
"mobx-react": "7.2.0",

server/helper.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const renderAndCache = ({ req, res, path }) => {
99
// do not cache in dev mode
1010
if (dev) {
1111
const pagePath = path || req.path
12-
console.log('# pagePath: ', pagePath)
1312
return app.render(req, res, pagePath, {
1413
...req.query,
1514
...req.params,

src/components/AnimatedCount/AnimatedCount.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const AnimatedCount: FC<TProps> = ({
1313
active = false,
1414
}) => {
1515
return (
16-
<Wrapper size={size} $active={active}>
16+
<Wrapper size={size} $active={active} count={count}>
1717
<AnimateOnChange
1818
animationIn="fadeInUp"
1919
animationOut="bounceOut"

src/components/AnimatedCount/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const AnimatedCount = dynamic(() => import('./AnimatedCount'), {
2020
active: boolean
2121
}
2222
return (
23-
<Wrapper size={size} $active={active}>
23+
<Wrapper size={size} $active={active} count={count}>
2424
{count}
2525
</Wrapper>
2626
)

src/components/AnimatedCount/styles/index.ts

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

33
import type { TSIZE, TActive } from '@/spec'
4-
import { theme } from '@/utils/themes'
54

6-
import { getFontSize } from './metric'
5+
import { getFontSize, getCountColor } from './metric'
76

8-
type TWrapper = { size: TSIZE } & TActive
7+
type TWrapper = { size: TSIZE; count: number } & TActive
98

109
export const Wrapper = styled.div<TWrapper>`
11-
color: ${({ $active }) =>
12-
$active ? '#139C9E' : theme('thread.articleTitle')};
10+
color: ${({ $active, count }) => getCountColor($active, count)};
1311
font-size: ${({ size }) => getFontSize(size)};
1412
font-weight: ${({ $active }) => ($active ? 'bold' : 'normal')};
1513
overflow-y: hidden;

src/components/AnimatedCount/styles/metric.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { TSIZE } from '@/spec'
22
import { SIZE } from '@/constant'
33

4+
import { theme } from '@/utils/themes'
5+
46
export const getFontSize = (size: TSIZE): string => {
57
switch (size) {
68
case SIZE.TINY: {
@@ -15,4 +17,10 @@ export const getFontSize = (size: TSIZE): string => {
1517
}
1618
}
1719

18-
export const holder = 1
20+
export const getCountColor = ($active: boolean, count: number): string => {
21+
if ($active) return '#139C9E'
22+
if (count === 0) return '#4f7478'
23+
if (count >= 5) return theme('thread.articleTitle')
24+
25+
return theme('thread.articleDigest')
26+
}

src/components/ArtimentBody/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const ArtimentBody: FC<TProps> = ({
5252

5353
return (
5454
<Wrapper testid={testid}>
55-
<Body ref={bodyRef} lineClampNum={lineClampNum}>
55+
<Body ref={bodyRef} lineClampNum={lineClampNum} mode={mode}>
5656
<HTML
5757
dangerouslySetInnerHTML={{
5858
__html: document.bodyHtml,

src/components/ArtimentBody/styles/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({
88
'data-test-id': testid,
99
}))<TTestable>``
1010

11-
export const Body = styled.div<{ lineClampNum: number }>`
12-
font-size: 16px;
11+
type TBody = { lineClampNum: number; mode: 'article' | 'comment' }
12+
export const Body = styled.div<TBody>`
13+
font-size: ${({ mode }) => (mode === 'article' ? '16px' : '15px')};
1314
line-height: 1.85;
1415
position: relative;
1516
display: -webkit-box;

src/components/Buttons/SubmitButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const SubmitButton: FC<TProps> = ({
3333
{publishDone ? (
3434
<DonwWrapper>
3535
<DoneIcon />
36-
<DoneHint>已完成</DoneHint>
36+
<DoneHint>已提交</DoneHint>
3737
</DonwWrapper>
3838
) : (
3939
<YesOrNoButtons

0 commit comments

Comments
 (0)