diff --git a/package.json b/package.json index 1318686b14..ca58b7ea8d 100644 --- a/package.json +++ b/package.json @@ -265,4 +265,4 @@ ] }, "pre-commit": "lint:staged" -} +} \ No newline at end of file diff --git a/src/components/flyout/index.js b/src/components/flyout/index.js index f04c3f6386..25c530bf1d 100644 --- a/src/components/flyout/index.js +++ b/src/components/flyout/index.js @@ -14,7 +14,7 @@ const StyledFlyout = styled(FlexRow)` top: 36px; z-index: ${zIndex.flyout}; color: ${({ theme }) => theme.text.default}; - transition: ${Transition.dropdown.off}; + ${props => props.style}; `; const StyledRow = styled(FlexCol)` diff --git a/src/views/thread/components/actionBar.js b/src/views/thread/components/actionBar.js index 3949da36ef..b4e65e8d55 100644 --- a/src/views/thread/components/actionBar.js +++ b/src/views/thread/components/actionBar.js @@ -2,6 +2,7 @@ import * as React from 'react'; import { connect } from 'react-redux'; import Clipboard from 'react-clipboard.js'; +import { Manager, Reference, Popper } from 'react-popper'; import { addToastWithTimeout } from '../../../actions/toasts'; import { openModal } from '../../../actions/modals'; import Icon from '../../../components/icons'; @@ -11,6 +12,8 @@ import Flyout from '../../../components/flyout'; import { track } from '../../../helpers/events'; import type { GetThreadType } from 'shared/graphql/queries/thread/getThread'; import toggleThreadNotificationsMutation from 'shared/graphql/mutations/thread/toggleThreadNotifications'; +import OutsideClickHandler from '../../../components/outsideClickHandler'; + import { FollowButton, ShareButtons, @@ -42,11 +45,19 @@ type Props = { type State = { notificationStateLoading: boolean, flyoutOpen: boolean, + isSettingsBtnHovering: boolean, }; class ActionBar extends React.Component { state = { notificationStateLoading: false, flyoutOpen: false, + isSettingsBtnHovering: false, + }; + + toggleHover = () => { + this.setState(({ isSettingsBtnHovering }) => ({ + isSettingsBtnHovering: !isSettingsBtnHovering, + })); }; toggleFlyout = val => { @@ -216,7 +227,11 @@ class ActionBar extends React.Component { isLockingThread, isPinningThread, } = this.props; - const { notificationStateLoading, flyoutOpen } = this.state; + const { + notificationStateLoading, + flyoutOpen, + isSettingsBtnHovering, + } = this.state; const isPinned = thread.community.pinnedThreadId === thread.id; const shouldRenderActionsDropdown = this.shouldRenderActionsDropdown(); @@ -350,129 +365,158 @@ class ActionBar extends React.Component {
{shouldRenderActionsDropdown && ( - - - - - - {thread.receiveNotifications ? 'Subscribed' : 'Notify me'} - - - - {shouldRenderEditThreadAction && ( - - - - - - )} - - {shouldRenderPinThreadAction && ( - - - - - - )} - - {shouldRenderMoveThreadAction && ( - - - Move thread - - - )} - - {shouldRenderLockThreadAction && ( - - - - - - )} - - {shouldRenderDeleteThreadAction && ( - - + + + {({ ref }) => { + return ( + + ); + }} + + {(isSettingsBtnHovering || flyoutOpen) && ( + + - - - + {({ style, ref, placement }) => { + return ( + + + + {thread.receiveNotifications + ? 'Subscribed' + : 'Notify me'} + + + + {shouldRenderEditThreadAction && ( + + + + + + )} + + {shouldRenderPinThreadAction && ( + + + + + + )} + + {shouldRenderMoveThreadAction && ( + + + Move thread + + + )} + + {shouldRenderLockThreadAction && ( + + + + + + )} + + {shouldRenderDeleteThreadAction && ( + + + + + + )} + + ); + }} + + )} - + )}
- {flyoutOpen && ( -
- setTimeout(() => { - this.toggleFlyout(false); - }) - } - /> - )} ); } diff --git a/src/views/thread/style.js b/src/views/thread/style.js index f0232b7fac..76da42bf19 100644 --- a/src/views/thread/style.js +++ b/src/views/thread/style.js @@ -184,17 +184,9 @@ export const DropWrap = styled(FlexCol)` } .flyout { - display: none; position: absolute; - top: 100%; - right: 0; - transition: ${Transition.hover.off}; - } - - &:hover .flyout, - &.open > .flyout { - display: inline-block; - transition: ${Transition.hover.on}; + right: auto; + width: 200px; } `;