@talend/react-bootstrap
Version:
Bootstrap 3 components built with React
62 lines • 1.79 kB
JavaScript
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import { prefix } from './utils/bootstrapUtils';
import createChainedFunction from './utils/createChainedFunction';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const propTypes = {
onClick: PropTypes.func,
/**
* The toggle content, if left empty it will render the default toggle (seen above).
*/
children: PropTypes.node
};
const contextTypes = {
$bs_navbar: PropTypes.shape({
bsClass: PropTypes.string,
expanded: PropTypes.bool,
onToggle: PropTypes.func.isRequired
})
};
class NavbarToggle extends React.Component {
render() {
const {
onClick,
className,
children,
...props
} = this.props;
const navbarProps = this.context.$bs_navbar || {
bsClass: 'navbar'
};
const buttonProps = {
type: 'button',
...props,
onClick: createChainedFunction(onClick, navbarProps.onToggle),
className: classNames(className, prefix(navbarProps, 'toggle'), !navbarProps.expanded && 'collapsed')
};
if (children) {
return /*#__PURE__*/_jsx("button", {
...buttonProps,
children: children
});
}
return /*#__PURE__*/_jsxs("button", {
...buttonProps,
children: [/*#__PURE__*/_jsx("span", {
className: "sr-only",
children: "Toggle navigation"
}), /*#__PURE__*/_jsx("span", {
className: "icon-bar"
}), /*#__PURE__*/_jsx("span", {
className: "icon-bar"
}), /*#__PURE__*/_jsx("span", {
className: "icon-bar"
})]
});
}
}
NavbarToggle.propTypes = propTypes;
NavbarToggle.contextTypes = contextTypes;
export default NavbarToggle;
//# sourceMappingURL=NavbarToggle.js.map