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

import { Div } from "../../base";

import { theme, getPadding, getMargin } from "../../styled-config";

const padding = (props) => {
  if (props.sm) {
    return css`
      padding: ${(props) => getPadding(props, "cardBody", "sm")};
    `;
  } else {
    return css`
      padding: ${(props) => getPadding(props, "cardBody", "default")};
    `;
  }
};

const cursor = (props) => {
  if (props.button) {
    return css`
      cursor: pointer;
    `;
  } else if (props.loading){
    return css`
    box-sizing: border-box;
    background-color: #F6F6F6;
    background-image: linear-gradient(
      90deg,
      #eee,
      #f5f5f5,
      #eee
    );
    background-size: 12.5rem 100%;
    background-repeat: no-repeat;
    display: inline-block;
    line-height: 1;
    animation: skeletonKeyframes 1.2s ease-in-out infinite;
      @keyframes skeletonKeyframes {
        0% {
          background-position: -200px 0;
        }
        100% {
          background-position: calc(200px + 100%) 0;
        }
      }
      cursor: progress;
    `;
  }
};


const styleBody = (props) => css`
  flex: 1 1 auto;
  & > a {
    &:hover {
      text-decoration: none;
    }
    & + a {
      margin-left: ${(props) => getMargin(props, "cardBody", "leftA")};
    }
  }
  ${cursor(props)};
  ${padding(props)};
`;

const CardBody = styled(Div)`
  ${(props) => styleBody(props)};
`;

CardBody.defaultProps = {
  theme,
};

export { CardBody };
