Skip to content

Commit

Permalink
Use a better name for the actual library content and menu --> Library…
Browse files Browse the repository at this point in the history
…Body
  • Loading branch information
standeren committed Oct 30, 2024
1 parent 8dac1fb commit bcacb06
Show file tree
Hide file tree
Showing 25 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import classes from './ContentLibrary.module.css';
import { LibraryHeader } from './LibraryHeader';
import { StudioHeading } from '@studio/components';
import type { PageName } from '../types/PageName';
import { LibraryContent } from './LibraryContent/LibraryContent';
import { LibraryBody } from './LibraryBody';

type ContentLibraryProps = {
pages: PagesConfig;
Expand Down Expand Up @@ -37,7 +37,7 @@ function ContentLibraryForPage<T extends PageName = 'landingPage'>({
<div className={classes.libraryBackground}>
<div className={classes.libraryContainer}>
<LibraryHeader />
<LibraryContent Component={Component} pages={pages} currentPage={currentPage} />
<LibraryBody Component={Component} pages={pages} currentPage={currentPage} />
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import type { PagePropsMap, PagesConfig } from '../../types/PagesProps';
import type { PageName } from '../../types/PageName';
import type { PageComponent } from '../../utils/router/RouterRouteMapper';

type LibraryContentProps<T extends PageName = 'landingPage'> = {
type LibraryBodyProps<T extends PageName = 'landingPage'> = {
Component: PageComponent<Required<PagePropsMap>[T]>;
pages: PagesConfig;
currentPage: PageName;
};

export function LibraryContent<T extends PageName = 'landingPage'>({
export function LibraryBody<T extends PageName = 'landingPage'>({
Component,
pages,
currentPage,
}: LibraryContentProps) {
}: LibraryBodyProps) {
const componentProps: Required<PagePropsMap>[T] = pages[currentPage]
?.props as Required<PagePropsMap>[T];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { PagesRouter } from './PagesRouter';
import { textMock } from '@studio/testing/mocks/i18nMock';
import { RouterContext } from '../../../contexts/RouterContext';
import type { PageName } from '../../../types/PageName';
import { BrowserRouter } from 'react-router-dom';
import { renderWithBrowserRouter } from '../../../../test-utils/renderWithBrowserRouter';

const navigateMock = jest.fn();

Expand Down Expand Up @@ -35,11 +35,9 @@ describe('PagesRouter', () => {
});

const renderPagesRouter = (pageNames: PageName[] = ['codeList', 'images']) => {
render(
<BrowserRouter>
<RouterContext.Provider value={{ currentPage: 'codeList', navigate: navigateMock }}>
<PagesRouter pageNames={pageNames} />
</RouterContext.Provider>
</BrowserRouter>,
renderWithBrowserRouter(
<RouterContext.Provider value={{ currentPage: 'codeList', navigate: navigateMock }}>
<PagesRouter pageNames={pageNames} />
</RouterContext.Provider>,
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { LibraryBody } from './LibraryBody';
4 changes: 2 additions & 2 deletions frontend/libs/studio-content-library/src/types/PagesProps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CodeListProps } from '../ContentLibrary/LibraryContent/pages/CodeList';
import type { CodeListProps } from '../ContentLibrary/LibraryBody/pages/CodeList';
import type { PageName } from './PageName';
import type { ImagesProps } from '../ContentLibrary/LibraryContent/pages/Images';
import type { ImagesProps } from '../ContentLibrary/LibraryBody/pages/Images';

export type PagePropsMap = {
landingPage?: {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RouterRouteMapperImpl } from './RouterRouteMapper';
import { LandingPage } from '../../ContentLibrary/LibraryContent/pages/LandingPage';
import { CodeList } from '../../ContentLibrary/LibraryContent/pages/CodeList';
import { LandingPage } from '../../ContentLibrary/LibraryBody/pages/LandingPage';
import { CodeList } from '../../ContentLibrary/LibraryBody/pages/CodeList';
import { mockPagesConfig } from '../../../mocks/mockPagesConfig';

describe('RouterRouteMapperImpl', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type ComponentProps, type ReactElement } from 'react';
import { CodeList } from '../../ContentLibrary/LibraryContent/pages/CodeList';
import { CodeList } from '../../ContentLibrary/LibraryBody/pages/CodeList';
import type { PageName } from '../../types/PageName';
import { LandingPage } from '../../ContentLibrary/LibraryContent/pages/LandingPage';
import { LandingPage } from '../../ContentLibrary/LibraryBody/pages/LandingPage';
import type { PagesConfig } from '../../types/PagesProps';
import { Images } from '../../ContentLibrary/LibraryContent/pages/Images';
import { Images } from '../../ContentLibrary/LibraryBody/pages/Images';

type PageProps =
| ComponentProps<typeof LandingPage>
Expand Down

0 comments on commit bcacb06

Please sign in to comment.