keycloak-scim/js/apps/admin-ui/src/components/external-link/FormattedLink.tsx

27 lines
593 B
TypeScript
Raw Normal View History

import { ExternalLinkAltIcon } from "@patternfly/react-icons";
import { AnchorHTMLAttributes } from "react";
2020-09-01 08:25:24 +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 (
<a
2020-09-21 20:12:53 +00:00
href={href}
target="_blank"
rel="noreferrer noopener"
className={isInline ? "pf-m-link pf-m-inline" : ""}
2020-09-21 20:12:53 +00:00
{...rest}
>
{title ? title : href}{" "}
{href?.startsWith("http") && <ExternalLinkAltIcon />}
</a>
2020-09-01 08:25:24 +00:00
);
};