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 87c96bf
Show file tree
Hide file tree
Showing 22 changed files with 12 additions and 13 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';

0 comments on commit 87c96bf

Please sign in to comment.