This repository was archived by the owner on Nov 8, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork37
feat(comment): actions menu button#1127
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
10 commits Select commitHold shift + click to select a range
95b564f
fix(copy-button): avoid un-expected animation with value change
mydearxyme6ea909
fix(tooltip): z-index edge case
mydearxymfb6ebfc
fix(switcher-icon): active style adjust
mydearxym357d7e2
fix(report): reset view on close
mydearxymcd6a31b
feat(comment): basic fold/extand UI/UX
mydearxymede85fd
feat(comment): range bar wip
mydearxym23be7e7
refactor(fold): UX & re-design looks
mydearxymee7e319
fix: mini
mydearxym697c990
feat(comment): put action into menu
mydearxym31d6bdd
feat(comment): put action into menu
mydearxymFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 0 additions & 1 deletionsrc/components/Buttons/DropdownButton/OptionPanel.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { FC, memo } from 'react' | ||
import { ICON } from '@/config' | ||
import { cutRest } from '@/utils' | ||
76 changes: 76 additions & 0 deletionssrc/components/Buttons/MenuButton/Menu.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { FC, memo } from 'react' | ||
import { isEmpty } from 'ramda' | ||
import { ICON } from '@/config' | ||
import { cutRest } from '@/utils' | ||
import type { TOption } from './index' | ||
import { | ||
Wrapper, | ||
Block, | ||
BlockA, | ||
Item, | ||
Icon, | ||
Title, | ||
LinkIcon, | ||
Divider, | ||
} from '../styles/menu_button/menu' | ||
// there is two types of block, normal block and link | ||
const OptionBlock = ({ item, onClick }) => { | ||
if (item.link) { | ||
return ( | ||
<BlockA as="a" href={item.link}> | ||
<Item> | ||
<Icon src={item.icon} /> | ||
<Title>{cutRest(item.title, 50)}</Title> | ||
<LinkIcon src={`${ICON}/shape/link-hint.svg`} /> | ||
</Item> | ||
</BlockA> | ||
) | ||
} | ||
return ( | ||
<Block onClick={onClick}> | ||
<Item> | ||
<Icon src={item.icon} /> | ||
<Title>{cutRest(item.title, 50)}</Title> | ||
</Item> | ||
</Block> | ||
) | ||
} | ||
type TProps = { | ||
options: TOption[] | ||
extraOptions: TOption[] | ||
panelMinWidth: string | ||
onClick?: (key?: string) => void | ||
} | ||
const Menu: FC<TProps> = ({ | ||
options, | ||
extraOptions, | ||
onClick, | ||
panelMinWidth, | ||
}) => { | ||
return ( | ||
<Wrapper panelMinWidth={panelMinWidth}> | ||
{options.map((item) => ( | ||
<OptionBlock | ||
key={item.key} | ||
item={item} | ||
onClick={() => onClick(item.key)} | ||
/> | ||
))} | ||
{!isEmpty(extraOptions) && <Divider />} | ||
{extraOptions.map((item) => ( | ||
<OptionBlock | ||
key={item.key} | ||
item={item} | ||
onClick={() => onClick(item.key)} | ||
/> | ||
))} | ||
</Wrapper> | ||
) | ||
} | ||
export default memo(Menu) |
59 changes: 59 additions & 0 deletionssrc/components/Buttons/MenuButton/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { FC, ReactNode, memo } from 'react' | ||
import { buildLog } from '@/utils' | ||
import type { TTooltipPlacement } from '@/spec' | ||
import Tooltip from '@/components/Tooltip' | ||
import Menu from './Menu' | ||
// import { Wrapper } from '../styles/menu_button' | ||
const log = buildLog('C:MenuButton') | ||
export type TOption = { | ||
title: string | ||
key: string | ||
icon?: string | ||
link?: string | ||
} | ||
type TProps = { | ||
children: ReactNode | ||
options: TOption[] | ||
extraOptions: TOption[] | ||
placement?: TTooltipPlacement | ||
panelMinWidth?: string | ||
onClick: (key?: string) => void | ||
} | ||
const MenuButton: FC<TProps> = ({ | ||
children, | ||
options, | ||
extraOptions = [], | ||
onClick = log, | ||
placement = 'top-end', | ||
panelMinWidth = '100px', | ||
}) => { | ||
return ( | ||
<Tooltip | ||
placement={placement} | ||
trigger="click" | ||
hideOnClick | ||
content={ | ||
<Menu | ||
options={options} | ||
extraOptions={extraOptions} | ||
onClick={onClick} | ||
panelMinWidth={panelMinWidth} | ||
/> | ||
} | ||
noPadding | ||
> | ||
{children} | ||
</Tooltip> | ||
) | ||
} | ||
export default memo(MenuButton) |
1 change: 1 addition & 0 deletionssrc/components/Buttons/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletionssrc/components/Buttons/styles/menu_button/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import styled from 'styled-components' | ||
import { css } from '@/utils' | ||
export const Wrapper = styled.div` | ||
${css.flex('align-center')}; | ||
width: 100%; | ||
position: relative; | ||
` | ||
export const Holder = 1 |
60 changes: 60 additions & 0 deletionssrc/components/Buttons/styles/menu_button/menu.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import styled from 'styled-components' | ||
import Img from '@/Img' | ||
import { css, theme } from '@/utils' | ||
export const Wrapper = styled.div<{ panelMinWidth: string }>` | ||
${css.flexColumn('align-center')}; | ||
width: 100%; | ||
min-width: ${({ panelMinWidth }) => panelMinWidth}; | ||
max-height: 300px; | ||
overflow: hidden; | ||
` | ||
export const Block = styled.div` | ||
${css.flex('align-start')}; | ||
width: 100%; | ||
padding: 6px 10px; | ||
padding-left: 15px; | ||
&:hover { | ||
background: #0d3e4e; | ||
cursor: pointer; | ||
} | ||
` | ||
export const Divider = styled.div` | ||
width: 100%; | ||
height: 1px; | ||
background: #0d3e4e; | ||
margin-top: 3px; | ||
margin-bottom: 3px; | ||
` | ||
export const BlockA = styled(Block)` | ||
text-decoration: none; | ||
` | ||
export const Item = styled.div` | ||
${css.flex('align-center')}; | ||
` | ||
export const Icon = styled(Img)` | ||
fill: ${theme('thread.articleDigest')}; | ||
${css.size(12)}; | ||
margin-right: 10px; | ||
opacity: 0.8; | ||
${Item}:hover & { | ||
opacity: 1; | ||
} | ||
` | ||
export const Title = styled.div` | ||
color: ${theme('thread.articleTitle')}; | ||
font-size: 13px; | ||
` | ||
export const LinkIcon = styled(Img)` | ||
${css.size(10)}; | ||
fill: ${theme('thread.articleDigest')}; | ||
margin-left: 7px; | ||
` | ||
export const Desc = styled.div` | ||
color: ${theme('thread.articleDigest')}; | ||
font-size: 11px; | ||
margin-top: 4px; | ||
` |
80 changes: 69 additions & 11 deletionssrc/containers/unit/Comments/Comment/Actions.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
15 changes: 3 additions & 12 deletionssrc/containers/unit/Comments/Comment/DesktopView/DefaultLayout.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletionssrc/containers/unit/Comments/Comment/DesktopView/FoldLayout.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletionsrc/containers/unit/Comments/Comment/DesktopView/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -12,7 +12,6 @@ type TProps = { | ||
accountInfo: TAccount | ||
tobeDeleteId: string | ||
hasReplies?: boolean | ||
foldedIds: TID[] | ||
} | ||
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.