CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/components/A.tsx
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
/* Use this component to make an anchor tag that
7
opens in a new tab in the right way, namely
8
with rel=noopener. This avoids sharing cpu
9
with the main cocalc page.
10
*/
11
12
import { CSSProperties, ReactNode } from "react";
13
import { Tooltip } from "antd";
14
15
interface AProps {
16
href: string;
17
children: ReactNode;
18
title?: string;
19
placement?: string;
20
style?: CSSProperties;
21
onClick?: (any) => void;
22
onMouseDown?: (any) => void;
23
}
24
25
export function A({
26
href,
27
children,
28
style,
29
title,
30
placement,
31
onClick,
32
onMouseDown,
33
}: AProps) {
34
if (title) {
35
// use nicer antd tooltip.
36
return (
37
<Tooltip title={title} placement={placement as any}>
38
<a
39
href={href}
40
target={"_blank"}
41
rel={"noopener"}
42
style={style}
43
onClick={onClick}
44
onMouseDown={onMouseDown}
45
>
46
{children}
47
</a>
48
</Tooltip>
49
);
50
}
51
return (
52
<a
53
href={href}
54
target={"_blank"}
55
rel={"noopener"}
56
style={style}
57
title={title}
58
onClick={onClick}
59
onMouseDown={onMouseDown}
60
>
61
{children}
62
</a>
63
);
64
}
65
66