import React, {useMemo} from 'react'; import {BLACK_HEX, WHITE} from '../../helpers/colors'; import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item'; import {SHADOW_TOWARDS_BOTTOM, SHADOW_TOWARDS_TOP} from '../Menu/styles'; export const INFO_TOOLTIP_FONT_SIZE = 13; const arrow: React.CSSProperties = { height: 7, display: 'block', overflow: 'visible', }; export const InfoTooltip: React.FC<{ readonly children: React.ReactNode; readonly arrowDirection: 'up' | 'down'; readonly backgroundColor: string; readonly horizontalAlignment: 'left' | 'right'; }> = ({children, arrowDirection, backgroundColor, horizontalAlignment}) => { const container: React.CSSProperties = useMemo(() => { return { boxShadow: arrowDirection === 'down' ? SHADOW_TOWARDS_TOP : SHADOW_TOWARDS_BOTTOM, background: backgroundColor, color: WHITE, fontSize: INFO_TOOLTIP_FONT_SIZE, border: '0.5px solid ' + BLACK_HEX, maxHeight: 200, overflow: 'auto', borderRadius: '4px', }; }, [arrowDirection, backgroundColor]); const arrowStyle: React.CSSProperties = useMemo(() => { return { ...arrow, ...(horizontalAlignment === 'left' ? {marginLeft: 7} : {marginRight: 7}), ...(arrowDirection === 'up' ? {transform: `translateY(1px)`} : {marginTop: -1}), }; }, [arrowDirection, horizontalAlignment]); return (
{children}
{arrowDirection === 'down' ? ( ) : null} {arrowDirection === 'up' ? ( ) : null}
); };