Skip to content

Commit

Permalink
Merge pull request #5 from nickoferrall/update-tooltip
Browse files Browse the repository at this point in the history
Update naming and org file
  • Loading branch information
nickoferrall authored May 25, 2020
2 parents 49aaf7c + 7943bdf commit f911a3b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ const DeleteIconButton = styled(IconButton)<{disabled?: boolean}>(({disabled}) =
}))

const IconBlock = styled('div')({
display: 'flex',
alignItems: 'center',
display: 'flex',
justifyContent: 'center',
marginRight: '4px',
width: '2rem',
'&:active': {
opacity: 0.8
opacity: 0.7
},
'&:hover': {
cursor: 'pointer'
Expand Down Expand Up @@ -105,10 +105,10 @@ interface Props {
activeMeetings: AgendaItem_activeMeetings
agendaItem: AgendaItem_agendaItem
gotoStageId: ReturnType<typeof useGotoStageId> | undefined
hoveringId: string
hoveringId: string | null
isDragging: boolean
meetingId?: string | null
updateHoveringId: (id: string) => void
updateHoveringId: (id: string | null) => void
}

const AgendaItem = (props: Props) => {
Expand All @@ -132,7 +132,7 @@ const AgendaItem = (props: Props) => {
const {picture} = teamMember
const atmosphere = useAtmosphere()
const {viewerId} = atmosphere
const hovering = hoveringId === agendaItemId
const isHovering = hoveringId === agendaItemId
const closedTooltipStatus = 4
const ref = useRef<HTMLDivElement>(null)
const {
Expand All @@ -151,8 +151,8 @@ const AgendaItem = (props: Props) => {
useEffect(() => {
// if the tooltip has closed and we're not hovering in a new item, remove hover
// this is required because onMouseLeave isn't triggered if the cursor moves over the tooltip
if (tooltipStatus === closedTooltipStatus && hovering) {
updateHoveringId('')
if (tooltipStatus === closedTooltipStatus && isHovering) {
updateHoveringId(null)
}
}, [tooltipStatus])

Expand All @@ -169,27 +169,27 @@ const AgendaItem = (props: Props) => {
RemoveAgendaItemMutation(atmosphere, {agendaItemId})
}

const handleMouseMove = () => {
const handleMouseMoveItem = () => {
// onMouseEnter isn't triggered if the cursor quickly moves over tooltip so check onMouseMove
if (!hovering) {
if (!isHovering) {
updateHoveringId(agendaItemId)
}
}

const handleMouseMoveIcon = () => {
if (hovering && tooltipStatus === closedTooltipStatus) {
if (isHovering && tooltipStatus === closedTooltipStatus) {
openTooltip()
}
}

const getIcon = () => {
if (pinned && hovering) return <SvgIcon alt='unpinIcon' src={unpinIcon} />
else if (!pinned && !hovering) return <Avatar hasBadge={false} picture={picture} size={24} />
if (pinned && isHovering) return <SvgIcon alt='unpinIcon' src={unpinIcon} />
else if (!pinned && !isHovering) return <Avatar hasBadge={false} picture={picture} size={24} />
else return <SvgIcon alt='pinnedIcon' src={pinIcon} />
}

return (
<AgendaItemStyles onMouseMove={handleMouseMove}>
<AgendaItemStyles onMouseMove={handleMouseMoveItem}>
<MeetingSubnavItem
label={content}
metaContent={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface Props {
const AgendaList = (props: Props) => {
const atmosphere = useAtmosphere()
const {dashSearch, gotoStageId, meetingId, team} = props
const [hoveringId, setHoveringId] = useState('')
const [hoveringId, setHoveringId] = useState<string | null>(null)
const {activeMeetings, agendaItems} = team
const filteredAgendaItems = useMemo(() => {
return dashSearch ? agendaItems.filter(({content}) => content.match(dashSearch)) : agendaItems
Expand Down Expand Up @@ -82,7 +82,7 @@ const AgendaList = (props: Props) => {
setHoveringId('')
}

const updateHoveringId = (id: string) => {
const updateHoveringId = (id: string | null) => {
setHoveringId(id)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,20 @@ const OrgMemberRow = (props: Props) => {
})
}
}

const {tooltipPortal, openTooltip, closeTooltip, originRef: tooltipRef} = useTooltip<
HTMLDivElement
>(MenuPosition.LOWER_RIGHT)

const handleMouseOver = (e: React.MouseEvent) => {
e.stopPropagation()
openTooltip()
}

const handleMouseOut = (e: React.MouseEvent) => {
e.stopPropagation()
closeTooltip()
}

return (
<StyledRow>
<AvatarBlock>
Expand All @@ -173,11 +183,9 @@ const OrgMemberRow = (props: Props) => {
<RowActions>
<ActionsBlock>
{!isBillingLeader && viewerId === userId && (
<>
<StyledFlatButton onClick={toggleLeave} onMouseEnter={LeaveOrgModal.preload}>
Leave Organization
</StyledFlatButton>
</>
<StyledFlatButton onClick={toggleLeave} onMouseEnter={LeaveOrgModal.preload}>
Leave Organization
</StyledFlatButton>
)}
{isProTier && isViewerBillingLeader && (
<ToggleBlock>
Expand All @@ -187,8 +195,8 @@ const OrgMemberRow = (props: Props) => {
{isViewerLastBillingLeader && userId === viewerId && (
<MenuToggleBlock
onClick={closeTooltip}
onMouseEnter={openTooltip}
onMouseLeave={closeTooltip}
onMouseOver={handleMouseOver}
onMouseOut={handleMouseOut}
ref={tooltipRef}
>
{tooltipPortal(
Expand Down

0 comments on commit f911a3b

Please sign in to comment.