-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1708 from AletheiaFact/Change-all-popover-and-too…
…ltip Change all popover and tooltip
- Loading branch information
Showing
24 changed files
with
385 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { styled, Tooltip, tooltipClasses, TooltipProps } from "@mui/material"; | ||
import React from "react"; | ||
import colors from "../../styles/colors"; | ||
|
||
type InfoTooltipProps = { | ||
placement?: TooltipProps["placement"]; | ||
content: React.ReactNode; | ||
children: React.ReactElement; | ||
useCustomStyle?: boolean; | ||
}; | ||
|
||
const DefaultTooltip = ({ className, ...props }: TooltipProps) => { | ||
return ( | ||
<Tooltip {...props} arrow | ||
title={ | ||
<span style={{ fontSize: 15 }}> | ||
{props.title} | ||
</span> | ||
} | ||
> | ||
{props.children} | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
const InfoTooltip: React.FC<InfoTooltipProps> = ({ | ||
placement = "top", | ||
content, | ||
children, | ||
useCustomStyle = true, | ||
}) => { | ||
|
||
const CustomTooltip = styled(({ className, ...props }: TooltipProps) => ( | ||
<Tooltip {...props} arrow classes={{ popper: className }} /> | ||
))(() => ({ | ||
[`& .${tooltipClasses.arrow}`]: { | ||
color: colors.white, | ||
}, | ||
[`& .${tooltipClasses.tooltip}`]: { | ||
backgroundColor: colors.white, | ||
maxWidth: "100%", | ||
boxShadow: `0px 0px 15px ${colors.shadow}`, | ||
}, | ||
})); | ||
|
||
|
||
const TooltipComponent = useCustomStyle ? CustomTooltip : DefaultTooltip; | ||
|
||
return ( | ||
<TooltipComponent placement={placement} title={content}> | ||
{children} | ||
</TooltipComponent> | ||
); | ||
}; | ||
|
||
export default InfoTooltip; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from "react"; | ||
import { IconButton, Popover, PopoverOrigin } from "@mui/material"; | ||
|
||
interface PopoverClickProps { | ||
children: React.ReactNode; | ||
content: React.ReactNode; | ||
anchorOrigin?: PopoverOrigin; | ||
transformOrigin?: PopoverOrigin; | ||
} | ||
|
||
const PopoverClick: React.FC<PopoverClickProps> = ({ | ||
children, | ||
content, | ||
anchorOrigin = { vertical: "bottom", horizontal: "center" }, | ||
transformOrigin = { vertical: "top", horizontal: "center" }, | ||
}) => { | ||
const [anchorEl, setAnchorEl] = React.useState<HTMLElement | null>(null); | ||
const open = Boolean(anchorEl); | ||
const id = open ? "simple-popover" : undefined; | ||
|
||
const handleClick = (event: React.MouseEvent<HTMLElement>) => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
|
||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
|
||
return ( | ||
<> | ||
<IconButton | ||
aria-describedby={id} | ||
onClick={handleClick} | ||
> | ||
{children} | ||
</IconButton> | ||
<Popover | ||
id={id} | ||
open={open} | ||
anchorEl={anchorEl} | ||
onClose={handleClose} | ||
anchorOrigin={anchorOrigin} | ||
transformOrigin={transformOrigin} | ||
> | ||
{content} | ||
</Popover> | ||
</> | ||
); | ||
}; | ||
|
||
export default PopoverClick; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.