import styled from 'styled-components';
import * as React from 'react';

const TooltipText = styled.span`
    min-width: 120px;
    background-color: ${({ theme }) => theme.colorPalette.primary.main};
    color: ${({ theme }) => theme.colorPalette.primary.fontColor};
    text-align: center;
    border-radius: 4px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 10px;
`;

interface TooltipProps {
    align: 'left' | 'right' | 'top' | 'bottom';
    showOn: 'hover' | 'click' | 'props';
    show?: boolean;
}

const StyledTooltip = styled.div<TooltipProps>`
    display: inline-block;

    ${props => props.showOn === 'hover' && `
    
        &:hover ${TooltipText}{
            visibility: visible;
            opacity: 1;
        }
    `}

    ${props => props.showOn === 'props' && props.show && `
        ${TooltipText}{
            visibility: visible;
            opacity: 1;
        }
    `}
    
`;

export { StyledTooltip, TooltipText };
