{"size": 1344, "ext": "js", "max_stars_repo_path": "src/components/source-card/index.js", "max_stars_repo_name": "lburdock/fodmap", "max_stars_repo_stars_event_min_datetime": "2019-03-05T15:47:26.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-05T15:47:26.000Z", "max_issues_repo_path": "src/components/source-card/index.js", "max_issues_repo_name": "lburdock/fodmap", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/source-card/index.js", "max_forks_repo_name": "lburdock/fodmap", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.358490566, "max_line_length": 70, "alphanum_fraction": 0.640625}
import cn from "classnames";
import React from "react";
import PropTypes from "prop-types";
import { capitalize } from "../../utils/string";
import ExternalLink from "../external-link";
import Subtitle from "./subtitle";
import styles from "./index.module.css";

const iconMap = {
  journal: "fa-newspaper",
  website: "fa-laptop",
};

const SourceCard = ({ author, publisher, title, type, url }) => (
  <article className={cn("card", styles.sourceCard)}>
    <div className="card-content">
      <div className={cn("has-text-centered", styles.sourceIcon)}>
        <span className="icon is-medium">
          <i
            className={cn("fas fa-2x", iconMap[type])}
            title={capitalize(type)}
          />
        </span>
      </div>

      <h2 className="title is-5">{title}</h2>

      <Subtitle list={author} prefix="By" />

      <Subtitle list={publisher} />

      <ExternalLink to={url} className="button is-black is-fullwidth">
        Read more
      </ExternalLink>
    </div>
  </article>
);

SourceCard.propTypes = {
  author: PropTypes.arrayOf(PropTypes.string),
  publisher: PropTypes.arrayOf(PropTypes.string),
  title: PropTypes.string.isRequired,
  type: PropTypes.string.isRequired,
  url: PropTypes.string.isRequired,
};

SourceCard.defaultProps = {
  author: [],
  publisher: [],
};

export default SourceCard;
