@carbon/ibm-security
Version:
Carbon for Cloud & Cognitive IBM Security UI components
51 lines (49 loc) • 1.68 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["children", "className", "href"];
/**
* @file External link.
* @copyright IBM Security 2019 - 2021
*/
import { Launch16 } from '@carbon/icons-react';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import Icon from '../Icon';
import Link from '../Link';
import { getComponentNamespace } from '../../globals/namespace';
var namespace = getComponentNamespace('link--external');
/**
* External link component.
*/
var ExternalLink = function ExternalLink(_ref) {
var children = _ref.children,
className = _ref.className,
href = _ref.href,
other = _objectWithoutProperties(_ref, _excluded);
return /*#__PURE__*/React.createElement(Link, _extends({
className: classnames(className, namespace),
href: href,
rel: "noopener noreferrer",
target: "_blank"
}, other), /*#__PURE__*/React.createElement("span", {
className: "".concat(namespace, "__title")
}, children), /*#__PURE__*/React.createElement("span", {
className: "".concat(namespace, "__icon-wrapper")
}, /*#__PURE__*/React.createElement(Icon, {
className: "".concat(namespace, "__icon"),
renderIcon: Launch16
})));
};
ExternalLink.propTypes = {
/** @type {string} The link content. */
children: PropTypes.node.isRequired,
/** @type {string} Additional classes. */
className: PropTypes.string,
/** @type {string} The external URL. */
href: PropTypes.string.isRequired
};
ExternalLink.defaultProps = {
className: ''
};
export default ExternalLink;