import styled, { css } from 'styled-components';

import { Span } from '../../base';

import {
  theme,
  getColor,
  getBorderRadius,
  getBoxShadow,
  getPadding,
} from '../../styled-config';

const borderRadius = (props) => {
  if (props.noRadius) {
    return css`
      border-radius: ${getBorderRadius(props, 'tag', 'noRadius')};
    `;
  }

  return css`
    border-radius: ${getBorderRadius(props, 'tag', 'default')};
  `;
};

const boxShadow = (props) => {
  return css`
    box-shadow: ${getBoxShadow(props, 'tag', 'default')} ${(props) => getColor(props, 'tag', 'shadowColor')};
  `;
};

const background = (props) => {
  if (props.background) {
    return css`
    background-color: ${props.background};
    `;
  }

  return css`
  background-color: ${(props) => getColor(props, 'tag', 'backgroundColor')};
  `;
};

const padding = (props) => {
  return css`
  padding: ${(props) => getPadding(props, "tag", "default")};
  `;
}

const Tag = styled(Span)`
  position: relative;
  font-family: Montserrat;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1rem;
  word-wrap: break-word;
  background-clip: border-box;
  display: inline-flex;
  cursor: pointer;
  ${(props) => boxShadow(props)}
  ${(props) => borderRadius(props)}
  ${(props) => background(props)}
  ${(props) => padding(props)}
`;

Tag.defaultProps = {
  theme,
};

export { Tag };
