@carbon/react
Version:
React components for the Carbon Design System
60 lines (54 loc) • 1.87 kB
JavaScript
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var cx = require('classnames');
var React = require('react');
var PropTypes = require('prop-types');
var Link = require('./Link.js');
var usePrefix = require('../../internal/usePrefix.js');
function HeaderName({
children,
className: customClassName,
prefix = 'IBM',
...rest
}) {
const selectorPrefix = usePrefix.usePrefix();
const className = cx(`${selectorPrefix}--header__name`, customClassName);
return /*#__PURE__*/React.createElement(Link.default, _rollupPluginBabelHelpers.extends({}, rest, {
className: className
}), prefix && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
className: `${selectorPrefix}--header__name--prefix`
}, prefix), "\xA0"), /*#__PURE__*/React.createElement("span", null, children));
}
HeaderName.propTypes = {
/**
* Pass in a valid `element` to replace the underlying `<a>` tag with a
* custom `Link` element
*/
...Link.LinkPropTypes,
/**
* Pass in children that are either a string or can be read as a string by
* screen readers
*/
children: PropTypes.node.isRequired,
/**
* Optionally provide a custom class to apply to the underlying `<li>` node
*/
className: PropTypes.string,
/**
* Provide an href for the name to link to
*/
href: PropTypes.string,
/**
* Optionally specify a prefix to your header name. Useful for companies, for
* example: IBM [Product Name] versus solely [Product Name]
*/
prefix: PropTypes.string
};
exports.default = HeaderName;