Skip to content

[NO-JIRA][BpkBadge] Render component README in Storybook Docs#4737

Open
Gert-Jan Vercauteren (gert-janvercauteren) wants to merge 4 commits into
mainfrom
gert-janvercauteren/readme-in-storybook
Open

[NO-JIRA][BpkBadge] Render component README in Storybook Docs#4737
Gert-Jan Vercauteren (gert-janvercauteren) wants to merge 4 commits into
mainfrom
gert-janvercauteren/readme-in-storybook

Conversation

@gert-janvercauteren

@gert-janvercauteren Gert-Jan Vercauteren (gert-janvercauteren) commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Adds the ability to render a component's `README.md` inside its Storybook Docs page, and wires it up for `BpkBadge` as the first example. A `webpackFinal` rule loads `.md` files as raw source strings (`asset/source`), a `*.md` TypeScript module declaration types the import, and the BpkBadge Docs page now renders Title → README → props table via the `<Title />` and `` blocks. The README is inlined into the static build, so it ships with `storybook:dist`. No runtime component behaviour changes.

Changes

  • Added `webpackFinal` rule in `main.ts` to load `.md` files as raw source strings, with explicit `module`/`rules` initialisation before pushing the rule
  • Added `*.md` TypeScript module declaration so `.md` imports are typed
  • Wired up `BpkBadge` Docs page to render `<Title />` → `{readme}` → ``

Remember to include the following changes:

  • Ensure the PR title includes the name of the component you are changing so it's clear in the release notes for consumers of the changes in the version e.g `[Clover-123][BpkButton] Updating the colour`
  • `README.md` (If you have created a new component)
  • Component `README.md`
  • Tests
  • Accessibility tests
    • The following checks were performed:
      • Ability to navigate using a keyboard only
      • Zoom functionality (Deque University explanation):
        • The page SHOULD be functional AND readable when only the text is magnified to 200% of its initial size
        • Pages must reflow as zoom increases up to 400% so that content continues to be presented in only one column i.e. Content MUST NOT require scrolling in two directions (both vertically and horizontally)
      • Ability to navigate using a screen reader only
  • Storybook examples created/updated
  • For breaking changes or deprecating components/properties, migration guides added to the description of the PR. If the guide has large changes, consider creating a new Markdown page inside the component's docs folder and link it here

🤖 Generated with Claude Code

Add a webpack rule to import Markdown files as raw source strings, plus
a TypeScript module declaration for `*.md`. Wire BpkBadge's Docs page to
render its README beneath the title via the <Markdown> block.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Visit https://backpack.github.io/storybook-prs/4737 to see this build running in a browser.

@skyscanner-backpack-bot

skyscanner-backpack-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor
Warnings
⚠️

Package source files (e.g. packages/package-name/src/Component.js) were updated, but snapshots weren't. Have you checked that the tests still pass?

Browser support

If this is a visual change, make sure you've tested it in multiple browsers.

Generated by 🚫 dangerJS against f2c7ecc

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds support for rendering component README.md content in Storybook Docs pages by loading Markdown files as raw strings in the Storybook webpack config, and wires the pattern into BpkBadge docs.

Changes:

  • Add a Storybook webpackFinal rule to load .md files as asset/source.
  • Add a TypeScript module declaration to type *.md imports as string.
  • Update BpkBadge Storybook docs page to render the component README via <Markdown> and show props via <ArgTypes>.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/backpack-web/src/bpk-component-badge/src/BpkBadge.stories.tsx Imports the component README and customizes the Docs page to render it plus the props table.
libs/backpack-storybook-host/.storybook/main.ts Adds a webpack rule to make .md importable as raw strings for Docs rendering.
@types/md.d.ts Declares *.md modules as string for TypeScript.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +328 to +337
parameters: {
docs: {
page: () => (
<>
<Markdown>{readme}</Markdown>
<ArgTypes exclude={['zoomEnabled']} />
</>
),
},
},
Comment on lines +38 to +46
webpackFinal: async (webpackConfig) => {
// Allow importing README.md (and other Markdown) files as raw source
// strings so they can be rendered in Docs pages via the <Markdown> block.
webpackConfig.module?.rules?.push({
test: /\.md$/,
type: 'asset/source',
});
return webpackConfig;
},

import type { ReactNode } from 'react';

import { ArgTypes, Markdown } from '@storybook/addon-docs/blocks';
Add a storybook-import step to the SupernovaPublish job so the built
Storybook is pushed to Supernova on release. Checkout, setup-node and a
Storybook build-cache restore are added since the job now needs the
dist-storybook files locally.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Visit https://backpack.github.io/storybook-prs/4737 to see this build running in a browser.

…k rule initialisation

- Add <Title /> before <Markdown> in BpkBadge docs.page so the Docs
  page renders Title → README → props table as described in the PR
- Initialise webpackConfig.module and .rules explicitly before pushing
  the .md rule, removing the silent no-op risk from optional chaining

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Visit https://backpack.github.io/storybook-prs/4737 to see this build running in a browser.

Avoid mutating the webpackConfig parameter directly; build the updated
config immutably and return it instead.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Visit https://backpack.github.io/storybook-prs/4737 to see this build running in a browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants