refactor(docs,storybook): adopt the layer-docs Storybook bridge (UXF-278) - #337
Open
alexgrozav wants to merge 2 commits into
Open
alexgrozav wants to merge 2 commits into
alexgrozav wants to merge 2 commits into
Conversation
…er one (UXF-278) `apps/storybook` hand-rolled both halves of the docs-embed postMessage contract — theme relay, height measurement, chrome accounting. The docs side of that contract now ships in `@uxfront/layer-docs/storybook`, so the local copy is a fork that can only drift. `legacyNamespace: "styleframe"` keeps the existing `styleframe:*` message names alive alongside the neutral ones, so this deploys before the docs rewrite without breaking the embeds already in production. The layer is framework-free on this subpath and adds no new packages to the store — only peer-resolution snapshots of packages the workspace already installs.
`StoryPreview` was the docs half of a postMessage contract `apps/storybook` implemented on the other side. `StorybookEmbed` in `@uxfront/layer-docs` is that same component, maintained once for every consumer, so the local one is deleted rather than kept in parallel. `panel` becomes `mode`, which names the Storybook surface instead of describing one of two. The mapping preserves today's rendering exactly: `panel: true` was the manager with its addon panel (`mode: panel`), and both `panel: false` and an absent `panel` built the manager's `full=1` URL (`mode: full`). The 92 blocks that relied on that default now say so. `mode: preview` — the layer's own default, embedding `iframe.html` with no Storybook chrome — is a lighter surface than `full` and worth a look, but changing 92 embeds is a design decision, not a rename. The reserved heights are unchanged (320 for `full`, 600 for `panel`), so the embeds still reserve their space before Storybook reports a real one.
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
apps/docsandapps/storybookeach held one half of a hand-rolledpostMessagecontract — theme sync, height measurement, manager chrome accounting. Both halves now ship in@uxfront/layer-docs0.4.1, whichapps/docsalready depends on since #335. This replaces the local copies with the shared ones.Two commits, in the order they can be deployed:
1.
apps/storybook— the bridge..storybook/preview.tsand.storybook/manager.tscallinstallDocsEmbedPreviewBridge/installDocsEmbedManagerBridge. The addon-specific work (the@vueless/storybook-dark-modechannel, thesb-addon-themes-3store,addons.setConfig) stays local, reached through the bridges'onThemecallback.legacyNamespace: "styleframe"keeps the existingstyleframe:*message names alive alongside the neutral ones, so this deploys before the docs side without breaking the embeds already in production.2.
apps/docs— the content.StoryPreview.vueis deleted; 385::story-previewblocks across 65 files become::storybook-embed.storybookBaseUrlandstorybookLegacyMessageNamespaceare set inruntimeConfig.public.The
panel→modemappingmodenames the Storybook surface rather than describing one of two, so the rename is not one-to-one. The mapping preserves today's rendering exactly:panel: true(292)mode: panelpanel: false(1)mode: fullfull=1panel(92)mode: fullfull=1— the old default, now explicitReserved heights are unchanged (320 for
full, 600 forpanel), so the embeds still hold their space before Storybook reports a real one.mode: preview— the layer's own default, embeddingiframe.htmlwith no Storybook chrome — is a lighter surface thanfulland worth considering for the 92. It is a design decision rather than a rename, so it is left out of this PR.Dependency note
@uxfront/layer-docsis added toapps/storybookas a devDependency for the framework-free/storybooksubpath. It adds no new packages to the store — the lockfile grows by 42 peer-resolution snapshots of packages the workspace already installs.StoryPreview.vuehardcodedimport.meta.dev ? http://localhost:6006 : <deployed>.StorybookEmbedreadsstorybookBaseUrlfromruntimeConfig.publicinstead, which points at the deployed Storybook in every environment. Local development against a local Storybook now needs an explicit override:apps/docs/.env.examplecarries this line. A contributor with an existingapps/docs/.envdoes not get it automatically: their embeds silently load the deployed Storybook instead of their local one. Copy the line into your.envafter you pull this change.Related issue
Relates to UXF-278. Follows #335, which had to land first because both touch
apps/docs.Type of change
Checklist
feat(theme): …)pnpm build:nodocs && pnpm lint && pnpm typecheck && pnpm testand everything passespnpm changeset) for changes to publishable packages, or this change only touches docs/storybook/app/playground/testsdist/,.styleframe/)mainand stays focused in scopeNotes on the checklist: no changeset — this touches only
apps/docsandapps/storybook, matching #335. No new tests — the rewrite adds no behaviour, and the bridge's own logic is tested in the layer (storybook/index.test.ts,app/utils/storybookEmbed.test.ts).apps/docs/AGENTS.mdis updated with the new block syntax and what eachmodemeans. Repo-widepnpm lintran out of memory in my environment;oxlinton the changed files andpnpm format:checkacross all 1826 files both pass.Notes / screenshots
Verified in a browser against
apps/storybookon:6006andapps/docson:3000, on/docs/theme/components/button(12 embeds, both modes). Console: 0 errors.mode: panelbuilds the panel URL,mode: fullappendsfull=1. No.story-previewleft in the DOM.fullall-variants embed from 320px to 886px. That signal crosses preview → manager → docs page, so it exercises both new bridges end to end.legacyNamespace.Storybook preview: theme recipes actions button default); the oldStoryPreviewleft the frame unlabelled for screen readers.Both builds pass:
pnpm --filter @styleframe/storybook buildandpnpm --filter @styleframe/docs build.Screenshots (panel embed light/dark, and a
full-mode embed) are attached to the issue thread.