Skip to content

Commit

Permalink
Merge pull request #1966 from navikt/test-storybook
Browse files Browse the repository at this point in the history
Storybook 🧪
  • Loading branch information
bdahle authored Aug 23, 2024
2 parents 61e8f0e + 5267194 commit a32f180
Show file tree
Hide file tree
Showing 155 changed files with 19,094 additions and 11,046 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"plugins": ["css-modules", "no-relative-import-paths"],
"extends": ["next/core-web-vitals", "plugin:css-modules/recommended"],
"extends": [
"next/core-web-vitals",
"plugin:css-modules/recommended",
"plugin:storybook/recommended"
],
"ignorePatterns": ["next.config.js"],
"rules": {
"@next/next/no-img-element": 0,
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

# testing
/coverage
*storybook.log
/storybook-static

# next.js
/.next/
Expand Down
49 changes: 49 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import path, { dirname, join } from 'path';
import type { StorybookConfig } from '@storybook/nextjs';

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],

addons: [
getAbsolutePath('@storybook/addon-onboarding'),
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('@chromatic-com/storybook'),
getAbsolutePath('@storybook/addon-interactions'),
getAbsolutePath('@storybook/addon-mdx-gfm'),
getAbsolutePath('@storybook/addon-storysource'),
],

framework: {
name: getAbsolutePath('@storybook/nextjs'),
options: {},
},

webpackFinal: async (config) => {
const updatedConfig = {
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve?.alias,
common: path.resolve(__dirname, '../src/common.scss'),
},
},
};

return updatedConfig;
},

staticDirs: ['../public'],

docs: {},

typescript: {
reactDocgen: 'react-docgen-typescript',
},
};
export default config;

function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, 'package.json')));
}
11 changes: 11 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Preview } from '@storybook/react';
import '../src/global.scss';

const preview: Preview = {
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
};

export default preview;
Loading

0 comments on commit a32f180

Please sign in to comment.