-
Notifications
You must be signed in to change notification settings - Fork 1
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 #170 from TrustlessComputer/feat/whitelist_munual
Feat/whitelist munual
- Loading branch information
Showing
9 changed files
with
355 additions
and
29 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,9 @@ | ||
/* eslint-disable jsx-a11y/alt-text */ | ||
import { Image } from '@chakra-ui/react'; | ||
import React from 'react'; | ||
|
||
const IcHelp = () => { | ||
return <Image src={`/icons/ic-tooltip.svg`} />; | ||
}; | ||
|
||
export default IcHelp; |
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,105 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { | ||
Box, | ||
Flex, | ||
PlacementWithLogical, | ||
Popover, | ||
PopoverArrow, | ||
PopoverBody, | ||
PopoverContent, | ||
PopoverTrigger, | ||
Text, | ||
useDisclosure, | ||
} from '@chakra-ui/react'; | ||
import { ReactNode, useEffect, useRef } from 'react'; | ||
import IcHelp from './IcHelp'; | ||
|
||
interface InfoTooltipProps { | ||
label: ReactNode; | ||
children?: ReactNode; | ||
placement?: PlacementWithLogical; | ||
iconSize?: string; | ||
fontSize?: string; | ||
iconColor?: string; | ||
showIcon?: boolean; | ||
iconName?: any; | ||
setIsOpen?: (b: boolean) => void; | ||
isStyleConfig?: boolean; | ||
bodyClassName?: any; | ||
className?: any; | ||
} | ||
|
||
const InfoTooltip = (props: InfoTooltipProps) => { | ||
const { | ||
label, | ||
children, | ||
showIcon = false, | ||
setIsOpen, | ||
isStyleConfig = true, | ||
bodyClassName, | ||
className | ||
} = props; | ||
const { isOpen, onToggle, onClose } = useDisclosure(); | ||
|
||
useEffect(() => { | ||
setIsOpen && setIsOpen(isOpen); | ||
}, [isOpen]); | ||
|
||
const initRef = useRef<any>(); | ||
|
||
const renderChild = () => { | ||
if (children && showIcon) { | ||
return ( | ||
<Flex gap={1} alignItems={'center'}> | ||
{children} | ||
<IcHelp /> | ||
</Flex> | ||
); | ||
} | ||
if (children) { | ||
return children; | ||
} | ||
return <IcHelp />; | ||
}; | ||
|
||
return ( | ||
<Popover | ||
closeOnBlur={true} | ||
placement="auto" | ||
initialFocusRef={initRef} | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
styleConfig={ | ||
{ zIndex: 999999999 } | ||
} | ||
> | ||
<PopoverTrigger> | ||
<Box | ||
cursor={"pointer"} | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
onToggle(); | ||
}} | ||
className={className} | ||
> | ||
{renderChild()} | ||
</Box> | ||
</PopoverTrigger> | ||
<PopoverContent> | ||
<PopoverArrow bg="white" /> | ||
<PopoverBody | ||
style={{ | ||
padding: 5, | ||
zIndex: 999999999 | ||
}} | ||
className={bodyClassName} | ||
> | ||
<Text fontSize={'12px'}>{label}</Text> | ||
</PopoverBody> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
}; | ||
|
||
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,3 @@ | ||
.popover { | ||
color: red; | ||
} |
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.