Skip to content

Conversation

aresnik11
Copy link
Contributor

@aresnik11 aresnik11 commented Sep 29, 2025

Overview

We've integrated the storybook-addon-deep-controls package into our Storybook setup to enhance the developer experience when working with complex, nested object props in our component stories. This addon transforms the way we interact with deeply nested properties by breaking them down into individual, user-friendly controls instead of requiring manual JSON editing.

How It Works

The addon automatically detects nested object properties in component args and creates individual controls for each primitive property within the nested structure. Instead of seeing a single JSON editor for complex objects, developers now see separate, typed controls for each nested property.

Key Technical Implementation:

  1. Automatic Generation: The addon automatically splits any defined object args into multiple primitive controls for each deep primitive property passed into args. See Alert as an example.

  2. Dot Notation: If you need/want to customize the argType beyond what is inferred automatically, you can access the nested properties using dot notation in argTypes, such as:

  • 'tipProps.placement' for tooltip placement options
  • 'infotip.emphasis' for infotip emphasis levels
  • 'popoverProps.beak' for popover beak positioning
  1. Type Safety: Stories that are customizing nested properties will have a TS error and will need to use TypeWithDeepControls<Meta<typeof Component>> instead of the standard Meta<typeof Component> to enable proper TypeScript support for deep controls.
Screenshot 2025-10-08 at 4 34 30 PM Screenshot 2025-10-08 at 4 45 39 PM

PR Checklist

  • Related to designs:
  • Related to JIRA ticket: GM-1255
  • 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
  • The alpha package of this PR is passing end-to-end tests in all relevant Codecademy repositories

Testing Instructions

  1. Go to all button stories
  2. Confirm the size and icon controls work as expected
  3. Go to Input story
  4. Confirm icon control works as expected
  5. Go to Select and SelectDropdown stories
  6. Confirm value control works as expected
  7. Go to Modal story
  8. Confirm stories still work as expected
  9. Go to the IconButton story
  10. Confirm you see the new nested props! and now you can easily interact with tipProps
  11. Repeat for nested props in FormGroup, Radio, Alert, Coachmark, Dialog, ConnectedFormGroup, GridForm
  12. Check it with VO
  13. Finish and do a celebratory dance

PR Links and Envs

Repository PR Link
Monolith Monolith PR
Mono Mono PR

@aresnik11 aresnik11 changed the title initial setup docs: add deep controls add on Sep 29, 2025
Copy link

nx-cloud bot commented Sep 29, 2025

View your CI Pipeline Execution ↗ for commit fb3b96b

Command Status Duration Result
nx run-many --target=verify --parallel=3 --all ✅ Succeeded <1s View ↗
nx run-many --target=build --all ✅ Succeeded 28s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-08 20:19:32 UTC

@codecademydev
Copy link
Collaborator

🚀 Styleguide deploy preview ready!

https://68e6c8395fb9e603bfbf6dff--gamut-preview.netlify.app

Deploy Logs

@codecademydev
Copy link
Collaborator

📬Published Alpha Packages:

@codecademy/[email protected]

@aresnik11 aresnik11 marked this pull request as ready for review October 8, 2025 20:47
@aresnik11 aresnik11 requested a review from a team as a code owner October 8, 2025 20:47
Copy link
Member

@jakemhiller jakemhiller left a comment

Choose a reason for hiding this comment

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

this
is
really
nice

Copy link
Contributor

@LinKCoding LinKCoding left a comment

Choose a reason for hiding this comment

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

Looking good! 🔥🔥
I saw some things that could use some touch-ups, so left some thoughts/Qs.

options: ['normal', 'small', 'large'],
},
control: 'radio',
options: ['normal', 'small', 'large'],
Copy link
Contributor

Choose a reason for hiding this comment

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

The "CTAButton" story has size control, which doesn't work, but the Figma seems to only have a single size. Looking into the CTAButton.tsx, it doesn't look like it uses sizeVariants. TL;DR: should this size prop be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

on my list to clean up the button stories but gonna say this is out of scope

args: defaultProps,
args: {
title: 'Modal Modality',
size: 'small',
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to make the controls for the a dropdown? or radio button?
rn it's just text

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah i have a whole list of things id like to do within SB, id say this is out of scope for this work

},
};

export const LowEmphasisInfoTip: Story = {
Copy link
Contributor

Choose a reason for hiding this comment

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

(Sorries, this exists already) for this story, and the highemphasis — could you add some tip alignment props? they're very awkwardly placed rn

Image

export const Default: Story = {
args: {
children: 'This is an alert',
cta: { children: 'Click Me', text: 'Hello' },
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it should be either children or text?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this story include an onClose() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah these props are weird

Comment on lines +13 to +14
href: '#',
onClick: () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like href and onClick aren't be included in the controls at the same time :\ is it possible to add?
I'd imagine it's some typing thing happening between Anchor and Button

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its the onClick just doesnt want to show up so i gave up

control: {
type: 'boolean',
},
control: 'boolean',
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this actually do anything?
I don't see it in the actual component lol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i dont know, i was just cleaning up the controls so we dont accidentally do it wrong like we did half the time before

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.

4 participants