diff --git a/src/app/Root/Root.tsx b/src/app/Root/Root.tsx index a140de1..088188f 100644 --- a/src/app/Root/Root.tsx +++ b/src/app/Root/Root.tsx @@ -1,9 +1,8 @@ -import { Layout } from '../../components/Layout' -import { Menu } from '../../components/Menu' - -import { useGetTocQuery } from '../../features/toc' import { DocPage } from '../../components/DocPage' import { Error } from '../../components/Error' +import { Layout } from '../../components/Layout' +import { useGetTocQuery } from '../../features/toc' +import { Menu } from '../../features/toc/ui/Menu' import tocUrl from '/toc.json?url' export function Root() { diff --git a/src/components/Menu/Context/MenuProvider.tsx b/src/features/toc/ui/Menu/Context/MenuProvider.tsx similarity index 79% rename from src/components/Menu/Context/MenuProvider.tsx rename to src/features/toc/ui/Menu/Context/MenuProvider.tsx index cdf445c..5584ff3 100644 --- a/src/components/Menu/Context/MenuProvider.tsx +++ b/src/features/toc/ui/Menu/Context/MenuProvider.tsx @@ -1,5 +1,6 @@ -import { type PropsWithChildren } from 'react' -import { getBreadCrumbs, type PageURL, type TableOfContent } from '../../../features/toc' +import type { PropsWithChildren } from 'react' +import { getBreadCrumbs } from '../../../core/getBreadCrumbs' +import type { PageURL, TableOfContent } from '../../../types' import { LocationContext, TocContext } from './contexts' type MenuProviderProps = PropsWithChildren<{ diff --git a/src/components/Menu/Context/contexts.ts b/src/features/toc/ui/Menu/Context/contexts.ts similarity index 86% rename from src/components/Menu/Context/contexts.ts rename to src/features/toc/ui/Menu/Context/contexts.ts index 4956f4a..1d8e5cf 100644 --- a/src/components/Menu/Context/contexts.ts +++ b/src/features/toc/ui/Menu/Context/contexts.ts @@ -1,5 +1,6 @@ import { createContext } from 'react' -import { type PageDescriptor, type PageURL, type TableOfContent } from '../../../features/toc' + +import type { PageDescriptor, PageURL, TableOfContent } from '../../../types' type TocContextValue = { toc: TableOfContent diff --git a/src/components/Menu/Context/hooks.ts b/src/features/toc/ui/Menu/Context/hooks.ts similarity index 83% rename from src/components/Menu/Context/hooks.ts rename to src/features/toc/ui/Menu/Context/hooks.ts index a400b98..5b4e667 100644 --- a/src/components/Menu/Context/hooks.ts +++ b/src/features/toc/ui/Menu/Context/hooks.ts @@ -1,5 +1,7 @@ import { useContext } from 'react' -import { buildMenu, type PageId, type SectionHighlight } from '../../../features/toc' + +import { buildMenu } from '../../../core/buildMenu' +import type { PageId, SectionHighlight } from '../../../types' import { LocationContext, TocContext } from './contexts' export const useMenuItems = (parentId: PageId = '', level: number = 0, highlight: SectionHighlight) => { diff --git a/src/components/Menu/Item/Item.module.css b/src/features/toc/ui/Menu/Item/Item.module.css similarity index 100% rename from src/components/Menu/Item/Item.module.css rename to src/features/toc/ui/Menu/Item/Item.module.css diff --git a/src/components/Menu/Item/Item.tsx b/src/features/toc/ui/Menu/Item/Item.tsx similarity index 89% rename from src/components/Menu/Item/Item.tsx rename to src/features/toc/ui/Menu/Item/Item.tsx index 7a17ef3..fdc4c15 100644 --- a/src/components/Menu/Item/Item.tsx +++ b/src/features/toc/ui/Menu/Item/Item.tsx @@ -1,10 +1,10 @@ import clsx from 'clsx' import { useState, type PropsWithChildren } from 'react' -import type { MenuItem } from '../../../features/toc' -import { Chevron } from '../../Chevron' -import { OptionalLink } from '../../OptionalLink' -import { Skeleton } from '../../Skeleton' +import { Chevron } from '../../../../../components/Chevron' +import { OptionalLink } from '../../../../../components/OptionalLink' +import { Skeleton } from '../../../../../components/Skeleton' +import type { MenuItem } from '../../../types' import { useIsLoading } from '../Context/hooks' import styles from './Item.module.css' diff --git a/src/components/Menu/Menu.module.css b/src/features/toc/ui/Menu/Menu.module.css similarity index 100% rename from src/components/Menu/Menu.module.css rename to src/features/toc/ui/Menu/Menu.module.css diff --git a/src/components/Menu/Menu.test.tsx b/src/features/toc/ui/Menu/Menu.test.tsx similarity index 89% rename from src/components/Menu/Menu.test.tsx rename to src/features/toc/ui/Menu/Menu.test.tsx index 934f9fd..31ef32a 100644 --- a/src/components/Menu/Menu.test.tsx +++ b/src/features/toc/ui/Menu/Menu.test.tsx @@ -1,13 +1,13 @@ import { act, fireEvent, screen, waitFor } from '@testing-library/react' import { describe, expect, it } from 'vitest' -import type { TableOfContent } from '../../features/toc' -import tocFlat from '../../test/fixtures/toc/flat.json' -import tocTwoLevels from '../../test/fixtures/toc/two-levels.json' -import { renderInApp } from '../../test' +import { renderInApp } from '../../../../test' +import tocFlat from '../../../../test/fixtures/toc/flat.json' +import tocTwoLevels from '../../../../test/fixtures/toc/two-levels.json' +import type { TableOfContent } from '../../types' import { Menu } from './Menu' -describe('components/Menu', () => { +describe('features/toc/ui/Menu', () => { it('should render skeletons while TOC is loading', async () => { const toc: TableOfContent = tocTwoLevels const currentUrl = '/bar.html' diff --git a/src/components/Menu/Menu.tsx b/src/features/toc/ui/Menu/Menu.tsx similarity index 83% rename from src/components/Menu/Menu.tsx rename to src/features/toc/ui/Menu/Menu.tsx index 5ceb322..254bfca 100644 --- a/src/components/Menu/Menu.tsx +++ b/src/features/toc/ui/Menu/Menu.tsx @@ -1,5 +1,5 @@ -import { type TableOfContent } from '../../features/toc' -import { useCurrentPageUrl } from '../../hooks/useCurrentPageUrl' +import { useCurrentPageUrl } from '../../../../hooks/useCurrentPageUrl' +import type { TableOfContent } from '../../types' import { MenuProvider } from './Context/MenuProvider' import { Section } from './Section/Section' diff --git a/src/components/Menu/Section/Section.tsx b/src/features/toc/ui/Menu/Section/Section.tsx similarity index 93% rename from src/components/Menu/Section/Section.tsx rename to src/features/toc/ui/Menu/Section/Section.tsx index 2b4b828..5b9dffd 100644 --- a/src/components/Menu/Section/Section.tsx +++ b/src/features/toc/ui/Menu/Section/Section.tsx @@ -1,4 +1,4 @@ -import { type PageId, type SectionHighlight } from '../../../features/toc' +import type { PageId, SectionHighlight } from '../../../types' import { useMenuItems } from '../Context/hooks' import { Item, ItemToggle } from '../Item/Item' diff --git a/src/components/Menu/__snapshots__/Menu.test.tsx.snap b/src/features/toc/ui/Menu/__snapshots__/Menu.test.tsx.snap similarity index 59% rename from src/components/Menu/__snapshots__/Menu.test.tsx.snap rename to src/features/toc/ui/Menu/__snapshots__/Menu.test.tsx.snap index cae8205..6976267 100644 --- a/src/components/Menu/__snapshots__/Menu.test.tsx.snap +++ b/src/features/toc/ui/Menu/__snapshots__/Menu.test.tsx.snap @@ -1,22 +1,22 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`components/Menu > should build a menu and highlight current page 1`] = ` +exports[`features/toc/ui/Menu > should build a menu and highlight current page 1`] = ` `; -exports[`components/Menu > should build a two-levels menu and open all parents that contains current page 1`] = ` +exports[`features/toc/ui/Menu > should build a two-levels menu and open all parents that contains current page 1`] = ` `; -exports[`components/Menu > should close a submenu when clicking on a chevron 1`] = ` +exports[`features/toc/ui/Menu > should close a submenu when clicking on a chevron 1`] = ` `; -exports[`components/Menu > should close a submenu when clicking on a chevron 2`] = ` +exports[`features/toc/ui/Menu > should close a submenu when clicking on a chevron 2`] = ` `; -exports[`components/Menu > should render skeletons while TOC is loading 1`] = ` +exports[`features/toc/ui/Menu > should render skeletons while TOC is loading 1`] = `