Skip to content

Commit

Permalink
Change name of component used in stories
Browse files Browse the repository at this point in the history
  • Loading branch information
standeren committed Oct 30, 2024
1 parent f6b826b commit fa401ce
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';
import type { Meta, StoryFn } from '@storybook/react';
import { BookIcon, VideoIcon, QuestionmarkDiamondIcon, ExternalLinkIcon } from '@studio/icons';
import type { StudioContentMenuWrapperProps } from './StudioContentMenuWrapper';
import { StudioContentMenuWrapper } from './StudioContentMenuWrapper';
import type { StudioContentMenuStoryExampleProps } from './StudioContentMenuStoryExample';
import { StudioContentMenuStoryExample } from './StudioContentMenuStoryExample';

type Story = StoryFn<StudioContentMenuWrapperProps<StudioMenuTabName>>;
type Story = StoryFn<StudioContentMenuStoryExampleProps<StudioMenuTabName>>;

const meta: Meta<StudioContentMenuWrapperProps<StudioMenuTabName>> = {
const meta: Meta<StudioContentMenuStoryExampleProps<StudioMenuTabName>> = {
title: 'Components/StudioContentMenu',
component: StudioContentMenuWrapper,
component: StudioContentMenuStoryExample,
argTypes: {
buttonTabs: {
control: 'object',
Expand Down Expand Up @@ -38,8 +38,8 @@ export default meta;

type StudioMenuTabName = 'booksTab' | 'videosTab' | 'tabWithVeryLongTabName' | 'tabAsLink';

export const Preview: Story = (args: StudioContentMenuWrapperProps<StudioMenuTabName>) => (
<StudioContentMenuWrapper {...args} />
export const Preview: Story = (args: StudioContentMenuStoryExampleProps<StudioMenuTabName>) => (
<StudioContentMenuStoryExample {...args} />
);

Preview.args = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import { StudioContentMenu } from './';
import type { StudioContentMenuWrapperProps } from './StudioContentMenuWrapper';
import { StudioContentMenu, type StudioContentMenuLinkTabProps } from './';
import type { StudioContentMenuButtonTabProps } from './StudioContentMenuButtonTab';

type StudioMenuTabName = 'tab1' | 'tab2' | 'tab3';
Expand Down Expand Up @@ -174,10 +173,15 @@ describe('StudioContentMenu', () => {
});
});

type RenderStudioContentMenuProps<TabId extends string> = {
buttonTabs: StudioContentMenuButtonTabProps<TabId>[];
linkTabs: StudioContentMenuLinkTabProps<TabId>[];
};

const renderStudioContentMenu = ({
buttonTabs = [],
linkTabs = [],
}: Partial<StudioContentMenuWrapperProps<StudioMenuTabName>> = {}) => {
}: Partial<RenderStudioContentMenuProps<StudioMenuTabName>> = {}) => {
render(
<StudioContentMenu selectedTabId={undefined} onChangeTab={onChangeTabMock}>
{buttonTabs.map((buttonTab) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import React from 'react';
import { StudioContentMenu } from './';
import classes from './StudioContentMenuWrapper.module.css';
import classes from './StudioContentMenuStoryExample.module.css';
import type { StudioContentMenuButtonTabProps } from './StudioContentMenuButtonTab';
import type { StudioContentMenuLinkTabProps } from './StudioContentMenuLinkTab';

export type StudioContentMenuWrapperProps<TabId extends string> = {
export type StudioContentMenuStoryExampleProps<TabId extends string> = {
buttonTabs: StudioContentMenuButtonTabProps<TabId>[];
linkTabs: StudioContentMenuLinkTabProps<TabId>[];
selectedTabId: TabId;
onChangeTab: (tabId: TabId) => void;
};

export function StudioContentMenuWrapper<TabId extends string>({
export function StudioContentMenuStoryExample<TabId extends string>({
selectedTabId,
onChangeTab,
buttonTabs,
linkTabs,
}: StudioContentMenuWrapperProps<TabId>) {
}: StudioContentMenuStoryExampleProps<TabId>) {
return (
<div className={classes.contentMenuWrapper}>
<StudioContentMenu selectedTabId={selectedTabId} onChangeTab={onChangeTab}>
Expand Down

0 comments on commit fa401ce

Please sign in to comment.