Storybook responsive fix

This commit is contained in:
adilallo
2025-08-11 13:54:54 -06:00
parent 4ef658a355
commit 79ae558b60
21 changed files with 5371 additions and 159 deletions
+32
View File
@@ -0,0 +1,32 @@
/** @type { import('@storybook/nextjs-vite').StorybookConfig } */
const config = {
stories: [
"../stories/**/*.mdx",
"../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",
],
addons: [
"@chromatic-com/storybook",
"@storybook/addon-docs",
"@storybook/addon-onboarding",
"@storybook/addon-a11y",
"@storybook/addon-vitest",
"@storybook/addon-viewport",
],
framework: {
name: "@storybook/nextjs-vite",
options: {},
},
staticDirs: ["../public"],
async viteFinal(cfg) {
// Ensure esbuild treats .js as JSX during dep pre-bundling
cfg.optimizeDeps ??= {};
cfg.optimizeDeps.esbuildOptions ??= {};
cfg.optimizeDeps.esbuildOptions.loader = {
...(cfg.optimizeDeps.esbuildOptions.loader || {}),
".js": "jsx",
".ts": "tsx",
};
return cfg;
},
};
export default config;
+63
View File
@@ -0,0 +1,63 @@
import "../app/globals.css";
/** @type { import('@storybook/nextjs-vite').Preview } */
const preview = {
parameters: {
nextjs: { appDirectory: true },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
a11y: {
// 'todo' - show a11y violations in the test UI only
// 'error' - fail CI on a11y violations
// 'off' - skip a11y checks entirely
test: "todo",
},
backgrounds: {
default: "dark",
values: [
{
name: "dark",
value: "#000000",
},
{
name: "light",
value: "#ffffff",
},
],
},
viewport: {
defaultViewport: "md",
viewports: {
xsm: {
name: "XSmall (≤429px)",
styles: { width: "429px", height: "800px" },
},
sm: {
name: "Small (≥430px)",
styles: { width: "430px", height: "800px" },
},
md: {
name: "Medium (≥640px)",
styles: { width: "640px", height: "800px" },
},
lg: {
name: "Large (≥1024px)",
styles: { width: "1024px", height: "800px" },
},
xl: {
name: "XLarge (≥1440px)",
styles: { width: "1440px", height: "900px" },
},
},
},
},
};
export default preview;
+7
View File
@@ -0,0 +1,7 @@
import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
import { setProjectAnnotations } from '@storybook/nextjs-vite';
import * as projectAnnotations from './preview';
// This is an important step to apply the right configuration when testing your stories.
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);