|
| 1 | +import { FC, memo } from 'react' |
| 2 | + |
| 3 | +import { ICON } from '@/config' |
| 4 | +import { SVG } from '@/constant' |
| 5 | + |
| 6 | +import IconButton from '@/widgets/Buttons/IconButton' |
| 7 | +import { IconSwitcher } from '@/widgets/Switcher' |
| 8 | + |
| 9 | +import { MODE, API_MODE } from '../../constant' |
| 10 | + |
| 11 | +import type { TMode } from '../../spec' |
| 12 | +import type { TProps as TBase } from '../index' |
| 13 | + |
| 14 | +import { Wrapper } from '../../styles/head_bar/state_bar/actions' |
| 15 | +import { foldAllComments, expandAllComments, onModeChange } from '../../logic' |
| 16 | + |
| 17 | +type TProps = Pick<TBase, 'mode' | 'apiMode' | 'isAllFolded'> |
| 18 | + |
| 19 | +const actionIconConfig = { |
| 20 | + right: 11, |
| 21 | + hintDelay: 200, |
| 22 | +} |
| 23 | + |
| 24 | +const switchItems = [ |
| 25 | + { |
| 26 | + key: MODE.REPLIES, |
| 27 | + iconSrc: `${ICON}/article/comment-reply-mode.svg`, |
| 28 | + desc: '回复模式', |
| 29 | + }, |
| 30 | + { |
| 31 | + key: MODE.TIMELINE, |
| 32 | + iconSrc: `${ICON}/article/comment-timeline-mode.svg`, |
| 33 | + desc: '时间线模式', |
| 34 | + }, |
| 35 | +] |
| 36 | + |
| 37 | +const Actions: FC<TProps> = ({ mode, isAllFolded, apiMode }) => { |
| 38 | + return ( |
| 39 | + <Wrapper> |
| 40 | + {/* {apiMode === API_MODE.ARTICLE && ( |
| 41 | + <IconButton |
| 42 | + icon={SVG.LOCK} |
| 43 | + hint="关闭讨论" |
| 44 | + {...actionIconConfig} |
| 45 | + top={-1} |
| 46 | + /> |
| 47 | + )} */} |
| 48 | + |
| 49 | + {/* {apiMode === API_MODE.ARTICLE && ( |
| 50 | + <IconButton |
| 51 | + path="article/notify-on.svg" |
| 52 | + hint="订阅讨论" |
| 53 | + {...actionIconConfig} |
| 54 | + /> |
| 55 | + )} */} |
| 56 | + |
| 57 | + {isAllFolded ? ( |
| 58 | + <IconButton |
| 59 | + {...actionIconConfig} |
| 60 | + icon={SVG.EXPAND} |
| 61 | + size={13} |
| 62 | + hint="展开全部" |
| 63 | + active |
| 64 | + onClick={expandAllComments} |
| 65 | + /> |
| 66 | + ) : ( |
| 67 | + <IconButton |
| 68 | + icon={SVG.FOLD} |
| 69 | + {...actionIconConfig} |
| 70 | + size={13} |
| 71 | + hint="折叠全部" |
| 72 | + onClick={foldAllComments} |
| 73 | + /> |
| 74 | + )} |
| 75 | + |
| 76 | + {apiMode === API_MODE.ARTICLE && ( |
| 77 | + <IconSwitcher |
| 78 | + items={switchItems} |
| 79 | + activeKey={mode} |
| 80 | + onChange={({ key }) => onModeChange(key as TMode)} |
| 81 | + /> |
| 82 | + )} |
| 83 | + </Wrapper> |
| 84 | + ) |
| 85 | +} |
| 86 | + |
| 87 | +export default memo(Actions) |
0 commit comments