Skip to content

Commit

Permalink
chore(storybook): pass function to playground
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Mar 22, 2019
1 parent 256e4e4 commit d1321b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
25 changes: 6 additions & 19 deletions .storybook/decorators.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { action } from '@storybook/addon-actions';
import algoliasearch from 'algoliasearch/lite';
import instantsearch from '../src/index';
import moviesPlayground from './playgrounds/movies';
import defaultPlayground from './playgrounds/default';

export const withHits = (
Expand All @@ -21,7 +20,7 @@ export const withHits = (
apiKey = '6be0576ff61c053d5f9a3225e2a90f76',
indexName = 'instant_search',
searchParameters = {},
playground = 'default',
playground = defaultPlayground,
...instantsearchOptions
} = searchOptions || {};

Expand Down Expand Up @@ -68,23 +67,11 @@ export const withHits = (
rightPanelPlaygroundElement.classList.add('panel-right');
playgroundElement.appendChild(rightPanelPlaygroundElement);

switch (playground) {
case 'movies': {
moviesPlayground({
search,
leftPanel: leftPanelPlaygroundElement,
rightPanel: rightPanelPlaygroundElement,
});
break;
}
default: {
defaultPlayground({
search,
leftPanel: leftPanelPlaygroundElement,
rightPanel: rightPanelPlaygroundElement,
});
}
}
playground({
search,
leftPanel: leftPanelPlaygroundElement,
rightPanel: rightPanelPlaygroundElement,
});

storyFn({
container: previewElement,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/checkRendering.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Renderer } from '../../types/connector';

function checkRendering(rendering: Renderer<any>, usage: string) {
function checkRendering(rendering: Renderer, usage: string) {
if (rendering === undefined || typeof rendering !== 'function') {
throw new Error(`The render function is not valid (got type "${typeof rendering}").
Expand Down

0 comments on commit d1321b2

Please sign in to comment.