From 831a51770ab00fcffced194b33d6160012094491 Mon Sep 17 00:00:00 2001 From: Adam Kudrna Date: Tue, 31 Mar 2026 00:03:48 +0200 Subject: [PATCH 1/2] Fix `--docoff-preview-css` breaking CSS in PR preview deployments The property was set to an absolute path `/docs/_assets/generated/react-ui.development.css`, which resolves against the domain root and bypasses the PR preview subdirectory. A small setup script now derives the URL from the co-located `react-ui*.js` bundle so that previews always load the correct CSS for the deployed branch. --- mkdocs.yml | 4 ++++ src/docs/_assets/js/setupDocoff.js | 11 +++++++++++ src/docs/_assets/stylesheets/extra.css | 7 ++++++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/docs/_assets/js/setupDocoff.js diff --git a/mkdocs.yml b/mkdocs.yml index d62737084..0904be692 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -64,6 +64,10 @@ extra_javascript: - docs/_assets/js/ruiIcon.js - docs/_assets/js/ruiSwatch.js + # Workaround for https://github.com/react-ui-org/docoff/issues/50 — sets --docoff-preview-css + # dynamically so subdirectory deployments (e.g. PR previews) load the correct CSS bundle. + - docs/_assets/js/setupDocoff.js + # Then load and init Docoff - https://unpkg.com/@react-ui-org/docoff@0.5.4/public/generated/bundle.js diff --git a/src/docs/_assets/js/setupDocoff.js b/src/docs/_assets/js/setupDocoff.js new file mode 100644 index 000000000..96dc50454 --- /dev/null +++ b/src/docs/_assets/js/setupDocoff.js @@ -0,0 +1,11 @@ +// Derives --docoff-preview-css from the co-located react-ui bundle URL so that +// subdirectory deployments (e.g. PR previews) resolve the correct CSS file. +// Remove once https://github.com/react-ui-org/docoff/issues/50 is fixed. +(() => { + const script = [...document.querySelectorAll('script[src]')] + .find((s) => /react-ui(\.\w+)?\.js$/.test(s.src)); + + if (script) { + document.body.style.setProperty('--docoff-preview-css', script.src.replace(/\.js$/, '.css')); + } +})(); diff --git a/src/docs/_assets/stylesheets/extra.css b/src/docs/_assets/stylesheets/extra.css index c2d0460cc..fdbf3d63c 100644 --- a/src/docs/_assets/stylesheets/extra.css +++ b/src/docs/_assets/stylesheets/extra.css @@ -33,7 +33,12 @@ --docoff-preview-padding: 1em; /* Custom preview CSS file, typically this would be the CSS of your component */ - --docoff-preview-css: /docs/_assets/generated/react-ui.development.css; + + /* Commented out — an absolute path breaks subdirectory deployments (e.g. PR previews). + Set dynamically via docs/_assets/js/setupDocoff.js instead. + See https://github.com/react-ui-org/docoff/issues/50 for the upstream fix. */ + + /* --docoff-preview-css: /docs/_assets/generated/react-ui.development.css; */ /* Visual configuration of the `` element */ --docoff-placeholder-background-dark: #4d4d4d; From 7733c3b65187959f2ab5d4121dfaf1ea9a00c990 Mon Sep 17 00:00:00 2001 From: Adam Kudrna Date: Tue, 31 Mar 2026 00:03:53 +0200 Subject: [PATCH 2/2] Remove failing environment cleanup from PR preview workflow Deleting a GitHub environment requires admin-level repository access. The built-in `GITHUB_TOKEN` is a GitHub App installation token and cannot perform this operation regardless of the `deployments: write` permission granted to the workflow. The `rossjrw/pr-preview-action` step already handles all necessary cleanup on `gh-pages`. --- .github/workflows/pull-request-preview.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/workflows/pull-request-preview.yml b/.github/workflows/pull-request-preview.yml index 62681b459..5284bfc03 100644 --- a/.github/workflows/pull-request-preview.yml +++ b/.github/workflows/pull-request-preview.yml @@ -115,21 +115,3 @@ jobs: preview-branch: gh-pages umbrella-dir: pr-preview action: remove - - - name: Delete preview environment - env: - GH_TOKEN: ${{ github.token }} - run: | - set -e - ENV_NAME="pr-preview/pr-${{ github.event.pull_request.number }}" - ENCODED_ENV="${ENV_NAME//\//%2F}" - - gh api "repos/${{ github.repository }}/deployments" \ - -X GET -f environment="$ENV_NAME" --jq '.[].id' \ - | while IFS= read -r id; do - gh api "repos/${{ github.repository }}/deployments/$id/statuses" \ - -X POST -f state=inactive - gh api "repos/${{ github.repository }}/deployments/$id" -X DELETE - done - - gh api "repos/${{ github.repository }}/environments/$ENCODED_ENV" -X DELETE