@carbon/ibm-products
Version:
Carbon for IBM Products
79 lines (72 loc) • 2.64 kB
JavaScript
/**
* Copyright IBM Corp. 2020, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
;
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var React = require('react');
var index = require('../../_virtual/index.js');
var settings = require('../../settings.js');
var react = require('@carbon/react');
// The block part of our conventional BEM class names (blockClass__E--M).
const blockClass = `${settings.pkg.prefix}--http-errors`;
const componentName = 'HTTPErrorContent';
let HTTPErrorContent = _ref => {
let {
description,
errorCodeLabel,
title,
links
} = _ref;
return /*#__PURE__*/React.createElement("div", {
className: `${blockClass}__content`
}, errorCodeLabel && /*#__PURE__*/React.createElement("p", {
className: `${blockClass}__error-code-label`
}, errorCodeLabel), title && /*#__PURE__*/React.createElement("h1", {
className: `${blockClass}__title`
}, title), description && /*#__PURE__*/React.createElement("p", {
className: `${blockClass}__description`
}, description), links && links.length && links.map(link => /*#__PURE__*/React.createElement(react.Link, _rollupPluginBabelHelpers.extends({}, link, {
role: "link",
href: link.href,
key: link.text,
className: `${blockClass}__link`
}), link.text)));
};
// The display name of the component, used by React. Note that displayName
// is used in preference to relying on function.name.
HTTPErrorContent.displayName = componentName;
// The types and DocGen commentary for the component props,
// in alphabetical order (for consistency).
// See https://www.npmjs.com/package/prop-types#usage.
HTTPErrorContent.propTypes = {
/**
* String that will provide the description for the HTTP error code
*/
description: index.propTypesExports.string.isRequired,
/**
* String that will describe the error that occurred
*/
errorCodeLabel: index.propTypesExports.string.isRequired,
/**
* Links that will display for extra context when receiving particular errors
*/
links: index.propTypesExports.arrayOf(index.propTypesExports.shape({
...react.Link.propTypes,
/**
* The text to display for the link
*/
text: index.propTypesExports.string.isRequired,
/**
* The link's destination
*/
href: index.propTypesExports.string.isRequired
})),
/**
* This will be for the main title of the HTTP error component
*/
title: index.propTypesExports.string.isRequired
};
exports.HTTPErrorContent = HTTPErrorContent;