@carbon/react
Version:
React components for the Carbon Design System
56 lines (52 loc) • 1.7 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.
*/
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import cx from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import Link, { LinkPropTypes } from './Link.js';
import { usePrefix } from '../../internal/usePrefix.js';
function HeaderName({
children,
className: customClassName,
prefix = 'IBM',
...rest
}) {
const selectorPrefix = usePrefix();
const className = cx(`${selectorPrefix}--header__name`, customClassName);
return /*#__PURE__*/React.createElement(Link, _extends({}, rest, {
className: className
}), prefix && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
className: `${selectorPrefix}--header__name--prefix`
}, prefix), "\xA0"), children);
}
HeaderName.propTypes = {
/**
* Pass in a valid `element` to replace the underlying `<a>` tag with a
* custom `Link` element
*/
...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
};
export { HeaderName as default };