From d1321b291963c59955fac3f5d83789e818484685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chalifour?= Date: Tue, 12 Mar 2019 17:49:49 +0100 Subject: [PATCH] chore(storybook): pass function to playground --- .storybook/decorators.ts | 25 ++++++------------------- src/lib/utils/checkRendering.ts | 2 +- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/.storybook/decorators.ts b/.storybook/decorators.ts index 785f950a07c..8a0c639d0fd 100644 --- a/.storybook/decorators.ts +++ b/.storybook/decorators.ts @@ -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 = ( @@ -21,7 +20,7 @@ export const withHits = ( apiKey = '6be0576ff61c053d5f9a3225e2a90f76', indexName = 'instant_search', searchParameters = {}, - playground = 'default', + playground = defaultPlayground, ...instantsearchOptions } = searchOptions || {}; @@ -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, diff --git a/src/lib/utils/checkRendering.ts b/src/lib/utils/checkRendering.ts index b35e990449c..94c8cab24be 100644 --- a/src/lib/utils/checkRendering.ts +++ b/src/lib/utils/checkRendering.ts @@ -1,6 +1,6 @@ import { Renderer } from '../../types/connector'; -function checkRendering(rendering: Renderer, 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}").