@carbon/ibm-products
Version:
Carbon for IBM Products
85 lines (78 loc) • 3.06 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 cx = require('classnames');
var devtools = require('../../global/js/utils/devtools.js');
var settings = require('../../settings.js');
// The block part of our conventional BEM class names (blockClass__E--M).
const blockClass = `${settings.pkg.prefix}--coachmark-overlay-element`;
const componentName = 'CoachmarkOverlayElement';
/**
* Component to be displayed within a CoachmarkOverlayElements container.
* Can be used 1 to N number, to display content in a Coachmark's overlay
* in a carousel fashion.
*/
exports.CoachmarkOverlayElement = /*#__PURE__*/React.forwardRef((_ref, ref) => {
let {
button,
className,
description,
title,
// Collect any other property values passed in.
...rest
} = _ref;
return /*#__PURE__*/React.createElement("div", _rollupPluginBabelHelpers.extends({}, rest, {
className: cx(blockClass,
// Apply the block class to the main HTML element
className,
// Apply any supplied class names to the main HTML element.
// example: `${blockClass}__template-string-class-${kind}-n-${size}`,
{
// switched classes dependant on props or state
// example: [`${blockClass}__here-if-small`]: size === 'sm',
}),
ref: ref
}, devtools.getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("div", {
className: `${blockClass}__content`
}, title && /*#__PURE__*/React.createElement("h2", {
className: `${blockClass}__title`
}, title), description && /*#__PURE__*/React.createElement("p", {
className: `${blockClass}__body`
}, description)), button && /*#__PURE__*/React.createElement("div", {
className: `${blockClass}__button`
}, button));
});
// Return a placeholder if not released and not enabled by feature flag
exports.CoachmarkOverlayElement = settings.pkg.checkComponentEnabled(exports.CoachmarkOverlayElement, componentName);
// The display name of the component, used by React. Note that displayName
// is used in preference to relying on function.name.
exports.CoachmarkOverlayElement.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.
exports.CoachmarkOverlayElement.propTypes = {
/**
* An optional button can be rendered below the description.
* This can be a link, button, Coachmark button, etc.
*/
button: index.default.node,
/**
* Optional class name for this component.
*/
className: index.default.string,
/**
* The description of the Coachmark.
*/
description: index.default.node.isRequired,
/**
* The title of the Coachmark.
*/
title: index.default.string.isRequired
};