2018-05-10 02:21:54 +02:00
|
|
|
// @flow
|
2018-05-10 04:47:08 +02:00
|
|
|
import * as React from 'react';
|
2018-05-10 02:21:54 +02:00
|
|
|
import { MODALS } from 'lbry-redux';
|
|
|
|
import Button from 'component/button';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
href?: string,
|
|
|
|
title?: string,
|
|
|
|
children: React.Node,
|
2018-05-10 04:47:08 +02:00
|
|
|
openModal: ({ id: string }, { url: string }) => void,
|
2018-05-10 02:21:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class ExternalLink extends React.PureComponent<Props> {
|
|
|
|
static defaultProps = {
|
|
|
|
href: null,
|
|
|
|
title: null,
|
|
|
|
};
|
|
|
|
render() {
|
|
|
|
const { href, title, children, openModal } = this.props;
|
|
|
|
return href ? (
|
|
|
|
<Button
|
|
|
|
button="link"
|
2018-05-10 04:47:08 +02:00
|
|
|
className="btn--external-link"
|
2018-05-10 02:21:54 +02:00
|
|
|
title={title}
|
|
|
|
onClick={() => openModal({ id: MODALS.CONFIRM_EXTERNAL_LINK }, { url: href })}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</Button>
|
|
|
|
) : (
|
|
|
|
<span>children</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ExternalLink;
|