Skip to content

Commit c185b3b

Browse files
authored
Merge pull request #67 from sushobhit-lt/DOT-1974
[Dot 1974] handle custom viewports for storybook
2 parents 8ccaafe + 719357e commit c185b3b

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

commands/storybook.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ async function storybook(serve, options) {
116116
browsers: browsers,
117117
resolutions: resolutions,
118118
storyIds: storyIds,
119-
waitForTimeout: storybookConfig.waitForTimeout
119+
waitForTimeout: storybookConfig.waitForTimeout,
120+
customViewports: storybookConfig.customViewports
120121
},
121122
git: {
122123
branch: commit.branch,

commands/utils/config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ const defaultSmartUIConfig = {
66
'safari',
77
'edge'
88
],
9-
resolutions: [
9+
viewports: [
1010
[1920, 1080]
1111
],
1212
waitForTimeout: 0,
1313
include: [],
14-
exclude: []
14+
exclude: [],
15+
customViewports: []
1516
}
1617
};
1718

commands/utils/dom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async function sendDoM(storybookUrl, stories, storybookConfig, options) {
6666
form.append('commitId', commit.shortHash);
6767
form.append('commitAuthor', commit.author.name);
6868
form.append('commitMessage', commit.subject);
69-
69+
form.append('customViewports', JSON.stringify(storybookConfig.customViewports));
7070
githubURL = process.env.GITHUB_URL
7171
if (githubURL) {
7272
form.append('githubURL', githubURL);

commands/utils/validate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ function validateConfig(configFile) {
125125

126126
try {
127127
validateConfigBrowsers(storybookConfig.browsers);
128-
storybookConfig.resolutions = validateConfigResolutions(storybookConfig.resolutions);
128+
resolutions = storybookConfig.resolutions || storybookConfig.viewports
129+
storybookConfig.resolutions = validateConfigResolutions(resolutions);
129130
} catch (error) {
130131
console.log(`[smartui] Error: Invalid config, ${error.message}`);
131132
process.exit(constants.ERROR_CATCHALL);
@@ -136,7 +137,7 @@ function validateConfig(configFile) {
136137
storybookConfig.waitForTimeout = 0;
137138
} else if (storybookConfig.waitForTimeout <= 0 || storybookConfig.waitForTimeout > 30000) {
138139
console.log('[smartui] Warning: Invalid config, value of waitForTimeout must be > 0 and <= 30000');
139-
console.log('If you do not wish to include waitForTimeout parameter, remove it from the config file.');
140+
console.log('[smartui] If you do not wish to include waitForTimeout parameter, remove it from the config file.');
140141
storybookConfig.waitForTimeout = 0;
141142
}
142143

0 commit comments

Comments
 (0)