2020-09-01 14:51:59 +00:00
|
|
|
import { ExternalLinkAltIcon } from "@patternfly/react-icons";
|
2023-02-10 06:31:00 +00:00
|
|
|
import { AnchorHTMLAttributes } from "react";
|
2020-09-01 08:25:24 +00:00
|
|
|
|
2021-02-16 19:18:09 +00:00
|
|
|
export type FormattedLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
|
|
isInline?: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const FormattedLink = ({
|
|
|
|
title,
|
|
|
|
href,
|
|
|
|
isInline,
|
|
|
|
...rest
|
|
|
|
}: FormattedLinkProps) => {
|
2020-09-01 08:25:24 +00:00
|
|
|
return (
|
2021-02-16 19:18:09 +00:00
|
|
|
<a
|
2020-09-21 20:12:53 +00:00
|
|
|
href={href}
|
2020-11-10 20:26:20 +00:00
|
|
|
target="_blank"
|
2021-02-16 19:18:09 +00:00
|
|
|
rel="noreferrer noopener"
|
|
|
|
className={isInline ? "pf-m-link pf-m-inline" : ""}
|
2020-09-21 20:12:53 +00:00
|
|
|
{...rest}
|
|
|
|
>
|
2021-02-16 19:18:09 +00:00
|
|
|
{title ? title : href}{" "}
|
|
|
|
{href?.startsWith("http") && <ExternalLinkAltIcon />}
|
|
|
|
</a>
|
2020-09-01 08:25:24 +00:00
|
|
|
);
|
|
|
|
};
|