{"size": 1651, "ext": "js", "max_stars_repo_path": "src/infinite-menu/InfiniteMenu.js", "max_stars_repo_name": "boof-tech/react-treemenu-tis", "max_stars_repo_stars_event_min_datetime": "2021-05-26T12:17:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-26T12:17:04.000Z", "max_issues_repo_path": "src/infinite-menu/InfiniteMenu.js", "max_issues_repo_name": "boof-tech/react-treemenu-tis", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/infinite-menu/InfiniteMenu.js", "max_forks_repo_name": "boof-tech/react-treemenu-tis", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 36.6888888889, "max_line_length": 124, "alphanum_fraction": 0.459721381}
import React from 'react';
import classNames from 'classnames';
import { RightIcon } from '../assets/icons';
import css from './infinite-menu.module.scss';

const InfiniteMenu = ({ className, items, onClick, selected, darkMode = false }) => (
   <ul className={classNames(css.menu_InfiniteMenuTis, {
      [css.Dark_InfiniteMenuTis]: darkMode
   })}>
      {items?.length > 0 &&
         items.map(({ title, items: subItems }) => (
            <li key={title} className={css.item_InfiniteMenuTis}>
               {subItems ? (
                  <div
                     className={classNames(css.subMenuButton_InfiniteMenuTis, {
                        [css.selected_InfiniteMenuTis]: subItems.filter(subItem => subItem?.title === selected)?.length > 0,
                     })}
                  >
                     {title}
                     <InfiniteMenu
                        className={className}
                        items={subItems}
                        onClick={onClick}
                        darkMode={darkMode}
                        selected={selected}
                     />
                     <RightIcon className={css.arrowIcon_InfiniteMenuTis} />
                  </div>
               ) : (
                  <div
                     className={classNames(css.link_InfiniteMenuTis, {
                        [css.selected_InfiniteMenuTis]: selected === title,
                     }, className)}
                     onClick={() => onClick(title)}
                  >
                     {title}
                  </div>
               )}
            </li>
         ))}
   </ul>
);

export default InfiniteMenu;
