import { Icon, Icons } from "components/Icon";
import { Link as LinkRouter } from "react-router-dom";
interface ILinkPropsBase {
linkText: string;
className?: string;
onClick?: () => void;
direction?: "left" | "right";
}
interface ILinkPropsExternal extends ILinkPropsBase {
url: string;
}
interface ILinkPropsInternal extends ILinkPropsBase {
to: string;
}
export type LinkProps =
| ILinkPropsExternal
| ILinkPropsInternal
| ILinkPropsBase;
export function Link(props: LinkProps) {
const direction = props.direction || "right";
const isExternal = !!(props as ILinkPropsExternal).url;
const isInternal = !!(props as ILinkPropsInternal).to;
const content = (
{direction === "left" ? (
) : null}
{props.linkText}
{direction === "right" ? (
) : null}
);
if (isExternal)
return {content};
else if (isInternal)
return (
{content}
);
return (
props.onClick && props.onClick()}>{content}
);
}