2017-09-25 02:06:28 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
2018-02-07 04:28:28 +00:00
|
|
|
export interface AAttributes {
|
2017-09-25 02:06:28 +00:00
|
|
|
charset?: string;
|
2017-11-07 06:24:54 +00:00
|
|
|
className?: string;
|
2017-09-25 02:06:28 +00:00
|
|
|
coords?: string;
|
|
|
|
download?: string;
|
|
|
|
hreflang?: string;
|
|
|
|
media?: string;
|
|
|
|
name?: string;
|
|
|
|
rel?:
|
|
|
|
| 'alternate'
|
|
|
|
| 'author'
|
|
|
|
| 'bookmark'
|
|
|
|
| 'external'
|
|
|
|
| 'help'
|
|
|
|
| 'license'
|
|
|
|
| 'next'
|
|
|
|
| 'nofollow'
|
|
|
|
| 'noreferrer'
|
|
|
|
| 'noopener'
|
|
|
|
| 'prev'
|
|
|
|
| 'search'
|
|
|
|
| 'tag';
|
|
|
|
rev?: string;
|
|
|
|
shape?: 'default' | 'rect' | 'circle' | 'poly';
|
|
|
|
target?: '_blank' | '_parent' | '_self' | '_top';
|
|
|
|
type?: string;
|
2018-01-01 19:46:28 +00:00
|
|
|
onClick?(ev: React.MouseEvent<HTMLAnchorElement>): void;
|
2017-09-25 02:06:28 +00:00
|
|
|
}
|
|
|
|
|
2017-11-07 18:42:53 +00:00
|
|
|
interface NewTabLinkProps extends AAttributes {
|
2018-02-07 04:28:28 +00:00
|
|
|
href: string;
|
2018-02-08 17:30:30 +00:00
|
|
|
content?: React.ReactElement<any> | string | string[];
|
|
|
|
children?: React.ReactElement<any> | string | string[];
|
2017-09-25 02:06:28 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 23:38:06 +00:00
|
|
|
export class NewTabLink extends React.Component<NewTabLinkProps> {
|
|
|
|
public render() {
|
|
|
|
const { content, children, ...rest } = this.props;
|
|
|
|
return (
|
2018-01-26 19:53:51 +00:00
|
|
|
<a target="_blank" rel="noopener noreferrer" {...rest}>
|
2018-01-22 23:38:06 +00:00
|
|
|
{content || children}
|
|
|
|
</a>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2017-09-25 02:06:28 +00:00
|
|
|
|
|
|
|
export default NewTabLink;
|