insomnia/app/ui/components/base/Link.js
2016-09-16 22:46:44 -07:00

27 lines
580 B
JavaScript

import React, {Component, PropTypes} from 'react';
import {shell} from 'electron';
class Link extends Component {
render () {
const {button, href, children, ...other} = this.props;
return button ? (
<button onClick={() => shell.openExternal(href)} {...other}>
{children}
</button>
) :(
<a href={href} onClick={e => {e.preventDefault(); shell.openExternal(href)}} {...other}>
{children}
</a>
)
}
}
Link.propTypes = {
href: PropTypes.string.isRequired,
// Optional
button: PropTypes.bool
};
export default Link;