66
77import { memo , FC } from 'react'
88import Router from 'next/router'
9+ import { isEmpty } from 'ramda'
910
10- import type { TThread } from '@/spec'
11+ import type { TThread , TPublishMode } from '@/spec'
12+ import { THREAD , HCN , SVG , PUBLISH_MODE } from '@/constant'
1113
12- import { THREAD , HCN } from '@/constant'
1314import { buildLog } from '@/utils/logger'
1415import { authWarn } from '@/utils/helper'
1516import { useAccount } from '@/hooks'
1617
18+ import { MORE_MENU } from './constant'
19+ import IconButton from '../IconButton'
20+ import MenuButton from '../MenuButton'
21+
1722import PostLayout from './PostLayout'
1823import WorksLayout from './WorksLayout'
1924
20- import { Wrapper , PubButton } from '../styles/publish_button'
25+ import { Wrapper , PubButton , MoreOption } from '../styles/publish_button'
2126import { getTargetPage , getText } from './helper'
2227
2328/* eslint-disable-next-line */
@@ -27,15 +32,20 @@ type TProps = {
2732 thread ?: TThread
2833 community ?: string
2934 text ?: string
35+ mode ?: TPublishMode
3036}
3137
3238const PublishButton : FC < TProps > = ( {
3339 thread = THREAD . POST ,
3440 community = HCN ,
3541 text = getText ( thread ) ,
42+ mode = PUBLISH_MODE . DEFAULT ,
3643} ) => {
3744 const accountInfo = useAccount ( )
3845
46+ const menuOptions = MORE_MENU [ mode ]
47+ const hasNoMenu = isEmpty ( menuOptions )
48+
3949 return (
4050 < Wrapper >
4151 < PubButton
@@ -51,6 +61,17 @@ const PublishButton: FC<TProps> = ({
5161 < PostLayout text = { text } />
5262 ) }
5363 </ PubButton >
64+ { ! hasNoMenu && (
65+ < MoreOption >
66+ < MenuButton
67+ placement = "bottom-end"
68+ options = { menuOptions }
69+ offset = { [ - 5 , 14 ] }
70+ >
71+ < IconButton icon = { SVG . MOREL } />
72+ </ MenuButton >
73+ </ MoreOption >
74+ ) }
5475 </ Wrapper >
5576 )
5677}
0 commit comments