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

interface Props {
    type: 'button' | 'circle-image' | 'square-image';
    src?: string;
    hasImage?: boolean;
    variant: Variants;
    color: Colors;
}

const StyledLabel = styled.label<Props>`
    display: inline-block;
    margin-top: 10px;
    margin-left: 5px;
    background: ${props => props.theme.colorPalette[props.color]?.main};
    color: #fff;
    border-radius: 5px;
    padding: 7px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    min-height: 20px;
    min-width: 80px;

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

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

    ${props => !props.hasImage && `
        font-size: 14px;
        font-weight: bold;
        text-align: center;
    `}

    ${ props => props.hasImage && `
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        color: #000;
    `}

    ${props => props.type === 'circle-image' && `
        height: 80px;
        width: 80px;
        padding: 0px;
        border-radius: 50px;
        background-image: url(${props.src});
        background-size: cover;
        background-position: center;
    `}

    ${props => props.type === 'square-image' && `
        min-height: 100px;
        min-width: 100px;
        width: inherit;
        height: 100%;
        max-width: 500px;
    `}

    &:hover{
        cursor: pointer;
        opacity: 0.8;
    }

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

const StyledUploadButton = styled.input`
    opacity: 0;
    width: 0px;
    height: 0px;
`;

const Image = styled.img<{type: 'button' | 'circle-image' | 'square-image'}>`
    max-width: 500px;
    max-height: 500px;
    width: 100%;
    ${ props => props.type === 'circle-image' && `
        border-radius: 50px;
    `}
`;

export { StyledLabel, StyledUploadButton, Image };
