Skip to content

Commit f6da703

Browse files
feat: add support for exclude in custom viewport
1 parent c9b7ab8 commit f6da703

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

commands/storybook.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ async function storybook(serve, options) {
4545
process.exit(constants.ERROR_CATCHALL);
4646
}
4747
console.log('[smartui] Stories found: ', Object.keys(stories).length);
48+
console.log('[smartui] Number of stories rendered may defer based on the config file.');
4849

4950
// Capture DoM of every story and send it to renderer API
5051
await sendDoM(url, stories, storybookConfig, options);

commands/utils/static.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function filterStories(dirPath, storybookConfig) {
7272
process.exit(constants.ERROR_CATCHALL);
7373
}
7474
console.log('[smartui] Stories found: ', storyIds.length);
75+
console.log('[smartui] Number of stories rendered may defer based on the config file.');
7576

7677
return storyIds
7778
}

commands/utils/validate.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,19 @@ function validateConfig(configFile) {
128128

129129
try {
130130
validateConfigBrowsers(storybookConfig.browsers);
131-
resolutions = storybookConfig.resolutions || storybookConfig.viewports
132-
storybookConfig.resolutions = validateConfigResolutions(resolutions);
131+
let resolutions = storybookConfig.resolutions || storybookConfig.viewports
132+
if (resolutions) {
133+
storybookConfig.resolutions = validateConfigResolutions(resolutions);
134+
}
133135
storybookConfig.viewports = storybookConfig.resolutions;
134-
validateCustomViewPorts(storybookConfig.customViewports)
136+
let customViewports = storybookConfig.customViewports;
137+
if (customViewports && customViewports.length > 0) {
138+
validateCustomViewPorts(storybookConfig.customViewports)
139+
}
140+
if (!resolutions && (!customViewports || customViewports.length === 0)) {
141+
console.log('[smartui] Error: No resolutions or customViewports found in config file');
142+
process.exit(constants.ERROR_CATCHALL);
143+
}
135144
} catch (error) {
136145
console.log(`[smartui] Error: Invalid config, ${error.message}`);
137146
process.exit(constants.ERROR_CATCHALL);
@@ -228,8 +237,8 @@ function validateCustomViewPorts(customViewports) {
228237
return
229238
}
230239
customViewports.forEach(element => {
231-
if (!Array.isArray(element.stories) || element.stories == 0) {
232-
throw new ValidationError('Missing `stories` in customViewports config. please check the config file');
240+
if (element.stories && element.stories.length !== 0 && element.exclude && element.exclude.length !== 0) {
241+
throw new ValidationError('Cannot specify both stories and excludeStories in customViewports');
233242
}
234243
if (element.styles) {
235244
if (!element.styles?.width) {

0 commit comments

Comments
 (0)