reg-viz / storycap

A Storybook Addon, Save the screenshot image of your stories :camera: via puppeteer.
https://www.npmjs.com/package/storycap
MIT License
712 stars 89 forks source link

bug?: `viewports` overrides local `viewport` parameter #475

Open lacolaco opened 3 years ago

lacolaco commented 3 years ago

Component-local viewport parameter seems being overridden by global viewports parameter.

Use-case

I want to take screenshots with some common viewports and some stories have its own proper viewport specifically. I expected component-local or story-local parameters can override global one from preview.ts, but it didn't work as I imagined.

// preview.ts
export const paramters = {
  screenshot: {
    viewports: {
      small: { width: 599, height: 400 },
      large: { width: 960, height: 400 },
    },
  },
};
// comp.stories.ts

export default {
  ...,
  parameters: {
    screenshot: { viewport: { width: 960, height: 640 } },
  },
} as Meta;
lacolaco commented 3 years ago

{ viewports: [], viewport: { width: 960, height: 640 } } can override global viewports.

sag1v commented 2 years ago

I think its because you are not overriding the same key. In global you set viewports but locally you set viewport. I guess viewports has precedence over viewport