Skip to content

docs: inline story examples so Show code shows real markup - #88

Draft
aresnik11 wants to merge 1 commit into
mainfrom
ajr-sb-show-code
Draft

aresnik11 wants to merge 1 commit into
mainfrom
ajr-sb-show-code

Conversation

@aresnik11

@aresnik11 aresnik11 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Many stories rendered an example component defined in the stories file (<PopoverExample />, <ExpandableButtonClickRow />, <PlainConnectedFields />, and so on). For those stories, Show code displayed only that component's name, so readers never saw the Gamut markup they came to copy. This PR inlines those examples, following the pattern Dialog already uses.

How Show code picks its source

  • A render that takes args gets a dynamic snippet built from the JSX it returns.
  • A render that takes no args shows the story's code as written in the file.
  • Either way, a local component like <FooExample /> shows up as a single tag and hides everything inside it.

What replaced the example components

  • Named render functions (render: function ControlledPagination(args) {...}) where a story needs hook state. The markup is inline in the render.
  • A shared meta.render where most stories render the same thing. Each story sets only its own args. Used in Popover (PopoverWithTrigger) and ConnectedForm (the four-field form behind the behavior stories).
  • A shared render const where only some of a file's stories share markup: renderLocalQueryTable in DataTable, and renderExpandableRows in ListRow, where a clickableRows arg switches between ExpandControl and a clickable row with a chevron.
  • Decorators for layout-only wrappers: Popover centering and scroll container, PreviewTip centering, Disclosure's primary background, ListCol's width container.
  • Plain JSX helpers in args where the same placeholder is used several times (Modal's gridContentPlaceholder('300px') and codeCelebrationImage). These are functions and constants, not components, so the dynamic snippet shows the FlexBox/Box markup instead of a component name.

Files

  • Anchor, Checkbox, Radio, Pagination, Disclosure, PreviewTip, Popover, Modal
  • SelectDropdown: 7 renders that defined a component inline and returned it now hold the hooks themselves (NoOptionsAnnouncement, GroupedIcons, MultipleSelectControlled, Creatable, CreatableMultiUncontrolled, CreatableMulti, CreatableWithValidation).
  • List, ListCol, ListRow
  • DataList, DataTable, and DataList/testUtils.tsx (removed createDemoTable and DisableContainerQueryExample, which nothing else used).
  • ConnectedForm

Left alone on purpose

  • DatePicker's ComposedDatePickerLayout and the ConnectedFormInputs helpers need context from a provider or hook.
  • DataTable's RowMenu is a cell renderer passed to a column, not story markup.
  • ButtonScale is a matrix built in a loop.
  • Tabs' ThreeTabs is the story's render itself (render: ThreeTabs), so Show code already shows its code.
  • Icon galleries.

Known limitations / notes for reviewers

  • Popover's BeakCentered no longer sets p={0}, so it now gets the same 16px padding as the other Popover stories.
  • ExpandableButton and ExpandableClickableRow show a clickableRows control in the Controls panel. It's a story-only arg, removed before props reach List.
  • Any new ConnectedForm story without a render gets the four-field form from meta.render.
  • OnChangeValidation keeps its own render, because its submit button disables itself when the form is invalid. Putting that in the shared render would disable the button in the stories that click submit with empty fields to trigger errors.
  • ListRow's expandable rows now keep one expandedNames array in the story instead of a useState per row. Several rows can still be open at once.
  • The Modal "cycle in arg views" warning in test output was already there before this change.
  • The story tests for all 15 changed files pass (221 tests).

PR Checklist

  • Related to designs:
  • Related to JIRA ticket: GMT-173
  • Changeset added (or empty changeset if no release)
  • I have run this code to verify it works
  • This PR includes unit tests for the code change
  • This PR includes testing instructions tests for the code change
  • Package previews from this PR are passing end-to-end tests in all relevant consuming repositories

Testing Instructions

  1. Open Storybook and go to any of the changed stories, for example Overlays/Popover, Overlays/Modal → Large, Data display/List/ListRow → Expandable Button, Inputs & forms/ConnectedForm/ConnectedForm → Validation Errors, Data display/DataTable → Local Sorting, Inputs & forms/SelectDropdown → Creatable.
  2. On the Docs page, click Show code under each story. It should show the real Gamut components (Popover, ListRow/ListCol, ConnectedFormGroup, DataTable), not a local *Example/*Template component.
  3. Check that each story still renders and behaves as before: popovers open, rows expand, forms validate and submit.
  4. Run yarn test:stories and confirm the story tests pass.

PR Links and Envs

Repository PR Link
N/A Storybook-only change

🤖 Generated with Claude Code

Replace example components in stories with inline renders, shared
meta renders, args, and decorators.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Nov 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

@skillsoft/eslint-plugin-gamut

npm i https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/eslint-plugin-gamut@88
yarn add https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/eslint-plugin-gamut@88.tgz

@skillsoft/gamut

npm i https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut@88
yarn add https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut@88.tgz

@skillsoft/gamut-agent-tools

npm i https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-agent-tools@88
yarn add https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-agent-tools@88.tgz

@skillsoft/gamut-codemods

npm i https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-codemods@88
yarn add https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-codemods@88.tgz

@skillsoft/gamut-icons

npm i https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-icons@88
yarn add https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-icons@88.tgz

@skillsoft/gamut-illustrations

npm i https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-illustrations@88
yarn add https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-illustrations@88.tgz

@skillsoft/gamut-patterns

npm i https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-patterns@88
yarn add https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-patterns@88.tgz

@skillsoft/gamut-styles

npm i https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-styles@88
yarn add https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-styles@88.tgz

@skillsoft/gamut-tests

npm i https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-tests@88
yarn add https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/gamut-tests@88.tgz

@skillsoft/variance

npm i https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/variance@88
yarn add https://pkg.pr.new/Codecademy/skillsoft-gamut/@skillsoft/variance@88.tgz

commit: bf79f4c

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the Storybook updates that expose component markup in Show code.

No open issues 🎉

What changed in this PR

This PR updates Gamut’s Storybook examples so Show code exposes component markup instead of local example-component tags. Changes are limited to stories, supporting utilities, and an empty changeset.

Changes:

  • Inline example markup and move hook state into named render functions.
  • Share renders where appropriate and move layout-only wrappers into decorators.
  • Replace Modal placeholder components with JSX helpers and remove unused story utilities.
File Description
packages/​gamut/​src/​Tips/​PreviewTip/​PreviewTip.stories.tsx Inline examples and extract a centering decorator.
packages/​gamut/​src/​Popover/​Popover.stories.tsx Share trigger markup through meta.render and use layout decorators.
packages/​gamut/​src/​Pagination/​Pagination.stories.tsx Inline the controlled pagination example.
packages/​gamut/​src/​Modals/​Modal.stories.tsx Replace placeholder components with JSX helpers.
packages/​gamut/​src/​List/​ListRow.stories.tsx Inline expandable rows and share expansion state logic.
packages/​gamut/​src/​List/​ListCol.stories.tsx Inline scrolling rows and decorate the constrained-width example.
packages/​gamut/​src/​List/​List.stories.tsx Inline scroll-update and container-query examples.
packages/​gamut/​src/​Form/​inputs/​SelectDropdown/​SelectDropdown.stories.tsx Move hooks and markup into seven named renders.
packages/​gamut/​src/​Form/​inputs/​Radio/​Radio.stories.tsx Inline the controlled radio-group example.
packages/​gamut/​src/​Form/​inputs/​Checkbox/​Checkbox.stories.tsx Inline controlled and nested checkbox examples.
packages/​gamut/​src/​Disclosure/​Disclosure.stories.tsx Replace background wrappers with a decorator and story args.
packages/​gamut/​src/​DataList/​testUtils.tsx Remove the replaced table factory and container-query helper.
packages/​gamut/​src/​DataList/​DataTable.stories.tsx Share the local-query render and inline container-query markup.
packages/​gamut/​src/​DataList/​DataList.stories.tsx Inline the full interactive list and container-query examples.
packages/​gamut/​src/​ConnectedForm/​ConnectedForm.stories.tsx Share four-field form markup and inline specialized examples.
packages/​gamut/​src/​Anchor/​Anchor.stories.tsx Inline the variants grid and reuse its render for icon variants.
.changeset/​orange-monkeys-follow.md Add an empty changeset for the documentation-only update.

Review effort: Balanced

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants