@carbon/ibm-products
Version:
Carbon for IBM Products
87 lines (77 loc) • 2.84 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.
*/
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import React__default from 'react';
import { Button } from '@carbon/react';
import { Crossroads } from '@carbon/react/icons';
import PropTypes from '../../_virtual/index.js';
import cx from 'classnames';
import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
import { pkg } from '../../settings.js';
var _Crossroads;
// The block part of our conventional BEM class names (blockClass__E--M).
const blockClass = `${pkg.prefix}--guidebanner__element-button`;
const componentName = 'GuidebannerElementButton';
const defaults = {
iconDescription: 'Crossroads'
};
/**
* One of two buttons styled specifically for the GuidebannerElement.
*/
let GuidebannerElementButton = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
let {
children,
className,
iconDescription = defaults.iconDescription,
type,
...rest
} = _ref;
if (type === 'primary') {
return /*#__PURE__*/React__default.createElement(Button, _extends({}, rest, {
className: cx(blockClass, className),
iconDescription: iconDescription,
kind: "tertiary",
ref: ref,
renderIcon: () => _Crossroads || (_Crossroads = /*#__PURE__*/React__default.createElement(Crossroads, {
size: 16
})),
role: "button",
size: "md"
}, getDevtoolsProps(componentName)), children);
}
return /*#__PURE__*/React__default.createElement(Button, _extends({}, rest, {
className: cx(blockClass, className),
kind: "ghost",
role: "button",
size: "md"
}, getDevtoolsProps(componentName)), children);
});
// Return a placeholder if not released and not enabled by feature flag
GuidebannerElementButton = pkg.checkComponentEnabled(GuidebannerElementButton, componentName);
// The display name of the component, used by React. Note that displayName
// is used in preference to relying on function.name.
GuidebannerElementButton.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.
GuidebannerElementButton.propTypes = {
/**
* Provide the contents of the GuidebannerElementButton.
*/
children: PropTypes.node.isRequired,
/**
* Provide an optional class to be applied to the containing node.
*/
className: PropTypes.string,
/**
* If type is "primary", then return a tertiary button with the "crossroads" icon,
* else return a ghost button.
*/
type: PropTypes.string
/* TODO: add types and DocGen for all props. */
};
export { GuidebannerElementButton };