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

Feature/dropdown #7

Merged
merged 8 commits into from
Jan 19, 2024
2 changes: 2 additions & 0 deletions .storybook/preview.ts → .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Preview } from "@storybook/react";
import * as React from "react";

const preview: Preview = {
parameters: {
Expand All @@ -9,6 +10,7 @@ const preview: Preview = {
date: /Date$/i,
},
},
layout: "fullscreen",
},
};

Expand Down
27 changes: 27 additions & 0 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { getStoryContext } = require("@storybook/test-runner");
const { MINIMAL_VIEWPORTS } = require("@storybook/addon-viewport");

const DEFAULT_VP_SIZE = { width: 1280, height: 720 };

module.exports = {
/**
* This makes sure the test runner respects the viewport.
* @see {@link https://github.com/storybookjs/test-runner/issues/85#issuecomment-1576465128|[Bug] Tests always run in the default viewport}
* @param page
* @param story
*/
async preRender(page, story) {
const context = await getStoryContext(page, story);
const vpName =
context.parameters?.viewport?.defaultViewport ?? "responsive";
const vpParams = MINIMAL_VIEWPORTS[vpName];

if (vpParams) {
const width = parseInt(vpParams.styles.width);
const height = parseInt(vpParams.styles.height);
page.setViewportSize({ width, height });
} else {
page.setViewportSize(DEFAULT_VP_SIZE);
}
},
};
Loading