@carbon/ibm-products
Version:
Carbon for IBM Products
52 lines (45 loc) • 2.26 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 index = require('../../_virtual/index.js');
var cx = require('classnames');
var packageSettings = require('../../global/js/package-settings.js');
var react = require('@carbon/react');
var _p, _br, _p2, _br2, _p3;
// The block part of our conventional BEM class names (blockClass__E--M).
const blockClass = `${packageSettings.default.prefix}--canary`;
/**
* Canary component used when the component requested is not yet production
*/
const Canary = (_ref /*, originalArgs*/) => {
let {
className,
componentName,
...rest
} = _ref;
const instructions = `
import { pkg } from '@carbon/ibm-products';
// NOTE: must happen before component is first used
pkg.component.${componentName} = true;
`;
return /*#__PURE__*/React.createElement("div", _rollupPluginBabelHelpers.extends({}, rest, {
className: cx(blockClass, className)
}), /*#__PURE__*/React.createElement("h2", null, "This component ", /*#__PURE__*/React.createElement("strong", null, componentName), " is not ready yet."), _p || (_p = /*#__PURE__*/React.createElement("p", null, "To enable it, initialize package flags before the component is first used.")), _br || (_br = /*#__PURE__*/React.createElement("br", null)), _p2 || (_p2 = /*#__PURE__*/React.createElement("p", null, "e.g. in main.js")), /*#__PURE__*/React.createElement(react.CodeSnippet, {
type: "multi"
}, instructions), _br2 || (_br2 = /*#__PURE__*/React.createElement("br", null)), _p3 || (_p3 = /*#__PURE__*/React.createElement("p", null, "View a live example on", ' ', /*#__PURE__*/React.createElement("a", {
href: "https://codesandbox.io/s/example-component-olif5?file=/src/config.js"
}, "codesandbox"), ".")));
};
Canary.propTypes = {
/** Provide an optional class to be applied to the containing node */
className: index.default.string,
/** Name of the component that is not ready yet */
componentName: index.default.string.isRequired
};
exports.Canary = Canary;