Skip to content

Commit

Permalink
Disable graph tooltips on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
lubej committed Feb 21, 2023
1 parent 5a7cef3 commit 06ebf20
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 30 deletions.
8 changes: 8 additions & 0 deletions src/app/pages/HomePage/GraphTooltip/CipherTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ import AccessTimeIcon from '@mui/icons-material/AccessTime'
import { COLORS } from '../../../../styles/theme/colors'
import Typography from '@mui/material/Typography'
import { useTranslation } from 'react-i18next'
import useMediaQuery from '@mui/material/useMediaQuery'
import { useTheme } from '@mui/material/styles'

export const CipherTooltip: FC<GraphTooltipExtendedProps> = ({ children, offsetWidth, offsetHeight }) => {
const { t } = useTranslation()
const theme = useTheme()
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))

if (isMobile) {
return children
}

return (
<GraphTooltip
Expand Down
8 changes: 8 additions & 0 deletions src/app/pages/HomePage/GraphTooltip/ConsensusTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ import Typography from '@mui/material/Typography'
import { useTranslation } from 'react-i18next'
import AdjustIcon from '@mui/icons-material/Adjust'
import CheckCircleIcon from '@mui/icons-material/CheckCircle'
import { useTheme } from '@mui/material/styles'
import useMediaQuery from '@mui/material/useMediaQuery'

export const ConsensusTooltip: FC<GraphTooltipExtendedProps> = ({ children, offsetWidth, offsetHeight }) => {
const { t } = useTranslation()
const theme = useTheme()
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))

if (isMobile) {
return children
}

return (
<GraphTooltip
Expand Down
8 changes: 8 additions & 0 deletions src/app/pages/HomePage/GraphTooltip/EmeraldTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import Typography from '@mui/material/Typography'
import { useTranslation } from 'react-i18next'
import AdjustIcon from '@mui/icons-material/Adjust'
import CheckCircleIcon from '@mui/icons-material/CheckCircle'
import { useTheme } from '@mui/material/styles'
import useMediaQuery from '@mui/material/useMediaQuery'

export const EmeraldTooltip: FC<GraphTooltipExtendedProps> = ({
children,
Expand All @@ -24,6 +26,12 @@ export const EmeraldTooltip: FC<GraphTooltipExtendedProps> = ({
onClick,
}) => {
const { t } = useTranslation()
const theme = useTheme()
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))

if (isMobile) {
return children
}

return (
<GraphTooltip
Expand Down
8 changes: 8 additions & 0 deletions src/app/pages/HomePage/GraphTooltip/SapphireTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ import AccessTimeIcon from '@mui/icons-material/AccessTime'
import { COLORS } from '../../../../styles/theme/colors'
import Typography from '@mui/material/Typography'
import { useTranslation } from 'react-i18next'
import { useTheme } from '@mui/material/styles'
import useMediaQuery from '@mui/material/useMediaQuery'

export const SapphireTooltip: FC<GraphTooltipExtendedProps> = ({ children, offsetWidth, offsetHeight }) => {
const { t } = useTranslation()
const theme = useTheme()
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))

if (isMobile) {
return children
}

return (
<GraphTooltip
Expand Down
34 changes: 4 additions & 30 deletions src/app/pages/HomePage/GraphTooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ export const GraphTooltipDescriptionText = styled(Box)(() => ({
alignItems: 'center',
}))

export interface GraphTooltipExtendedProps {
children: TooltipProps['children']
open?: TooltipProps['open']
onOpen?: TooltipProps['onOpen']
onClose?: TooltipProps['onClose']
onClick?: TooltipProps['onClick']
export interface GraphTooltipExtendedProps extends Omit<TooltipProps, 'title'> {
offsetWidth?: number
offsetHeight?: number
}
Expand Down Expand Up @@ -93,35 +88,14 @@ const GraphTooltipWrapper = styled(
},
}))

interface GraphTooltipProps {
title: TooltipProps['title']
children: TooltipProps['children']
open?: TooltipProps['open']
onOpen?: TooltipProps['onOpen']
onClose?: TooltipProps['onClose']
interface GraphTooltipProps extends TooltipProps {
offsetWidth?: number
offsetHeight?: number
}

export const GraphTooltip: FC<GraphTooltipProps> = ({
title,
children,
offsetWidth,
offsetHeight,
open,
onOpen,
onClose,
}) => {
export const GraphTooltip: FC<GraphTooltipProps> = ({ children, ...restProps }) => {
return (
<GraphTooltipWrapper
placement="right-start"
offsetWidth={offsetWidth}
offsetHeight={offsetHeight}
title={title}
open={open}
onOpen={onOpen}
onClose={onClose}
>
<GraphTooltipWrapper {...restProps} placement="right-start">
{children}
</GraphTooltipWrapper>
)
Expand Down

0 comments on commit 06ebf20

Please sign in to comment.