Skip to content

Commit

Permalink
Merge pull request #1455 from danskernesdigitalebibliotek/feature/upd…
Browse files Browse the repository at this point in the history
…ate-storybook

Feature/update storybook
  • Loading branch information
ThomasGross authored Oct 7, 2024
2 parents 2dc6b5b + 8c2cd7c commit 2f9ddf6
Show file tree
Hide file tree
Showing 136 changed files with 7,848 additions and 11,611 deletions.
Binary file added .DS_Store
Binary file not shown.
30 changes: 0 additions & 30 deletions .storybook/main.js

This file was deleted.

32 changes: 32 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const config = {
stories: ["../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],

addons: [
"@storybook/addon-essentials",
"@storybook/addon-queryparams",
"@storybook/addon-webpack5-compiler-babel",
"@chromatic-com/storybook"
],

typescript: {
check: true,
checkOptions: {},
reactDocgen: "react-docgen-typescript",
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
propFilter: (prop) =>
prop.parent ? !/node_modules/.test(prop.parent.fileName) : true
}
},

framework: {
name: "@storybook/react-webpack5",
options: {}
},

docs: {
autodocs: "tag"
}
};

export default config;
40 changes: 26 additions & 14 deletions .storybook/preview.js → .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { Preview } from "@storybook/react";
import "../src/components/components.scss";
import "@danskernesdigitalebibliotek/dpl-design-system/build/css/base.css";
import { setToken, TOKEN_LIBRARY_KEY, TOKEN_USER_KEY } from "../src/core/token";
import "../src/core/mount";
import Store from "../src/components/store";
import React from "react";
import { withErrorBoundary } from "react-error-boundary";
import ErrorBoundaryAlert from "../src/components/error-boundary-alert/ErrorBoundaryAlert";
import Store from "../src/components/store";


const getSessionStorage = (type) => window.sessionStorage.getItem(type);
const userToken =
Expand Down Expand Up @@ -40,18 +42,28 @@ const WrappedStory = (app) =>
}
});

const App = ({ story }) => <Store>{WrappedStory(story)}</Store>;

// Consideration for the future - using addon-redux could bring value.
// It wasn't implemented to begin with because it wasn't compatible with Storybook 6.
export const decorators = [
(Story) => (
<>
<App story={Story} />
</>
)
];
function App({ story }) {
return (
<Store>
<>{story}</>
</Store>
);
}

