Skip to content

Commit

Permalink
improve types in search stories
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed May 10, 2023
1 parent 4a6fd2a commit 28f5df5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions code/ui/manager/src/components/sidebar/Search.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import type { StoryFn, Meta } from '@storybook/react';
import type { API } from '@storybook/manager-api';
import { ManagerContext } from '@storybook/manager-api';
import { action } from '@storybook/addon-actions';
Expand All @@ -18,28 +19,29 @@ const getLastViewed = () =>
.filter((item, i) => item.type === 'component' && item.parent && i % 20 === 0)
.map((component) => ({ storyId: component.id, refId }));

export default {
const meta = {
component: Search,
title: 'Sidebar/Search',
parameters: { layout: 'fullscreen', withSymbols: true },
decorators: [(storyFn: any) => <div style={{ padding: 20, maxWidth: '230px' }}>{storyFn()}</div>],
};
} satisfies Meta<typeof Search>;
export default meta;

const baseProps = {
dataset,
clearLastViewed: action('clear'),
getLastViewed: () => [] as Selection[],
};

export const Simple = () => <Search {...baseProps}>{() => null}</Search>;
export const Simple: StoryFn = () => <Search {...baseProps}>{() => null}</Search>;

export const FilledIn = () => (
export const FilledIn: StoryFn = () => (
<Search {...baseProps} initialQuery="Search query">
{() => <SearchResults {...noResults} />}
</Search>
);

export const LastViewed = () => (
export const LastViewed: StoryFn = () => (
<Search {...baseProps} getLastViewed={getLastViewed}>
{({ query, results, closeMenu, getMenuProps, getItemProps, highlightedIndex }) => (
<SearchResults
Expand All @@ -54,16 +56,16 @@ export const LastViewed = () => (
</Search>
);

export const ShortcutsDisabled = () => (
export const ShortcutsDisabled: StoryFn = () => (
<Search {...baseProps} enableShortcuts={false}>
{() => null}
</Search>
);

export const CustomShortcuts = () => <Search {...baseProps}>{() => null}</Search>;
export const CustomShortcuts: StoryFn = () => <Search {...baseProps}>{() => null}</Search>;

CustomShortcuts.decorators = [
(storyFn: any) => (
(storyFn) => (
<ManagerContext.Provider
value={
{
Expand Down

0 comments on commit 28f5df5

Please sign in to comment.