import React from "react";
import classNames from "classnames";

import { filterAttrs } from "@arc-ui/community-utils/filter-attrs";

import { Author } from "../Author";
import { AuthorProps } from "../Author/Author";

import styles from "./Quote.module.css";

/**
 * Use `Quote` where a quote or testimonial from an existing customer or stakeholder would help build trust and credibility with potential new customers. It's commonly used on product pages where customers would learn about a product or service that we offer.*/
export const Quote: React.FC<QuoteProps> = ({
  author,
  styling = "Default",
  content,
  citeUrl,
  ...props
}) => {
  return (
    <div
      className="community-component--quote"
      data-testid="quote-test"
      {...filterAttrs(props)}
    >
      <blockquote
        data-testid="style-test"
        className={classNames(styles.blockQuote, styles[`quote${styling}`])}
        cite={citeUrl}
      >
        <svg
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 100 77"
          className={styles.quoteIcon}
          aria-hidden="true"
        >
          <path d="M21.8085 76.4706C15.9574 76.4706 10.8156 74.2732 6.38298 69.8783C2.12766 65.4834 0 58.979 0 50.3651C0 40.5206 3.10284 31.1156 9.30851 22.1501C15.6915 13.1846 25.3546 5.80122 38.2979 0L44.1489 11.3387C37.4113 14.3272 31.7376 18.0189 27.1277 22.4138C22.5177 26.6329 19.6809 31.4672 18.617 36.9168C19.8582 36.741 21.0106 36.6531 22.0745 36.6531C27.7482 36.6531 32.4468 38.499 36.1702 42.1907C40.0709 45.8824 42.0213 50.7167 42.0213 56.6937C42.0213 62.4949 39.9823 67.2414 35.9043 70.9331C32.0035 74.6247 27.305 76.4706 21.8085 76.4706ZM77.6596 76.4706C71.8085 76.4706 66.6667 74.2732 62.234 69.8783C57.9787 65.4834 55.8511 58.979 55.8511 50.3651C55.8511 40.5206 58.9539 31.1156 65.1596 22.1501C71.5425 13.1846 81.2057 5.80122 94.1489 0L100 11.3387C93.2624 14.3272 87.5886 18.0189 82.9787 22.4138C78.3688 26.6329 75.5319 31.4672 74.4681 36.9168C75.7092 36.741 76.8617 36.6531 77.9255 36.6531C83.5993 36.6531 88.2979 38.499 92.0213 42.1907C95.922 45.8824 97.8723 50.7167 97.8723 56.6937C97.8723 62.4949 95.8333 67.2414 91.7553 70.9331C87.8546 74.6247 83.156 76.4706 77.6596 76.4706Z" />
        </svg>
        <p className={styles.quoteContent}>{content}</p>
      </blockquote>
      {author && <Author {...author} />}
    </div>
  );
};

export interface QuoteProps {
  styling?: "Default" | "Secondary";
  content: string;
  author?: AuthorProps;
  citeUrl?: string;
}
