Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Add a composed Storybook (#529)

Mateusz Burzyński3794f9a4978b
diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml
index 52d8f560ff..a6b1de9b86 100644
--- a/.github/workflows/chromatic.yml
+++ b/.github/workflows/chromatic.yml
@@ -37,6 +37,14 @@ jobs:
chromaticSecretKey: CHROMATIC_REACT_SDK_TOKEN
workingDir: packages/react-sdk
+ outputs:
+ designer-app: ${{ steps.deployed-url.outputs.designer-app }}
+ css-engine: ${{ steps.deployed-url.outputs.css-engine }}
+ design-system: ${{ steps.deployed-url.outputs.design-system }}
+ icons: ${{ steps.deployed-url.outputs.icons }}
+ image: ${{ steps.deployed-url.outputs.image }}
+ react-sdk: ${{ steps.deployed-url.outputs.react-sdk }}
+
steps:
- uses: actions/checkout@v3
with:
@@ -48,7 +56,34 @@ jobs:
- run: yarn build --filter='!./apps/*'
- name: Chromatic
+ id: chromatic
uses: chromaui/action@v1
with:
projectToken: ${{ secrets[matrix.chromaticSecretKey] }}
workingDir: ${{ matrix.workingDir }}
+
+ - name: Save deployed URL
+ id: deployed-url
+ run: echo "${{ matrix.project }}=${{ steps.chromatic.outputs.storybookUrl }}" >> $GITHUB_OUTPUT
+
+ chromatic-root:
+ timeout-minutes: 20
+
+ needs: chromatic
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 2 # we need to fetch at least parent commit to satisfy Chromatic
+
+ - uses: ./.github/actions/ci-setup
+
+ - name: Chromatic
+ id: chromatic
+ uses: chromaui/action@v1
+ with:
+ projectToken: ${{ secrets.CHROMATIC_ROOT }}
+ env:
+ DEPLOYED_URLS: ${{ toJSON(needs.chromatic.outputs) }}
diff --git a/.storybook/main.js b/.storybook/main.js
new file mode 100644
index 0000000000..8ae717ba24
--- /dev/null
+++ b/.storybook/main.js
@@ -0,0 +1,19 @@
+if (!process.env.DEPLOYED_URLS) {
+ throw new Error("process.env.DEPLOYED_URLS is not set");
+}
+
+const urls = JSON.parse(process.env.DEPLOYED_URLS);
+
+module.exports = {
+ // at least one story is required: https://github.com/storybookjs/storybook/issues/12705
+ stories: ["./whole-repo.stories.js"],
+ refs: Object.fromEntries(
+ Object.entries(urls).map(([key, url]) => [
+ key,
+ { title: key, url, expanded: false },
+ ])
+ ),
+ features: {
+ storyStoreV7: true,
+ },
+};
diff --git a/.storybook/whole-repo.stories.js b/.storybook/whole-repo.stories.js
new file mode 100644
index 0000000000..05f30c0822
--- /dev/null
+++ b/.storybook/whole-repo.stories.js
@@ -0,0 +1,12 @@
+import React from "react";
+
+export default {
+ title: "Webstudio Designer Repository",
+};
+
+export const Welcome = () => (
+ <>
+ <p>Welcome to the Webstudio Designer Repository</p>
+ <p>You can browse all of our storybooks here.</p>
+ </>
+);
diff --git a/package.json b/package.json
index 0a926d8e17..f3f07238dc 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,7 @@
"dev": "turbo run dev --parallel",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"prepare": "husky install",
+ "build-storybook": "build-storybook",
"storybook": "turbo run storybook:run",
"storybook:build": "npm run build && turbo run storybook:build",
"storybook:ds:build": "turbo run storybook:build --filter=@webstudio-is/design-system",
@@ -23,6 +24,7 @@
"devDependencies": {
"@changesets/get-dependents-graph": "^1.3.4",
"@manypkg/get-packages": "^1.1.3",
+ "@storybook/react": "^6.5.9",
"@webstudio-is/eslint-config-custom": "*",
"chromatic": "^6.11.4",
"golden-fleece": "^1.0.9",