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 viewports not overriding global viewports #895

Open
stackdiver opened this issue Aug 26, 2024 · 0 comments
Open

Story viewports not overriding global viewports #895

stackdiver opened this issue Aug 26, 2024 · 0 comments

Comments

@stackdiver
Copy link

I'm a bit confused about the viewports option. Especially when it comes to overriding the global setting.

In our Storybook preview.tsx, we define the following viewports for screenshots:

screenshot: {
  viewports: {
    laptop: {
      width: 1920,
      height: 1080,
    },
    tablet: 'iPad',
    phone: {
      width: 360,
      height: 1054,
    },
  },
},

Then in some particular stories that should only be captured for mobile devices (tablet and phone), we override the viewports in the story params:

export const OnlyMobileStory: Story = {
  play: async ({ canvasElement }) => {
    await selectCar(canvasElement)
    await selectAmount(canvasElement)
    await selectAccount(canvasElement)
    await clickConfirm(canvasElement)
  },
  parameters: {
    screenshot: {
      viewports: {
        tablet: 'iPad',
        phone: {
          width: 360,
          height: 1054,
        },
      },
    },
  },
}

The problem is, that the laptop image is still generated.

I played around a little bit and found, that "resetting" the viewports for all stories in that file helps:

const meta: Meta = {
  ...
  parameters: {
    screenshot: {
      viewports: [],
    },
  },
}
export default meta

But then I have to specify the viewports again in every single story.
Any ideas? Possible bug?

Due to some internal infrastructure limitations, we still use Storybook 7.6.19 together with Storycap 4.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@stackdiver and others