/
githubmirror
/
immutable-js
Обзор
Документация
Войти
/
githubmirror
/
immutable-js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
website/src/sidebar/Sidebar.tsx
46 строк
1 KB
Julien Deniau
sort all imports via eslint
12 июн 2025, 01:23
12 июн 2025, 01:23
67a4fa9
Код
Авторство
О чём код?
'use client'; import { Fragment, useState } from 'react'; import { SIDEBAR_LINKS } from '../app/docs/currentVersion'; import Focus, { FocusType } from './Focus'; import SidebarMainLink from './SidebarMainLink'; export type SidebarLinks = Array<{ label: string; url: string }>; export default function SideBar({ links = SIDEBAR_LINKS, focus, activeType, }: { links?: SidebarLinks; focus?: FocusType; activeType?: string; }) { const [isForcedClosed, setIsForcedClosed] = useState(false); return ( <div className="sideBar"> <div className="sideBar__background" /> <div className="scrollContent"> <h2>Immutable.js</h2> {links.map((link) => { const isCurrent = activeType === link.label; const isActive = isCurrent && !isForcedClosed; return ( <Fragment key={link.url}> <SidebarMainLink label={link.label} url={link.url} isActive={isActive} canBeFocused={Boolean(focus?.length)} onClick={() => setIsForcedClosed((prev) => !prev)} /> {isActive && <Focus focus={focus} />} </Fragment> ); })} </div> </div> ); }