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