mirror of
https://github.com/Snigdha-OS/documentation.git
synced 2025-09-18 20:54:56 +02:00
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
import React from 'react';
|
|
import clsx from 'clsx';
|
|
import NavbarNavLink from '@theme/NavbarItem/NavbarNavLink';
|
|
function DefaultNavbarItemDesktop({
|
|
className,
|
|
isDropdownItem = false,
|
|
...props
|
|
}) {
|
|
const element = (
|
|
<NavbarNavLink
|
|
className={clsx(
|
|
isDropdownItem ? 'dropdown__link' : 'navbar__item navbar__link',
|
|
className,
|
|
)}
|
|
isDropdownLink={isDropdownItem}
|
|
{...props}
|
|
/>
|
|
);
|
|
if (isDropdownItem) {
|
|
return <li>{element}</li>;
|
|
}
|
|
return element;
|
|
}
|
|
function DefaultNavbarItemMobile({className, isDropdownItem, ...props}) {
|
|
return (
|
|
<li className="menu__list-item">
|
|
<NavbarNavLink className={clsx('menu__link', className)} {...props} />
|
|
</li>
|
|
);
|
|
}
|
|
export default function DefaultNavbarItem({
|
|
mobile = false,
|
|
position, // Need to destructure position from props so that it doesn't get passed on.
|
|
...props
|
|
}) {
|
|
const Comp = mobile ? DefaultNavbarItemMobile : DefaultNavbarItemDesktop;
|
|
return (
|
|
<Comp
|
|
{...props}
|
|
activeClassName={
|
|
props.activeClassName ??
|
|
(mobile ? 'menu__link--active' : 'navbar__link--active')
|
|
}
|
|
/>
|
|
);
|
|
}
|