From 1ec10ba72e5da3aca9a7bc594d2de6e287a912f2 Mon Sep 17 00:00:00 2001 From: atanasster Date: Thu, 27 Feb 2020 21:49:24 -0500 Subject: [PATCH] fix: accept false for data: --- blocks/core/src/Source/Source.stories.tsx | 1 + blocks/core/src/StorySource/StorySource.tsx | 2 +- core/core/src/randomizeData.ts | 2 +- core/specification/src/controls.ts | 5 +++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/blocks/core/src/Source/Source.stories.tsx b/blocks/core/src/Source/Source.stories.tsx index dc89ba119..0aa9ff04d 100644 --- a/blocks/core/src/Source/Source.stories.tsx +++ b/blocks/core/src/Source/Source.stories.tsx @@ -63,6 +63,7 @@ simpleSource.story = { /> ); };`, + data: null, }, }, }, diff --git a/blocks/core/src/StorySource/StorySource.tsx b/blocks/core/src/StorySource/StorySource.tsx index 31604d535..980b0b558 100644 --- a/blocks/core/src/StorySource/StorySource.tsx +++ b/blocks/core/src/StorySource/StorySource.tsx @@ -123,7 +123,7 @@ export const StorySource: FC = ({ if (parentTheme === undefined) { actions.push({ title: themeName, onClick: onRotateTheme }); } - if (args) { + if (args && args.length) { actions.push({ title: viewStyle, onClick: onMergeValues }); } diff --git a/core/core/src/randomizeData.ts b/core/core/src/randomizeData.ts index cfcdd5a25..a73de9797 100644 --- a/core/core/src/randomizeData.ts +++ b/core/core/src/randomizeData.ts @@ -39,7 +39,7 @@ export const randomizeData = ( .map(name => { const control = controls[name]; const { data } = control; - if (data === null) { + if (data === false || data === null) { return null; } // check if control has custom settings for generating data diff --git a/core/specification/src/controls.ts b/core/specification/src/controls.ts index 8c8e8f78d..e926cfc70 100644 --- a/core/specification/src/controls.ts +++ b/core/specification/src/controls.ts @@ -174,9 +174,10 @@ export interface ComponentControlBase { /** * helper information to generate random data - * can be used in conjunction with faker.js + * will be used in conjunction with faker.js + * datacan be set to false, if the control should not be randomized */ - data?: ComponentControlData | null; + data?: ComponentControlData | null | false; } export interface ComponentControlText extends ComponentControlBase {