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

Commit 8f2f27f

Browse files
authored
refactor(publish-button): publish button route (#1200)
* refactor(publish-button): re-org & unify publish needs * refactor(publish-button): target path adjust
1 parent 053d292 commit 8f2f27f

File tree

26 files changed

+286
-172
lines changed

26 files changed

+286
-172
lines changed

src/containers/content/WorksContent/RightSidebar/index.tsx

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

3-
import { ICON, ICON_CMD } from '@/config'
4-
3+
import { THREAD } from '@/constant'
54
import { Br } from '@/widgets/Common'
6-
import DropdownButton from '@/widgets/Buttons/DropdownButton'
5+
import PublishButton from '@/widgets/Buttons/PublishButton'
76
import SubTitle from '@/widgets/SubTitle'
87
import EmailSubscriber from '@/widgets/EmailSubscriber'
98

@@ -15,28 +14,12 @@ import {
1514
Wrapper,
1615
SubDesc,
1716
Divider,
18-
PublishIcon,
1917
PublishBtnWrapper,
2018
InterviewsWrapper,
2119
SubscribeWrapper,
2220
Footer,
2321
} from '../styles/right_sidebar/index'
2422

25-
const options = [
26-
{
27-
key: '0',
28-
icon: `${ICON_CMD}/common_check.svg`,
29-
title: '发布作品',
30-
desc: '像世界分享你的创意 ..',
31-
},
32-
{
33-
key: '1',
34-
icon: `${ICON_CMD}/common_link.svg`,
35-
title: '发布限制',
36-
desc: '原则上不欢迎此类内容',
37-
},
38-
]
39-
4023
type TProps = {
4124
testid?: string
4225
showSidebar: boolean
@@ -52,15 +35,10 @@ const RightSidebar: FC<TProps> = ({
5235
{/* <Linkers /> */}
5336
{/* <Divider top={18} bottom={22} /> */}
5437
<PublishBtnWrapper>
55-
<DropdownButton
56-
options={options}
57-
onClick={(key) => {
58-
console.log('key: ', key)
59-
}}
60-
>
61-
<PublishIcon src={`${ICON}/edit/publish-rocket.svg`} />
62-
{showSidebar ? '发 布' : '发布新作品'}
63-
</DropdownButton>
38+
<PublishButton
39+
thread={THREAD.WORKS}
40+
text={showSidebar ? '发 布' : '发布新作品'}
41+
/>
6442
</PublishBtnWrapper>
6543
<Br top={16} bottom={20} />
6644
<InterviewsWrapper>

src/containers/content/WorksContent/styles/right_sidebar/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import styled from 'styled-components'
22

33
import type { TTestable, TSpace } from '@/spec'
4-
import Img from '@/Img'
4+
// import Img from '@/Img'
55
import { theme } from '@/utils/themes'
66
import css from '@/utils/css'
77

@@ -33,11 +33,7 @@ export const Divider = styled.div<TSpace>`
3333
margin-bottom: ${({ bottom }) => `${bottom}px` || '15px'};
3434
opacity: 0.6;
3535
`
36-
export const PublishIcon = styled(Img)`
37-
fill: ${theme('button.fg')};
38-
${css.size(16)};
39-
margin-right: 10px;
40-
`
36+
4137
export const PublishBtnWrapper = styled.div`
4238
margin-left: 2px;
4339
margin-right: 2px;

src/containers/thread/ThreadSidebar/ClassicLayout/DynamicPart.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,43 @@
88

99
import { FC, memo } from 'react'
1010

11+
import type { TThread, TCommunity } from '@/spec'
12+
1113
import { buildLog } from '@/utils/logger'
1214
import { send } from '@/utils/helper'
1315
import { EVENT } from '@/constant'
1416

15-
import type { TThread } from '@/spec'
16-
1717
import Sticky from '@/widgets/Sticky'
1818
// import FiltersMenu from '@/widgets/FiltersMenu'
1919
import PublishButton from '@/widgets/Buttons/PublishButton'
2020
import CommunityJoinBadge from '@/containers/tool/CommunityJoinBadge'
2121
import TagsBar from '@/containers/unit/TagsBar'
2222
// import PromotionList from '@/widgets/PromotionList'
2323

24-
import type { TBaseProps } from '../index'
25-
2624
import {
2725
BadgeWrapper,
2826
TagsBarWrapper,
2927
PublishWrapper,
3028
} from '../styles/classic_layout'
31-
import { onCreate } from '../logic'
3229

3330
/* eslint-disable-next-line */
3431
const log = buildLog('c:ClassicSidebar')
3532

36-
type TProps = { showCommunityBadge: boolean; thread: TThread } & TBaseProps
33+
export type TProps = {
34+
showCommunityBadge: boolean
35+
thread: TThread
36+
community: TCommunity
37+
}
3738

38-
const ClassicLayout: FC<TProps> = ({ showCommunityBadge, thread }) => {
39+
const ClassicLayout: FC<TProps> = ({
40+
community,
41+
thread,
42+
showCommunityBadge,
43+
}) => {
3944
return (
4045
<Sticky offsetTop={50}>
4146
<PublishWrapper show={showCommunityBadge}>
42-
<PublishButton thread={thread} onCreate={onCreate} />
47+
<PublishButton thread={thread} community={community.raw} />
4348
</PublishWrapper>
4449
<BadgeWrapper show={!showCommunityBadge}>
4550
<CommunityJoinBadge />

src/containers/thread/ThreadSidebar/ClassicLayout/index.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import { FC, memo } from 'react'
1010
import dynamic from 'next/dynamic'
1111

12-
import type { TThread } from '@/spec'
12+
import type { TThread, TCommunity } from '@/spec'
1313
import { buildLog } from '@/utils/logger'
1414

1515
import { LavaLampLoading } from '@/widgets/dynamic'
@@ -33,12 +33,24 @@ export const DynamicPart = dynamic(() => import('./DynamicPart'), {
3333
ssr: false,
3434
})
3535

36-
type TProps = { showCommunityBadge: boolean; thread: TThread } & TBaseProps
37-
38-
const ClassicLayout: FC<TProps> = ({ showCommunityBadge, thread }) => {
36+
export type TProps = {
37+
showCommunityBadge: boolean
38+
thread: TThread
39+
community: TCommunity
40+
} & TBaseProps
41+
42+
const ClassicLayout: FC<TProps> = ({
43+
showCommunityBadge,
44+
thread,
45+
community,
46+
}) => {
3947
return (
4048
<Wrapper testid="thread-sidebar">
41-
<DynamicPart thread={thread} showCommunityBadge={showCommunityBadge} />
49+
<DynamicPart
50+
community={community}
51+
thread={thread}
52+
showCommunityBadge={showCommunityBadge}
53+
/>
4254
</Wrapper>
4355
)
4456
}

src/containers/thread/ThreadSidebar/HolyGrailLayout/DynamicPart.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ import Sticky from '@/widgets/Sticky'
88
import TagsBar from '@/containers/unit/TagsBar'
99
import PublishButton from '@/widgets/Buttons/PublishButton'
1010

11+
import type { TProps } from './index'
1112
import ExtraInfo from './ExtraInfo'
1213

1314
// 没有各种外链接,打赏信息等的官方社区
1415

15-
const DynamicPart: FC = () => {
16+
const DynamicPart: FC<TProps> = ({ thread, community }) => {
1617
return (
1718
<Fragment>
1819
<ExtraInfo />
1920
<Br bottom={20} />
20-
<PublishButton />
21+
<PublishButton thread={thread} community={community.raw} />
2122
<Br bottom={25} />
2223
<Sticky offsetTop={80}>
2324
<TagsBar onSelect={() => send(EVENT.REFRESH_ARTICLES)} />

src/containers/thread/ThreadSidebar/HolyGrailLayout/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FC, memo } from 'react'
22
import dynamic from 'next/dynamic'
33

4-
import type { TCommunity } from '@/spec'
4+
import type { TCommunity, TThread } from '@/spec'
55

66
import CommunityBrief from './CommunityBrief'
77
import { LavaLampLoading } from '@/widgets/dynamic'
@@ -16,16 +16,17 @@ export const DynamicPart = dynamic(() => import('./DynamicPart'), {
1616
ssr: false,
1717
})
1818

19-
type TProps = {
19+
export type TProps = {
20+
thread: TThread
2021
community: TCommunity
2122
}
2223

23-
const HolyGrailLayout: FC<TProps> = ({ community }) => {
24+
const HolyGrailLayout: FC<TProps> = ({ community, thread }) => {
2425
return (
2526
<Wrapper testid="community-digest">
2627
<CommunityBrief community={community} />
2728
<Divider />
28-
<DynamicPart />
29+
<DynamicPart community={community} thread={thread} />
2930
</Wrapper>
3031
)
3132
}

src/containers/thread/ThreadSidebar/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ const ThreadSidebarContainer: FC<TProps> = ({ threadSidebar: store }) => {
3838
<ClassicLayout
3939
showCommunityBadge={isCommunityDigestInViewport}
4040
thread={curThread}
41+
community={curCommunity}
4142
/>
4243
) : (
43-
<HolyGrailLayout community={curCommunity} />
44+
<HolyGrailLayout community={curCommunity} thread={curThread} />
4445
)}
4546
</Fragment>
4647
)

src/containers/thread/ThreadSidebar/logic.ts

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

4-
import { TYPE, EVENT } from '@/constant'
5-
import { send } from '@/utils/helper'
64
import { buildLog } from '@/utils/logger'
75

86
// import S from './service'
@@ -13,13 +11,7 @@ let store: TStore | undefined
1311
/* eslint-disable-next-line */
1412
const log = buildLog('L:ThreadSidebar')
1513

16-
export const onCreate = (): void => {
17-
const { isLogin, curThread, authWarning } = store
18-
if (!isLogin) return authWarning()
19-
const cmd = `${curThread.toUpperCase()}_CREATE`
20-
21-
send(EVENT.DRAWER.OPEN, { type: TYPE.DRAWER[cmd] })
22-
}
14+
export const holder = 1
2315

2416
// ###############################
2517
// init & uninit handlers

src/containers/tool/CommunityTagSetter/CommunitySetter/Body.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const Body: FC<TProps> = ({
4545
<InnerWrapper>
4646
<SearchBox searchValue={searchValue} texts={texts} />
4747
{texts.notice ? (
48-
<NoticeBar type="notice" content={texts.notice} bottom={20} noBg />
48+
<NoticeBar type="notice" content={texts.notice} bottom={5} noBg />
4949
) : (
5050
<Br bottom={0}>&nbsp;</Br>
5151
)}

src/containers/tool/CommunityTagSetter/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ const CommunityTagSetter = T.model('CommunityTagSetter', {
171171
header: '请选择子社区',
172172
searchPlaceholder: '// 搜索目标社区',
173173
notice:
174-
'内测阶段所有人均可发布内容到首页。若测试请发布到「黑洞」。发布恶俗/恶意内容到社区,账号本身将进入「黑洞」,谢谢理解。',
174+
'内测阶段所有人均可发布内容到首页。若测试请发布到「黑洞」。发布恶俗 / 恶意内容到社区,账号本身将进入「黑洞」,谢谢理解。',
175175
commonUsedHint: '常用子社区',
176176
notFoundHint:
177177
'抱歉,未找到相关子社区,请在该评论区或子社区 /feedback 中反馈。',

0 commit comments

Comments
 (0)