Skip to content

Commit

Permalink
refactored_pop_ups
Browse files Browse the repository at this point in the history
  • Loading branch information
mynotdoing committed Nov 16, 2023
1 parent c75be17 commit 06e31d7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const IconExtensionWithTitle: FC<IconExtensionWithTitleProps> = ({
description={size ? convertSize(size) : description}
style={styles.titleWithDescription}
title={title}
useTooltip
/>
</Box>
)
Expand Down
39 changes: 22 additions & 17 deletions src/components/title-with-description/TitleWithDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Box from '@mui/material/Box'
import Typography from '@mui/material/Typography'

import { styles } from '~/components/title-with-description/TitleWithDescription.styles'
import { ComponentEnum } from '~/types'

interface TitleWithDescriptionProps {
title: string | ReactElement
Expand All @@ -15,31 +14,37 @@ interface TitleWithDescriptionProps {
title?: SxProps
description?: SxProps
}
useTooltip?: boolean
}

const TitleWithDescription = ({
title,
description,
style = styles
style = styles,
useTooltip = false
}: TitleWithDescriptionProps) => {
const [tooltipVisible, setTooltipVisible] = useState<boolean>(false)

const handleTooltip = () => setTooltipVisible((prevState) => !prevState)

return (
<Box sx={style.wrapper}>
<Typography sx={style.title}>{title}</Typography>
<Tooltip open={tooltipVisible} placement='bottom' title={description}>
<Typography
component={ComponentEnum.Span}
onClick={handleTooltip}
sx={style.description}
>
{description}
</Typography>
</Tooltip>
</Box>
)
if (useTooltip) {
return (
<Box sx={style.wrapper}>
<Typography sx={style.title}>{title}</Typography>
<Tooltip open={tooltipVisible} placement='bottom' title={description}>
<Typography onClick={handleTooltip} sx={style.description}>
{description}
</Typography>
</Tooltip>
</Box>
)
} else {
return (
<Box sx={style.wrapper}>
<Typography sx={style.title}>{title}</Typography>
<Typography sx={style.description}>{description}</Typography>
</Box>
)
}
}

export default TitleWithDescription

0 comments on commit 06e31d7

Please sign in to comment.