import styled from 'styled-components';
import { Colors, Sizes, Variants } from '../../styles';
import * as React from 'react';

interface Props {
    size: Sizes;
    variant: Variants;
    color: Colors;
}

const sizes = {
    xxs: 5,
    xs: 10,
    sm: 15,
    md: 20,
    lg: 25,
    xl: 30,
    xxl: 35,
};

const getSize = (size: Sizes, variant: Variants) => {
    let mySize = sizes[size];
    mySize = mySize * 2;
    return `${mySize}px`;
};

export const StyledIconButton = styled.button<Props>`
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    margin-left: 10px;
    padding: 0px;
    border-radius: 57px;
    border: none;
    width: ${ props => getSize(props.size, props.variant)};
    height: ${ props => getSize(props.size, props.variant)};
    font-size: ${ props => `${sizes[props.size]}px`};
    background-color: ${props => props.theme.colorPalette[props.color]?.main};
    box-shadow: 1px 1px 3px 1px #a5a2a2;

    ${props => props.variant === 'outlined' && `
        background-color: transparent;
        border: 1px solid ${props.theme.colorPalette[props.color]?.main};
        color: ${props.theme.colorPalette[props.color]?.main};
        i {
            color: ${props.theme.colorPalette[props.color]?.main};
        }
    `}

    ${ props => props.variant === 'transparent' && `
        background-color: transparent;
        box-shadow: none;
        color: ${props.theme.colorPalette[props.color]?.main};
        i {
            color: ${props.theme.colorPalette[props.color]?.main};
        }
    `}

    > span {
        font-size: ${ props => `${sizes[props.size] * 1.25}px`};
    }

    &:hover{
        cursor: pointer;
        opacity: 0.8;
        ${props => (props.variant === 'transparent' || props.variant === 'outlined') && `
            background: ${props.theme.colorPalette[props.color]?.main};
            color: #fff;
            i {
                color: #fff;
            }
        `}
    }

    &:focus {
        outline: 0;
    }

    &:active {
        transform: scale(0.95);
    }
`;
