Skip to content

Commit

Permalink
Migrate Storybook to Vite
Browse files Browse the repository at this point in the history
  • Loading branch information
darekkay committed May 24, 2024
1 parent e4dbb98 commit c0c4b5f
Show file tree
Hide file tree
Showing 10 changed files with 7,742 additions and 12,516 deletions.
4 changes: 1 addition & 3 deletions .idea/runConfigurations/_storybook__start.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion app/src/components/modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import Icon from "components/icon";

if (!IS_TEST) {
// bind modal to the root app element
ReactModal.setAppElement("#root");
if (document.querySelector("#storybook-root")) {
ReactModal.setAppElement("#storybook-root");
} else {
ReactModal.setAppElement("#root");
}
} else {
// create a mock modal root
const modalRoot = document.createElement("div");
Expand Down
5 changes: 0 additions & 5 deletions storybook/.ncurc.yml

This file was deleted.

66 changes: 0 additions & 66 deletions storybook/.storybook/main.js

This file was deleted.

51 changes: 51 additions & 0 deletions storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// @ts-nocheck

import { resolve } from "path";

/** @type {import("@storybook/core-common").StorybookConfig} */
export default {
core: {
disableTelemetry: true,
},
stories: ["../../app/src/**/__stories__/*.stories.tsx"],

addons: ["storybook-addon-themes"],

staticDirs: ["../../app/public", "./assets"],

features: {
postcss: false,
},

typescript: {
// https://github.com/storybookjs/storybook/issues/12585
check: false,
reactDocgen: false,
},

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

async viteFinal(config, { configType }) {
config.resolve = {
alias: config.resolve.alias.concat(
[
"api",
"common",
"components",
"entry",
"state",
"styles",
"templates",
"widgets",
].map((folder) => ({
find: RegExp(`^${folder}`),
replacement: resolve(__dirname, `../../app/src/${folder}`),
}))
),
};
return config;
},
};
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
// @ts-nocheck

import { addDecorator, addParameters } from "@storybook/react";

import initStore from "state/store";
import "common/i18n";
import initStore from "../../app/src/state/store";
import "../../app/src/common/i18n";

import "../../app/src/styles/index.scss";

// TODO: check if required, causes issues with vite-storybook
// import "../src/styles/index.scss";
import "./storybook.scss";

initStore();

// Define UI themes
addParameters({
export const parameters = {
themes: {
default: "Default",
list: [
Expand All @@ -32,4 +37,4 @@ addParameters({
theme?.class.substring(6) || "default";
},
},
});
};
Loading

0 comments on commit c0c4b5f

Please sign in to comment.