Skip to content

Commit

Permalink
refactor(storybook): fix types in stories (#1551)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtsvetkov-splunk authored Jan 31, 2025
1 parent 7286664 commit c6b356d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ import InputPage from '../../../pages/Input/InputPage';
const meta = {
component: InputPage,
title: 'CheckboxGroup/Page',
render: (args) => {
setUnifiedConfig(args.globalConfig);
render: (_args, { parameters }) => {
setUnifiedConfig(parameters.globalConfig);
return <InputPage />;
},
args: {
globalConfig: checkboxGroupConfig,
},
parameters: {
msw: {
handlers: serverHandlers,
},
globalConfig: checkboxGroupConfig,
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
Expand All @@ -40,7 +38,7 @@ type Story = StoryObj<typeof BaseFormView>;
export const InputPageView: Story = {};

export const RequiredView: Story = {
args: {
parameters: {
globalConfig: checkboxGroupRequiredConfig,
},
play: async ({ canvasElement }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ import InputPage from '../../../pages/Input/InputPage';
const meta = {
component: InputPage,
title: 'CheckboxTree/Page',
render: (args) => {
setUnifiedConfig(args.globalConfig);
render: (_args, { parameters }) => {
setUnifiedConfig(parameters.globalConfig);
return <InputPage />;
},
args: {
globalConfig: CheckboxTreeConfig,
},
parameters: {
globalConfig: CheckboxTreeConfig,
msw: {
handlers: serverHandlers,
},
Expand All @@ -40,7 +38,7 @@ type Story = StoryObj<typeof BaseFormView>;
export const InputPageView: Story = {};

export const RequiredView: Story = {
args: {
parameters: {
globalConfig: CheckboxTreeRequiredConfig,
},
play: async ({ canvasElement }) => {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/table/stories/TableWrapper.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { ReactNode } from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { fn } from '@storybook/test';

Expand All @@ -23,7 +23,7 @@ const meta = {
setUnifiedConfig(props.config);
return (
<TableContextProvider>
{(<TableWrapper {...props} />) as unknown as Node}
{(<TableWrapper {...props} />) as unknown as ReactNode}
</TableContextProvider>
);
},
Expand Down
8 changes: 5 additions & 3 deletions ui/src/pages/stories/GlobalConfigPlayground.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react';
import { SplunkThemeProvider } from '@splunk/themes';
import TabBar from '@splunk/react-ui/TabBar';
import TabBar, { TabBarChangeHandler } from '@splunk/react-ui/TabBar';
import React, { useCallback, useState } from 'react';
import { http, HttpResponse } from 'msw';

Expand All @@ -27,8 +27,10 @@ const meta = {
const pageKeys = Object.keys(config.pages);
const [activeTabId, setActiveTabId] = useState(pageKeys[0]);

const handleChange = useCallback((e, { selectedTabId }) => {
setActiveTabId(selectedTabId);
const handleChange: TabBarChangeHandler = useCallback((e, { selectedTabId }) => {
if (selectedTabId !== undefined) {
setActiveTabId(selectedTabId);
}
}, []);

const page = pageMap[activeTabId];
Expand Down

0 comments on commit c6b356d

Please sign in to comment.