Skip to content

Commit

Permalink
Merge pull request #37 from club-40/feat/storybook
Browse files Browse the repository at this point in the history
feat: add storybook
  • Loading branch information
fcasibu authored May 20, 2023
2 parents 44853c3 + c9c3ec5 commit 3a760c9
Show file tree
Hide file tree
Showing 12 changed files with 14,150 additions and 2,676 deletions.
12 changes: 12 additions & 0 deletions frontend/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
"import/extensions": "off",
"import/no-unresolved": "off",

// disable React module needing to be in scope for jsx, no idea why react-jsx is not working in tsconfig
"react/react-in-jsx-scope": "off",

// disable warning of dev dependencies added by storybook needing to be in dependencies
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": ["**/*.stories.*", "**/.storybook/**/*.*"],
"peerDependencies": true
}
],

// additional ts settings for strictness
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/consistent-type-imports": "error",
Expand Down
23 changes: 23 additions & 0 deletions frontend/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { StorybookConfig } from "@storybook/react-vite";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx|mdx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/addon-styling",
"@storybook/addon-a11y",
],
framework: {
name: "@storybook/react-vite",
options: {},
},
core: {
disableTelemetry: true,
},
docs: {
autodocs: "tag",
},
};
export default config;
71 changes: 71 additions & 0 deletions frontend/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from "react";
import type { Decorator, Preview } from "@storybook/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import "../src/index.css";

const viewports = {
small: {
name: "Small",
styles: {
width: "390px",
height: "844px",
},
},
medium: {
name: "Medium",
styles: {
width: "768px",
height: "1024px",
},
},
large: {
name: "Large",
styles: {
width: "1512px",
height: "982px",
},
},
};

const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
refetchIntervalInBackground: false,
retry: false,
cacheTime: 0,
},
},
});

const decorators: Decorator[] = [
(Story) => {
// Extend if we're going to have more providers
return (
<QueryClientProvider client={queryClient}>
<Story />
</QueryClientProvider>
);
},
];

const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
options: {
storySort: {
order: ["Introduction", "Design", "Components"],
},
},
viewport: { viewports, defaultViewport: "small" },
},
decorators,
};

export default preview;
Loading

0 comments on commit 3a760c9

Please sign in to comment.