diff --git a/web/navigation-sidebar/account-settings-button.react.js b/web/navigation-sidebar/account-settings-button.react.js --- a/web/navigation-sidebar/account-settings-button.react.js +++ b/web/navigation-sidebar/account-settings-button.react.js @@ -6,8 +6,10 @@ import { useDispatch } from 'lib/utils/redux-utils.js'; import css from './account-settings-button.css'; +import { navigationSidebarLabelTooltipMargin } from './navigation-sidebar-constants.js'; import { updateNavInfoActionType } from '../redux/action-types.js'; import { useNavigationSidebarTooltip } from '../utils/tooltip-action-utils.js'; +import { tooltipPositions } from '../utils/tooltip-utils.js'; function AccountSettingsButton(): React.Node { const dispatch = useDispatch(); @@ -26,6 +28,8 @@ const { onMouseEnter, onMouseLeave } = useNavigationSidebarTooltip({ tooltipLabel: 'Settings', + position: tooltipPositions.RIGHT, + tooltipMargin: navigationSidebarLabelTooltipMargin, }); return ( diff --git a/web/navigation-sidebar/community-creation-button.react.js b/web/navigation-sidebar/community-creation-button.react.js --- a/web/navigation-sidebar/community-creation-button.react.js +++ b/web/navigation-sidebar/community-creation-button.react.js @@ -6,8 +6,10 @@ import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; import css from './community-creation-button.css'; +import { navigationSidebarLabelTooltipMargin } from './navigation-sidebar-constants.js'; import CommunityCreationModal from '../sidebar/community-creation/community-creation-modal.react.js'; import { useNavigationSidebarTooltip } from '../utils/tooltip-action-utils.js'; +import { tooltipPositions } from '../utils/tooltip-utils.js'; function CommunityCreationButton(): React.Node { const { pushModal } = useModalContext(); @@ -19,6 +21,8 @@ const { onMouseEnter, onMouseLeave } = useNavigationSidebarTooltip({ tooltipLabel: 'Create community', + position: tooltipPositions.RIGHT, + tooltipMargin: navigationSidebarLabelTooltipMargin, }); return ( diff --git a/web/navigation-sidebar/community-list-item.react.js b/web/navigation-sidebar/community-list-item.react.js --- a/web/navigation-sidebar/community-list-item.react.js +++ b/web/navigation-sidebar/community-list-item.react.js @@ -6,10 +6,12 @@ import type { ResolvedThreadInfo } from 'lib/types/thread-types.js'; import css from './community-list-item.css'; +import { navigationSidebarLabelTooltipMargin } from './navigation-sidebar-constants.js'; import ThreadAvatar from '../avatars/thread-avatar.react.js'; import UnreadBadge from '../components/unread-badge.react.js'; import { useSelector } from '../redux/redux-utils.js'; import { useNavigationSidebarTooltip } from '../utils/tooltip-action-utils.js'; +import { tooltipPositions } from '../utils/tooltip-utils.js'; type Props = { +threadInfo: ResolvedThreadInfo, @@ -36,6 +38,8 @@ const { onMouseEnter, onMouseLeave } = useNavigationSidebarTooltip({ tooltipLabel: threadInfo.uiName, + position: tooltipPositions.RIGHT, + tooltipMargin: navigationSidebarLabelTooltipMargin, }); return ( diff --git a/web/navigation-sidebar/navigation-sidebar-constants.js b/web/navigation-sidebar/navigation-sidebar-constants.js --- a/web/navigation-sidebar/navigation-sidebar-constants.js +++ b/web/navigation-sidebar/navigation-sidebar-constants.js @@ -1,8 +1,6 @@ // @flow -export const navigationSidebarTooltipContainerStyle = { - marginLeft: 24, -}; +export const navigationSidebarLabelTooltipMargin = 24; export const navigationSidebarTooltipStyle = { paddingTop: 8, diff --git a/web/navigation-sidebar/navigation-sidebar-home-button.react.js b/web/navigation-sidebar/navigation-sidebar-home-button.react.js --- a/web/navigation-sidebar/navigation-sidebar-home-button.react.js +++ b/web/navigation-sidebar/navigation-sidebar-home-button.react.js @@ -5,16 +5,20 @@ import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; import { unreadCount } from 'lib/selectors/thread-selectors.js'; +import { navigationSidebarLabelTooltipMargin } from './navigation-sidebar-constants.js'; import css from './navigation-sidebar-home-button.css'; import UnreadBadge from '../components/unread-badge.react.js'; import { useSelector } from '../redux/redux-utils.js'; import { useNavigationSidebarTooltip } from '../utils/tooltip-action-utils.js'; +import { tooltipPositions } from '../utils/tooltip-utils.js'; function NavigationSidebarHomeButton(): React.Node { const unreadCountValue = useSelector(unreadCount); const { onMouseEnter, onMouseLeave } = useNavigationSidebarTooltip({ tooltipLabel: 'Home', + position: tooltipPositions.RIGHT, + tooltipMargin: navigationSidebarLabelTooltipMargin, }); const unreadBadge = React.useMemo(() => { diff --git a/web/navigation-sidebar/navigation-sidebar-toolitp.react.js b/web/navigation-sidebar/navigation-sidebar-toolitp.react.js --- a/web/navigation-sidebar/navigation-sidebar-toolitp.react.js +++ b/web/navigation-sidebar/navigation-sidebar-toolitp.react.js @@ -1,26 +1,58 @@ // @flow +import classNames from 'classnames'; import * as React from 'react'; -import { - navigationSidebarTooltipContainerStyle, - navigationSidebarTooltipStyle, -} from './navigation-sidebar-constants.js'; +import { navigationSidebarTooltipStyle } from './navigation-sidebar-constants.js'; import css from './navigation-sidebar-tooltip.css'; +import { + tooltipPositions, + type TooltipPosition, +} from '../utils/tooltip-utils.js'; type Props = { +tooltipLabel: string, + +position: TooltipPosition, + +tooltipMargin: number, }; function NavigationSidebarTooltip(props: Props): React.Node { - const { tooltipLabel } = props; + const { tooltipLabel, position, tooltipMargin } = props; + + const tooltipMarginStyle = React.useMemo(() => { + if (position === tooltipPositions.RIGHT) { + return { + marginLeft: tooltipMargin, + }; + } + if (position === tooltipPositions.LEFT) { + return { + marginRight: tooltipMargin, + }; + } + if (position === tooltipPositions.BOTTOM) { + return { + marginTop: tooltipMargin, + }; + } + if (position === tooltipPositions.TOP) { + return { + marginBottom: tooltipMargin, + }; + } + return null; + }, [position, tooltipMargin]); + + const arrowClassName = classNames(css.arrow, { + [css.arrowLeft]: position === tooltipPositions.RIGHT, + [css.arrowRight]: position === tooltipPositions.LEFT, + [css.arrowTop]: position === tooltipPositions.BOTTOM, + [css.arrowBottom]: position === tooltipPositions.TOP, + }); return ( -