@carbon/ibm-products
Version:
Carbon for IBM Products
69 lines (67 loc) • 2.39 kB
JavaScript
/**
* Copyright IBM Corp. 2020, 2026
*
* 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 { __toESM } from "../../_virtual/_rolldown/runtime.js";
import { require_classnames } from "../../node_modules/classnames/index.js";
import { pkg } from "../../settings.js";
import { getDevtoolsProps } from "../../global/js/utils/devtools.js";
import React from "react";
import PropTypes from "prop-types";
import { Button } from "@carbon/react";
import { Crossroads } from "@carbon/react/icons";
//#region src/components/Guidebanner/GuidebannerElementButton.tsx
/**
* Copyright IBM Corp. 2023, 2024
*
* 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 import_classnames = /* @__PURE__ */ __toESM(require_classnames());
const blockClass = `${pkg.prefix}--guidebanner__element-button`;
const componentName = "GuidebannerElementButton";
const defaults = { iconDescription: "Crossroads" };
/**
* One of two buttons styled specifically for the GuidebannerElement.
*/
const GuidebannerElementButton = React.forwardRef(({ children, className, iconDescription = defaults.iconDescription, type, ...rest }, ref) => {
if (type === "primary") return /* @__PURE__ */ React.createElement(Button, {
...rest,
className: (0, import_classnames.default)(blockClass, className),
iconDescription,
kind: "tertiary",
ref,
renderIcon: () => /* @__PURE__ */ React.createElement(Crossroads, { size: 16 }),
role: "button",
size: "md",
...getDevtoolsProps(componentName)
}, children);
return /* @__PURE__ */ React.createElement(Button, {
...rest,
className: (0, import_classnames.default)(blockClass, className),
kind: "ghost",
role: "button",
size: "md",
...getDevtoolsProps(componentName)
}, children);
});
GuidebannerElementButton.displayName = componentName;
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
};
//#endregion
export { GuidebannerElementButton };