export const parameters = {
layout: "fullscreen"
const preview: Preview = {
parameters: {
layout: "fullscreen",
controls: {
expanded: true
}
},
decorators: [
(Story) => (
<>
<App story={Story()} />
</>
)
]
};

export default preview;
18 changes: 18 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const { defineConfig } = require("cypress");

module.exports = defineConfig({
projectId: "4trcdv",
defaultCommandTimeout: 10000,
pageLoadTimeout: 10000,
requestTimeout: 30000,
testFiles: "@(apps|components)/**/*.test.@(ts|tsx)",
integrationFolder: "./src",
retries: {
runMode: 3,
openMode: 0
},
e2e: {
baseUrl: "http://localhost:57021"
}
});
11 changes: 0 additions & 11 deletions cypress.json

This file was deleted.

2 changes: 1 addition & 1 deletion cypress/fixtures/search-result/campaign-image-only.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"url": "https://picsum.photos/id/777/300/200",
"alt": "I am a campaign image."
},
"url": "http://localhost/?path=/story/apps-search-result--search-result"
"url": "http://localhost/?path=/story/apps-search-result--primary"
}
}
2 changes: 1 addition & 1 deletion cypress/fixtures/search-result/campaign-text-only.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"url": null,
"alt": null
},
"url": "http://localhost/?path=/story/apps-search-result--search-result"
"url": "http://localhost/?path=/story/apps-search-result--primary"
}
}
2 changes: 1 addition & 1 deletion cypress/fixtures/search-result/campaign.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"url": "https://picsum.photos/id/777/300/200",
"alt": "I am a campaign image."
},
"url": "http://localhost/?path=/story/apps-search-result--search-result"
"url": "http://localhost/?path=/story/apps-search-result--primary"
}
}
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"watch:css": "postcss ./src/apps/**/*.scss ./src/components/components.scss --ext css --dir ./dist --watch",
"watch:lint:scss": "chokidar \"./src/**/*.scss\" -c \"yarn lint:scss:fix\"",
"watch:lint:js": "chokidar \"./src/**/*.{js,jsx,ts,tsx}\" -c \"yarn lint:js\"",
"build:storybook": "build-storybook -c .storybook -o dev",
"start:storybook:test": "NODE_ENV=test start-storybook --port 57021 --quiet --ci",
"start:storybook:dev": "NODE_ENV=development start-storybook --port 80",
"build:storybook": "storybook build -c .storybook -o dev",
"start:storybook:test": "NODE_ENV=test storybook dev --port 57021 --quiet --ci",
"start:storybook:dev": "NODE_ENV=development storybook dev --port 80",
"dev": "npx concurrently --raw \"yarn start:storybook:dev\" \"yarn watch\"",
"test:unit": "vitest",
"test:integration": "cypress run",
Expand All @@ -48,6 +48,7 @@
"@babel/core": "^7.25.7",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@chromatic-com/storybook": "^1",
"@babel/preset-env": "^7.25.7",
"@babel/preset-react": "^7.25.7",
"@babel/preset-typescript": "^7.25.7",
Expand All @@ -64,13 +65,11 @@
"@graphql-typed-document-node/core": "^3.1.1",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@namics/stylelint-bem": "^10.0.1",
"@storybook/addon-essentials": "^6.5.10",
"@storybook/addon-postcss": "^2.0.0",
"@storybook/addon-queryparams": "^6.2.9",
"@storybook/builder-webpack5": "^6.5.0-beta.7",
"@storybook/manager-webpack5": "^6.5.0-beta.7",
"@storybook/preset-typescript": "^3.0.0",
"@storybook/react": "^6.5.0-beta.7",
"@storybook/addon-essentials": "^8.2.9",
"@storybook/addon-queryparams": "^7.0.1",
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
"@storybook/react": "^8.2.9",
"@storybook/react-webpack5": "^8.2.9",
"@testing-library/dom": "^9.3.4",
"@testing-library/react": "^14.2.2",
"@testing-library/react-hooks": "^8.0.1",
Expand Down Expand Up @@ -125,6 +124,7 @@
"replace-in-file": "^6.3.2",
"sass": "^1.79.4",
"source-map-support": "^0.5.21",
"storybook": "^8.2.9",
"style-loader": "^4.0.0",
"stylelint": "^15.11.0",
"stylelint-config-prettier": "^9.0.5",
Expand Down
Binary file added src/apps/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import type { Meta, StoryFn } from "@storybook/react";
import React from "react";
import LibraryToken from "./library-token";

export default {
title: "SB Utilities / Set Library Token",
component: LibraryToken
} as ComponentMeta<typeof LibraryToken>;
} as Meta<typeof LibraryToken>;

export const LibraryTokenApp: ComponentStory<typeof LibraryToken> = () => {
export const LibraryTokenApp: StoryFn<typeof LibraryToken> = () => {
return <LibraryToken />;
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import type { Meta, StoryFn } from "@storybook/react";
import React from "react";
import UserToken from "./user-token";

export default {
title: "SB Utilities / Set User Token",
component: UserToken
} as ComponentMeta<typeof UserToken>;
} as Meta<typeof UserToken>;

export const UserTokenApp: ComponentStory<typeof UserToken> = () => {
export const UserTokenApp: StoryFn<typeof UserToken> = () => {
return <UserToken />;
};
Loading

0 comments on commit 2f9ddf6

Please sign in to comment.