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

Commit bfc9df7

Browse files
authored
refactor: mutation debug 1 (#1166)
* chore: basic login * chore: communityBrief adjust * refactor(followButton): adjust styles && offset prop * refactor(clean-up): unused store & containers * refactor(footer): move joinUS to footer item * refactor(upvote): re-org post action workflow * refactor(upvote): re-org general schema-thread logic * refactor(upvote): ux enhance, wip * refactor(comment): emotion wip * refactor(comment): emotion selector re-org * refactor(comment): emotion selector styles re-org * refactor(emotion): basic action & panel style * refactor(comment): style adjust * refactor(comment): emotion UX with server * refactor(comment): reply emotion UX done
1 parent b0aaba3 commit bfc9df7

File tree

111 files changed

+992
-1865
lines changed

Some content is hidden

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

111 files changed

+992
-1865
lines changed

src/components/ArtimentBody/FoldBox.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ type TProps = {
1212

1313
const FoldBox: FC<TProps> = ({ fold, onFold, onExpand, mode }) => {
1414
return (
15-
<Wrapper fold={fold} onClick={() => (fold ? onExpand() : onFold())}>
15+
<Wrapper
16+
fold={fold}
17+
mode={mode}
18+
onClick={() => (fold ? onExpand() : onFold())}
19+
>
1620
{!fold && (
1721
<FoldHint mode={mode}>
1822
折叠

src/components/ArtimentBody/styles/fold_box.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import Img from '@/Img'
44
// import { theme } from '@/utils/themes'
55
import css from '@/utils/css'
66

7-
export const Wrapper = styled.div<{ fold: boolean }>`
7+
type TWrapper = { fold: boolean; mode: 'article' | 'comment' }
8+
export const Wrapper = styled.div<TWrapper>`
89
${css.flex('align-both')};
9-
width: 100%;
10+
width: ${({ mode }) => (mode === 'article' ? '100%' : '96%')};
1011
margin-top: 28px;
1112
margin-bottom: 28px;
1213
padding: 5px 0;

src/components/Buttons/FollowButton/FollowingBtn.tsx

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

33
import { TSIZE_TSM } from '@/spec'
4-
import { ICON } from '@/config'
54

65
import { LavaLampLoading } from '@/components/dynamic'
76
import Tooltip from '@/components/Tooltip'
87

98
import {
109
BtnWrapper,
1110
Popinfo,
12-
CheckedIcon,
11+
FollowingIcon,
1312
FollowingButton,
1413
} from '../styles/follow_button'
1514

1615
type TProps = {
1716
size: TSIZE_TSM
1817
loading: boolean
18+
followingOffset: number
1919
text: string
2020
onClick: () => void
2121
}
2222

23-
const FollowingBtn: FC<TProps> = ({ size, loading, text, onClick }) => {
23+
const FollowingBtn: FC<TProps> = ({
24+
size,
25+
loading,
26+
followingOffset,
27+
text,
28+
onClick,
29+
}) => {
2430
return (
2531
<>
2632
{loading ? (
@@ -34,13 +40,14 @@ const FollowingBtn: FC<TProps> = ({ size, loading, text, onClick }) => {
3440
>
3541
<FollowingButton
3642
size={size}
43+
followingOffset={followingOffset}
3744
type="primary"
3845
ghost
3946
onClick={onClick}
4047
noBorder
4148
>
4249
<BtnWrapper>
43-
<CheckedIcon src={`${ICON}/shape/checked.svg`} />
50+
<FollowingIcon />
4451
{text}
4552
</BtnWrapper>
4653
</FollowingButton>

src/components/Buttons/FollowButton/index.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,48 +19,51 @@ type TProps = {
1919
userId?: TID
2020
size?: TSIZE_TSM
2121
loading?: boolean
22-
fakeLoading?: boolean
22+
simuLoading?: boolean
2323
followText?: string
2424
followingText?: string
25+
followingOffset?: number
2526
onFollow?: (userId: TID) => void
2627
onUndoFollow?: (userId: TID) => void
2728
}
2829

2930
const FollowButton: FC<TProps> = ({
3031
userId,
3132
size = SIZE.SMALL,
32-
fakeLoading = false,
33+
simuLoading = true,
3334
loading = false,
3435
hasFollowed = false,
3536
followText = '关 注',
3637
followingText = '已关注',
38+
followingOffset = 0,
3739
onFollow = log,
3840
onUndoFollow = log,
3941
}) => {
40-
const [simuLoading, setSimuLoading] = useState(false)
41-
const isLoading = fakeLoading ? simuLoading : loading
42+
const [fakeLoading, setFakeLoading] = useState(false)
43+
const isLoading = simuLoading ? fakeLoading : loading
4244

4345
const handleFollow = useCallback(() => {
44-
if (fakeLoading) {
45-
setSimuLoading(true)
46-
setTimeout(() => setSimuLoading(false), 1500)
46+
if (simuLoading) {
47+
setFakeLoading(true)
48+
setTimeout(() => setFakeLoading(false), 1500)
4749
}
4850
onFollow(userId)
49-
}, [fakeLoading, onFollow, userId])
51+
}, [simuLoading, onFollow, userId])
5052

5153
const handleUndoFollow = useCallback(() => {
52-
if (fakeLoading) {
53-
setSimuLoading(true)
54-
setTimeout(() => setSimuLoading(false), 1500)
54+
if (simuLoading) {
55+
setFakeLoading(true)
56+
setTimeout(() => setFakeLoading(false), 1500)
5557
}
5658
onUndoFollow(userId)
57-
}, [fakeLoading, onUndoFollow, userId])
59+
}, [simuLoading, onUndoFollow, userId])
5860

5961
return (
6062
<>
6163
{hasFollowed ? (
6264
<FollowingBtn
6365
size={size}
66+
followingOffset={followingOffset}
6467
loading={isLoading}
6568
text={followingText}
6669
onClick={handleUndoFollow}

src/components/Buttons/styles/follow_button/index.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import animate from '@/utils/animations'
66
import Button from '@/components/Buttons/Button'
77
import Img from '@/Img'
88

9+
import JoinEyeSVG from '@/icons/JoinEye'
10+
911
export const BtnWrapper = styled.div`
1012
${css.flex('align-center')};
11-
padding: 2px 5px;
13+
padding: 2px 4px;
1214
`
1315
const BtnIcon = styled(Img)`
1416
${css.size(14)};
@@ -32,23 +34,31 @@ export const LoadingIcon = styled(BtnIcon)<{ light: boolean }>`
3234
${css.size(15)};
3335
animation: ${animate.rotate360} 1s linear infinite;
3436
`
35-
export const CheckedIcon = styled(BtnIcon)`
37+
export const FollowingIcon = styled(JoinEyeSVG)`
3638
fill: ${theme('baseColor.green')};
39+
${css.size(15)};
40+
margin-right: 3px;
41+
transform: scaleX(0.9);
42+
margin-top: -1px;
43+
${BtnWrapper}:hover & {
44+
fill: ${theme('thread.articleTitle')};
45+
}
3746
`
3847
export const FollowedButton = styled(Button)`
3948
border-radius: 10px;
4049
`
41-
export const FollowingButton = styled(Button)`
42-
color: ${theme('thread.articleTitle')};
43-
/* color: ${theme('baseColor.green')}; */
50+
export const FollowingButton = styled(Button)<{ followingOffset: number }>`
51+
color: ${theme('baseColor.green')};
52+
font-weight: bold;
4453
border: none;
45-
border-radius: 10px;
46-
background: #003745;
54+
border-radius: 8px;
55+
margin-left: ${({ followingOffset }) => `${followingOffset}px` || 0};
56+
/* background: #034556; */
4757
padding-top: 2px;
4858
padding-bottom: 2px;
4959
5060
&:hover {
51-
background: #003745;
52-
/* border: 1px solid; */
61+
color: ${theme('thread.articleTitle')};
62+
background: #034556;
5363
}
5464
`
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* CommunityJoinSign
3+
*/
4+
5+
import { FC, memo } from 'react'
6+
7+
import { ICON_CMD } from '@/config'
8+
import { buildLog } from '@/utils/logger'
9+
10+
import FollowButton from '@/components/Buttons/FollowButton'
11+
12+
import {
13+
Wrapper,
14+
PopContentWrapper,
15+
PopHeader,
16+
PopHeaderIcon,
17+
PopHeaderText,
18+
PopHighlight,
19+
} from './styles'
20+
21+
/* eslint-disable-next-line */
22+
const log = buildLog('c:VerifiedSign:index')
23+
24+
const PopContent = () => {
25+
return (
26+
<PopContentWrapper>
27+
<PopHeader>
28+
<PopHeaderIcon src={`${ICON_CMD}/verified.svg`} />
29+
<PopHeaderText>官方认证</PopHeaderText>
30+
</PopHeader>
31+
<div>
32+
我们已通过各种渠道证实该社区为{' '}
33+
<PopHighlight>communityTitle</PopHighlight> 官方开通
34+
</div>
35+
</PopContentWrapper>
36+
)
37+
}
38+
39+
// type TProps = {}
40+
41+
const CommunityJoinSign: FC = () => {
42+
const hasFollowed = false
43+
return (
44+
<Wrapper hasFollowed={hasFollowed}>
45+
<FollowButton
46+
followText="&nbsp;加 入&nbsp;"
47+
followingText="已加入"
48+
size="tiny"
49+
hasFollowed={hasFollowed}
50+
/>
51+
</Wrapper>
52+
)
53+
}
54+
55+
export default memo(CommunityJoinSign)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import styled from 'styled-components'
2+
3+
import Img from '@/Img'
4+
import { theme } from '@/utils/themes'
5+
import css from '@/utils/css'
6+
7+
export const Wrapper = styled.div<{ hasFollowed: boolean }>`
8+
${css.flex('align-center')};
9+
margin-left: ${({ hasFollowed }) => (hasFollowed ? '-8px' : '5px')};
10+
`
11+
export const PopContentWrapper = styled.div`
12+
text-align: left;
13+
width: 200px;
14+
font-size: 13px !important;
15+
line-height: 1.6;
16+
`
17+
export const PopHeader = styled.div`
18+
${css.flex('align-center')}
19+
margin-bottom: 10px;
20+
`
21+
export const PopHeaderIcon = styled(Img)`
22+
fill: ${theme('baseColor.green')};
23+
padding: 0;
24+
margin-right: 4px;
25+
${css.size(14)};
26+
`
27+
export const PopHeaderText = styled.div`
28+
color: ${theme('baseColor.green')};
29+
font-size: 13px;
30+
font-weight: bold;
31+
`
32+
export const PopHighlight = styled.span`
33+
font-size: 14px;
34+
font-weight: bold;
35+
`

src/containers/editor/PostEditor/tests/index.test.ts renamed to src/components/CommunityJoinSign/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 PostEditor from '../index'
4+
// import VerifiedSign from '../index'
55

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

src/components/CommunityStatesPad/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ const CommunityStatesPad: FC<TProps> = ({
4040
onShowSubscriberList = log,
4141
withoutFounding = true,
4242
}) => {
43-
const { editorsCount, subscribersCount, viewerHasSubscribed } = community
43+
const { editorsCount, subscribersCount } = community
4444
const { isMobile } = usePlatform()
4545
const contentsCount = getContentCount(community)
4646

4747
return (
4848
<Wrapper>
49-
<NumberSection active={viewerHasSubscribed}>
49+
<NumberSection>
5050
{!isMobile && <NumberTitle>成员</NumberTitle>}
5151
<NumberGroup
5252
count={subscribersCount}

src/components/CommunityStatesPad/styles/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import styled from 'styled-components'
22

3-
import type { TActive } from '@/spec'
43
// import Img from '@/Img'
54
import { theme } from '@/utils/themes'
65
import css from '@/utils/css'
@@ -12,11 +11,9 @@ export const Wrapper = styled.div`
1211
margin-top: -4px;
1312
`};
1413
`
15-
type TNumberSection = TActive & { readOnly?: boolean }
14+
type TNumberSection = { readOnly?: boolean }
1615
export const NumberSection = styled.div<TNumberSection>`
1716
${css.flexColumn('align-end')};
18-
background-color: ${({ active }) =>
19-
active ? theme('banner.numberHoverBg') : ''};
2017
2118
padding: 0 5px;
2219
border-radius: 4px;

0 commit comments

Comments
 (0)