@carbon/ibm-security
Version:
Carbon for Cloud & Cognitive IBM Security UI components
101 lines (99 loc) • 4.6 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["backgroundImage", "className", "description", "title", "subTitle", "links", "style"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
* @file Non entitled section.
* @copyright IBM Security 2019 - 2021
*/
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import Link from '../Link';
import { carbonPrefix, getComponentNamespace } from '../../globals/namespace';
var namespace = getComponentNamespace('ne-section');
/**
* Non entitled section component.
*/
var NonEntitledSection = function NonEntitledSection(_ref) {
var backgroundImage = _ref.backgroundImage,
className = _ref.className,
description = _ref.description,
title = _ref.title,
subTitle = _ref.subTitle,
links = _ref.links,
style = _ref.style,
other = _objectWithoutProperties(_ref, _excluded);
var classes = classnames(className, namespace, "".concat(carbonPrefix, "--grid"));
return /*#__PURE__*/React.createElement("section", _extends({
className: classes,
style: backgroundImage && _objectSpread({
backgroundImage: "url(\"".concat(backgroundImage, "\")")
}, style)
}, other), /*#__PURE__*/React.createElement("div", {
className: "".concat(namespace, "__content-wrapper ").concat(carbonPrefix, "--row")
}, /*#__PURE__*/React.createElement("div", {
className: "".concat(namespace, "__content ").concat(carbonPrefix, "--col-lg-5 ").concat(carbonPrefix, "--col-md-4")
}, /*#__PURE__*/React.createElement("h2", {
className: "".concat(namespace, "__title")
}, title), /*#__PURE__*/React.createElement("h3", {
className: "".concat(namespace, "__sub-title")
}, subTitle), description && /*#__PURE__*/React.createElement("p", {
className: "".concat(namespace, "__description")
}, description), links.length > 0 && links.map(function (_ref2) {
var id = _ref2.id,
text = _ref2.text,
href = _ref2.href,
icon = _ref2.icon;
return /*#__PURE__*/React.createElement("div", {
key: id,
className: "".concat(namespace, "__link-wrapper")
}, /*#__PURE__*/React.createElement(Link, {
id: id,
href: href,
className: "".concat(namespace, "__link")
}, icon !== undefined && /*#__PURE__*/React.createElement("img", {
// `alt` is purposely left blank:
alt: "",
"aria-hidden": true,
className: "".concat(namespace, "__link__icon"),
src: icon
}), /*#__PURE__*/React.createElement("span", {
className: "".concat(namespace, "__link__text")
}, text)));
}))));
};
NonEntitledSection.defaultProps = {
backgroundImage: null,
className: '',
description: '',
links: []
};
NonEntitledSection.propTypes = {
/** @type {string} Background image data URI. */
backgroundImage: PropTypes.string,
/** @type {string} The class name of the section. */
className: PropTypes.string,
/** @type {string} Section description. */
description: PropTypes.string,
/** @type {Array<Object.*>} An array list of links. */
links: PropTypes.arrayOf(PropTypes.shape({
/** @type {node} Provide the identifier for the <a> node */
id: PropTypes.string.isRequired,
/** @type {node} Provide the text for the Link. */
text: PropTypes.string.isRequired,
/** @type {string} Provide the `href` attribute for the <a> node */
href: PropTypes.string.isRequired,
/** @type {string} Provide the `src` attribute for an icon */
icon: PropTypes.string
})),
/** Optional styles */
style: PropTypes.object,
/** @type {string} Section description heading. */
subTitle: PropTypes.string.isRequired,
/** @type {string} Section heading. */
title: PropTypes.string.isRequired
};
export default NonEntitledSection;