From beba895c5c2204059c26a831a233138ed24ca267 Mon Sep 17 00:00:00 2001 From: Charles de Dreuille Date: Fri, 18 Jul 2025 15:41:24 +0100 Subject: [PATCH] Fix stories Signed-off-by: Charles de Dreuille --- .../src/components/Header/Header.stories.tsx | 18 +++--- .../HeaderPage/HeaderPage.stories.tsx | 62 ++++--------------- 2 files changed, 21 insertions(+), 59 deletions(-) diff --git a/packages/ui/src/components/Header/Header.stories.tsx b/packages/ui/src/components/Header/Header.stories.tsx index da33b1a0f5..607d033ea4 100644 --- a/packages/ui/src/components/Header/Header.stories.tsx +++ b/packages/ui/src/components/Header/Header.stories.tsx @@ -40,7 +40,7 @@ const meta = { export default meta; type Story = StoryObj; -const withRouter = (Story: StoryFn) => ( +export const withRouter = (Story: StoryFn) => ( @@ -113,7 +113,7 @@ const menuItems: HeaderMenuItem[] = [ ]; // Extract layout decorator as a reusable constant -const layoutDecorator = [ +export const layoutDecorator = [ (Story: StoryFn) => ( <>
- + Current URL is mocked to be: /campaigns - + Notice how the "Campaigns" tab is selected (highlighted) because it matches the current path. @@ -301,10 +301,10 @@ export const WithMockedURLIntegrations: Story = {
- + Current URL is mocked to be: /integrations - + Notice how the "Integrations" tab is selected (highlighted) because it matches the current path. @@ -321,14 +321,14 @@ export const WithMockedURLNoMatch: Story = {
- + Current URL is mocked to be: /some-other-page - + No tab is selected because the current path doesn't match any tab's href. - + Tabs without href (like "Overview", "Checks", "Tracks") fall back to React Aria's internal state. diff --git a/packages/ui/src/components/HeaderPage/HeaderPage.stories.tsx b/packages/ui/src/components/HeaderPage/HeaderPage.stories.tsx index 6a4e7bef6f..3d755c2855 100644 --- a/packages/ui/src/components/HeaderPage/HeaderPage.stories.tsx +++ b/packages/ui/src/components/HeaderPage/HeaderPage.stories.tsx @@ -14,11 +14,11 @@ * limitations under the License. */ -import type { Meta, StoryObj, StoryFn } from '@storybook/react'; +import type { Meta, StoryObj } from '@storybook/react'; import { HeaderPage } from './HeaderPage'; import type { HeaderTab, HeaderMenuItem } from '../Header/types'; -import { MemoryRouter } from 'react-router-dom'; import { Button } from '../Button'; +import { layoutDecorator, withRouter } from '../Header/Header.stories'; const meta = { title: 'Components/HeaderPage', @@ -26,13 +26,6 @@ const meta = { parameters: { layout: 'fullscreen', }, - decorators: [ - (Story: StoryFn) => ( - - - - ), - ], } satisfies Meta; export default meta; @@ -72,47 +65,6 @@ const menuItems: HeaderMenuItem[] = [ }, ]; -// Extract layout decorator as a reusable constant -const layoutDecorator = [ - (Story: StoryFn) => ( - <> -
-
- -
-
- - ), -]; - export const Default: Story = { args: { title: 'Header Page', @@ -124,6 +76,7 @@ export const WithTabs: Story = { ...Default.args, tabs, }, + decorators: [withRouter], }; export const WithMenuItems: Story = { @@ -144,6 +97,7 @@ export const WithCustomActions: Story = { }; export const WithEverything: Story = { + decorators: [withRouter], render: () => ( ( + Custom action} + /> + ), };