aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/navbar/navbar.tsx
blob: 39f3c45f010e9158669f60d053ba9c918f615b52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import {
  type ForwardRefRenderFunction,
  forwardRef,
  type ReactNode,
} from 'react';
import { List, type ListProps } from '../../atoms';
import styles from './navbar.module.scss';

export type NavbarProps = Omit<
  ListProps<false, false>,
  'children' | 'hideMarker' | 'isHierarchical' | 'isInline' | 'isOrdered'
> & {
  /**
   * The navbar items.
   *
   * The number of items should not exceed 3 because of the modal position on
   * small screens.
   */
  children: ReactNode;
};

const NavbarWithRef: ForwardRefRenderFunction<HTMLUListElement, NavbarProps> = (
  { children, className = '', ...props },
  ref
) => {
  const wrapperClass = `${styles.wrapper} ${className}`;

  return (
    <List {...props} className={wrapperClass} hideMarker isInline ref={ref}>
      {children}
    </List>
  );
};

/**
 * Navbar component
 *
 * Render the website navbar.
 */
export const Navbar = forwardRef(NavbarWithRef);