lbry-desktop/src/renderer/component/externalLink/view.jsx

36 lines
774 B
React
Raw Normal View History

// @flow
2018-05-10 04:47:08 +02:00
import * as React from 'react';
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,
};
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"
title={title}
onClick={() => openModal({ id: MODALS.CONFIRM_EXTERNAL_LINK }, { url: href })}
>
{children}
</Button>
) : (
<span>children</span>
);
}
}
export default ExternalLink;