UNPKG

design-react-kit

Version:

Componenti React per Bootstrap 5

31 lines 1.65 kB
import React from 'react'; import classNames from 'classnames'; import { NavbarBrand } from 'reactstrap'; import { CENTER, useHeaderContext } from './HeaderContext'; import { Icon } from '../Icon/Icon'; export const HeaderBrand = ({ className, href, iconName, iconAlt, children, tag = 'a', responsive = false, testId, ...attributes }) => { const type = useHeaderContext(); const defaultAttributes = { tag }; if (type !== CENTER) { const classes = classNames('d-lg-block', className, { 'd-none': !responsive }); return (React.createElement(NavbarBrand, { className: classes, href: href, "data-testid": testId, ...attributes, ...defaultAttributes }, children)); } return (React.createElement("div", { className: 'it-brand-wrapper', "data-testid": testId }, React.createElement("a", { href: href }, iconName && React.createElement(Icon, { icon: iconName, title: iconAlt }), React.createElement("div", { className: 'it-brand-text' }, React.Children.map(children, (child, i) => { if (typeof child !== 'object' || child == null || !('props' in child)) { return child; } // convention here: first item is the main title, while others subtext const className = classNames(child.props.className, { 'd-none d-md-block': i } // subtext is anything but first element ); const props = { className }; return React.cloneElement(child, props); }))))); }; //# sourceMappingURL=HeaderBrand.js.map