Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Story level viewports don't override default viewport parameters with CSF #80

Closed
kylesuss opened this issue Dec 20, 2019 · 4 comments
Closed
Labels
bug Classification: Something isn't working

Comments

@kylesuss
Copy link
Contributor

kylesuss commented Dec 20, 2019

"storybook-chromatic": "^3.4.1"

Given this default export:
https://github.com/kylesuss/gh-provider-test/blob/45e20ad58547f498ca7295db38c1c865ee9718b1/stories/index.stories.js#L8-L13

const VIEWPORT_XSMALL = 400;
const VIEWPORT_SMALL = 768;
const VIEWPORT_MEDIUM = 1280;

export default {
  title: "Demo",
  parameters: {
    chromatic: { viewports: [VIEWPORT_XSMALL, VIEWPORT_SMALL, VIEWPORT_MEDIUM] }
  }
};

and this story:
https://github.com/kylesuss/gh-provider-test/blob/45e20ad58547f498ca7295db38c1c865ee9718b1/stories/index.stories.js#L51-L65

export const Button = () => {
  const button = document.createElement("button");
  button.type = "button";
  button.style = "color:green;";
  button.innerText = "Hello Buttonz";
  button.addEventListener("click", e => console.log(e));
  return button;
};

Button.story = {
  name: "button",
  parameters: {
    chromatic: { viewports: [VIEWPORT_SMALL, VIEWPORT_MEDIUM] }
  }
};

I would expect that the Button story only captured 2 viewports. However, 3 viewports were captured (the 3 from the default export).

I have confirmed that at least some of the chromatic parameters are being used by tossing { chromatic: { disable: true } } in the story (and the corresponding opposite of that in the default export) and seeing the story disappear.

@kylesuss kylesuss added the bug Classification: Something isn't working label Dec 20, 2019
@kylesuss
Copy link
Contributor Author

Closing this as I think this is actually happening on the Storybook side. I have done some investigation and it seems that storyStore.extract() is returning the 3 viewports. Therefore, we are just reading what Storybook sends.

@tmeasday
Copy link
Member

@kylesuss actually that code is not relevant to this problem -- that is explicitly not used for arrays, so shouldn't apply here:https://github.com/storybookjs/storybook/blob/9a6557ca77b0ace9538028e5f6bc9033e6350989/lib/client-api/src/client_api.ts#L249-L252

I wonder what is happening? If you have a sec, maybe try debugging through your example project.

@tmeasday
Copy link
Member

Oh.. or maybe it is used one level in. I take it back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Classification: Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants