Navigation.jsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. Copyright (C) 2025 QuantumNous
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. For commercial licensing, please contact support@quantumnous.com
  14. */
  15. import React from 'react';
  16. import { Link } from 'react-router-dom';
  17. import SkeletonWrapper from '../components/SkeletonWrapper';
  18. const Navigation = ({
  19. mainNavLinks,
  20. isMobile,
  21. isLoading,
  22. userState,
  23. pricingRequireAuth,
  24. }) => {
  25. const renderNavLinks = () => {
  26. const baseClasses =
  27. 'flex-shrink-0 flex items-center gap-1 font-semibold rounded-md transition-all duration-200 ease-in-out';
  28. const hoverClasses = 'hover:text-semi-color-primary';
  29. const spacingClasses = isMobile ? 'p-1' : 'p-2';
  30. const commonLinkClasses = `${baseClasses} ${spacingClasses} ${hoverClasses}`;
  31. return mainNavLinks.map((link) => {
  32. const linkContent = <span>{link.text}</span>;
  33. if (link.isExternal) {
  34. return (
  35. <a
  36. key={link.itemKey}
  37. href={link.externalLink}
  38. target='_blank'
  39. rel='noopener noreferrer'
  40. className={commonLinkClasses}
  41. >
  42. {linkContent}
  43. </a>
  44. );
  45. }
  46. let targetPath = link.to;
  47. if (link.itemKey === 'console' && !userState.user) {
  48. targetPath = '/login';
  49. }
  50. if (link.itemKey === 'pricing' && pricingRequireAuth && !userState.user) {
  51. targetPath = '/login';
  52. }
  53. return (
  54. <Link key={link.itemKey} to={targetPath} className={commonLinkClasses}>
  55. {linkContent}
  56. </Link>
  57. );
  58. });
  59. };
  60. return (
  61. <nav className='flex flex-1 items-center gap-1 lg:gap-2 mx-2 md:mx-4 overflow-x-auto whitespace-nowrap scrollbar-hide'>
  62. <SkeletonWrapper
  63. loading={isLoading}
  64. type='navigation'
  65. count={4}
  66. width={60}
  67. height={16}
  68. isMobile={isMobile}
  69. >
  70. {renderNavLinks()}
  71. </SkeletonWrapper>
  72. </nav>
  73. );
  74. };
  75. export default Navigation;