Path: blob/master/src/packages/frontend/components/A.tsx
1503 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45/* Use this component to make an anchor tag that6opens in a new tab in the right way, namely7with rel=noopener. This avoids sharing cpu8with the main cocalc page.9*/1011import { CSSProperties, ReactNode } from "react";12import { Tooltip } from "antd";1314interface AProps {15href: string;16children: ReactNode;17title?: string;18placement?: string;19style?: CSSProperties;20onClick?: (any) => void;21onMouseDown?: (any) => void;22}2324export function A({25href,26children,27style,28title,29placement,30onClick,31onMouseDown,32}: AProps) {33if (title) {34// use nicer antd tooltip.35return (36<Tooltip title={title} placement={placement as any}>37<a38href={href}39target={"_blank"}40rel={"noopener"}41style={style}42onClick={onClick}43onMouseDown={onMouseDown}44>45{children}46</a>47</Tooltip>48);49}50return (51<a52href={href}53target={"_blank"}54rel={"noopener"}55style={style}56title={title}57onClick={onClick}58onMouseDown={onMouseDown}59>60{children}61</a>62);63}646566