import { __ } from "@wordpress/i18n";
import { BookOpen, ArrowUpRight } from "lucide-react";
import "../scss/main/components/_related-guides.scss";

/** Documentation links for admin pages. */
const DocumentationLinks = ({ guides, browseUrl, constrained = false }) => {
  return (
    <nav
      className={`arraysubs-related-guides${constrained ? " arraysubs-related-guides--constrained" : ""}`}
      aria-label={__("Related guides", "arraysubs")}
    >
      <span className="arraysubs-related-guides__label">
        <BookOpen size={16} aria-hidden="true" />
        {__("Related guides", "arraysubs")}
      </span>
      <ul>
        {guides.map(({ href, label }) => (
          <li key={href}>
            <a href={href} target="_blank" rel="noopener noreferrer">
              {label}
              <ArrowUpRight size={14} aria-hidden="true" />
              <span className="screen-reader-text">{__("(opens in a new tab)", "arraysubs")}</span>
            </a>
          </li>
        ))}
      </ul>
      <a className="arraysubs-related-guides__browse" href={browseUrl} target="_blank" rel="noopener noreferrer">
        {__("Browse all docs", "arraysubs")}
        <ArrowUpRight size={14} aria-hidden="true" />
        <span className="screen-reader-text">{__("(opens in a new tab)", "arraysubs")}</span>
      </a>
    </nav>
  );
};

export default DocumentationLinks;
