import React from "react";
import classNames from "classnames";
import { Link, LinkProps } from "../Link";
import { Icon, ICON_TYPE } from "../Icon";

export interface ArrowLinkProps extends LinkProps {
  block?: boolean;
}

const defaultArrowLinkProps: Partial<ArrowLinkProps> = {
  block: false,
};

const ArrowLink = (props: ArrowLinkProps) => {
  const {
    className,
    children,
    block = defaultArrowLinkProps.block,
    ...rest
  } = props;

  return (
    <Link
      className={classNames(
        block ? "flex" : "inline-flex",
        "items-center",
        "justify-between",
        "no-underline",
        "font-medium",
        className,
      )}
      {...rest}
    >
      <span className="mr-1">{children}</span>
      <Icon icon={ICON_TYPE.LONG_ARROW_ALT_RIGHT} />
    </Link>
  );
};

ArrowLink.defaultProps = defaultArrowLinkProps;

export { ArrowLink };
