2016-07-07 20:10:55 +00:00
|
|
|
import React, {Component, PropTypes} from 'react';
|
2016-07-16 02:06:10 +00:00
|
|
|
import {shell} from 'electron';
|
2016-07-07 20:10:55 +00:00
|
|
|
|
|
|
|
class Link extends Component {
|
|
|
|
render () {
|
2016-08-25 17:06:01 +00:00
|
|
|
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}>
|
2016-07-07 20:10:55 +00:00
|
|
|
{children}
|
|
|
|
</a>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Link.propTypes = {
|
2016-08-25 17:06:01 +00:00
|
|
|
href: PropTypes.string.isRequired,
|
|
|
|
|
|
|
|
// Optional
|
|
|
|
button: PropTypes.bool
|
2016-07-07 20:10:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Link;
|