| 1 |
import React from 'react'; |
| 2 |
import parse from 'html-react-parser'; |
| 3 |
import './Tooltip.scss'; |
| 4 |
import { QuestionMarkCircleIcon } from '@heroicons/react/24/outline'; |
| 5 |
import classnames from 'classnames'; |
| 6 |
|
| 7 |
function Tooltip( props ) { |
| 8 |
const { |
| 9 |
text, |
| 10 |
position = 'default', |
| 11 |
classes = 'text-gray-400', |
| 12 |
descClass = '', |
| 13 |
icon = '', |
| 14 |
} = props; |
| 15 |
return ( |
| 16 |
<div |
| 17 |
className={ classnames( |
| 18 |
classes, |
| 19 |
'wcf-tooltip-icon cursor-pointer ml-1', |
| 20 |
'default' !== position |
| 21 |
? 'wcf-tooltip-position--' + position |
| 22 |
: '' |
| 23 |
) } |
| 24 |
> |
| 25 |
{ '' === icon ? ( |
| 26 |
<QuestionMarkCircleIcon className={ `w-4 h-4 stroke-2` } /> |
| 27 |
) : ( |
| 28 |
icon |
| 29 |
) } |
| 30 |
|
| 31 |
{ '' !== text && ( |
| 32 |
<span className={ `wcf-tooltip-text ${ descClass }` }> |
| 33 |
{ typeof text === 'string' ? parse( text ) : text } |
| 34 |
</span> |
| 35 |
) } |
| 36 |
</div> |
| 37 |
); |
| 38 |
} |
| 39 |
|
| 40 |
export default Tooltip; |
| 41 |
|