mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 09:25:15 +00:00
48 lines
1.7 KiB
JavaScript
48 lines
1.7 KiB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
var _excluded = ["bsPrefix", "className", "children", "label", "as", "onClick"];
|
|
import classNames from 'classnames';
|
|
import React, { useContext } from 'react';
|
|
import useEventCallback from '@restart/hooks/useEventCallback';
|
|
import { useBootstrapPrefix } from './ThemeProvider';
|
|
import NavbarContext from './NavbarContext';
|
|
var defaultProps = {
|
|
label: 'Toggle navigation'
|
|
};
|
|
var NavbarToggle = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
var bsPrefix = _ref.bsPrefix,
|
|
className = _ref.className,
|
|
children = _ref.children,
|
|
label = _ref.label,
|
|
_ref$as = _ref.as,
|
|
Component = _ref$as === void 0 ? 'button' : _ref$as,
|
|
onClick = _ref.onClick,
|
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
|
|
bsPrefix = useBootstrapPrefix(bsPrefix, 'navbar-toggler');
|
|
|
|
var _ref2 = useContext(NavbarContext) || {},
|
|
onToggle = _ref2.onToggle,
|
|
expanded = _ref2.expanded;
|
|
|
|
var handleClick = useEventCallback(function (e) {
|
|
if (onClick) onClick(e);
|
|
if (onToggle) onToggle();
|
|
});
|
|
|
|
if (Component === 'button') {
|
|
props.type = 'button';
|
|
}
|
|
|
|
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
ref: ref,
|
|
onClick: handleClick,
|
|
"aria-label": label,
|
|
className: classNames(className, bsPrefix, !expanded && 'collapsed')
|
|
}), children || /*#__PURE__*/React.createElement("span", {
|
|
className: bsPrefix + "-icon"
|
|
}));
|
|
});
|
|
NavbarToggle.displayName = 'NavbarToggle';
|
|
NavbarToggle.defaultProps = defaultProps;
|
|
export default NavbarToggle; |