Create stories template with best practices#484
Conversation
|
natalia-fitzgerald
left a comment
There was a problem hiding this comment.
@flacoman91
Nice work! Here are some initial suggestions on the templates.
| </li> | ||
| <li> | ||
| <Paragraph> | ||
| You want to describe usage rules, do/don't guidance, or accessibility |
There was a problem hiding this comment.
All usage guidelines should all live in the CFPB Design System itself and not in the DSR. If we are referring to something more specific here, for example, React implementations then we can specify.
| </li> | ||
| </List> | ||
|
|
||
| <Heading type='4'>Related stories</Heading> |
There was a problem hiding this comment.
| <Heading type='4'>Related stories</Heading> | |
| <Heading type='4'>Component variant</Heading> |
| * - Keep stories focused on behavior/appearance; avoid test-only props. | ||
| * - Use args for the "Default" story and reuse them in variants. | ||
| * - Add a minimal set of variants that reflect real usage. | ||
| * - Add the link to the component's documentation page in https://cfpb.github.io/design-system/components/ |
There was a problem hiding this comment.
| * - Add the link to the component's documentation page in https://cfpb.github.io/design-system/components/ | |
| * - Add the link to the component's CFPB Design System documentation page in https://cfpb.github.io/design-system/components/ |
|
@flacoman91
|
The first 2 items, i added in the component.tsx file since that is how that info gets injected in the storybook file. The rest I added this in the stories template. |
natalia-fitzgerald
left a comment
There was a problem hiding this comment.
@flacoman91
I know this is still a work in progress. I made some suggestions, particularly for the stories and overview docs to make this look more like a template for what the final pages should look like (in terms of their content blocks). I think the guidance is good but I would prefer that we hide it outside of the content that will show up on the pages.
| </li> | ||
| <li> | ||
| <Paragraph> | ||
| All usage guidelines should all live in the CFPB Design System itself and not in the DSR. If we are referring to something more specific here, for example, React implementations then we can specify. |
There was a problem hiding this comment.
This blurb applies to how we handle DSR component documentation more broadly. It could be moved to the component template stories level.
| </li> | ||
| <li> | ||
| <Paragraph> | ||
| All usage guidelines should all live in the CFPB Design System itself and not in the DSR. If we are referring to something more specific here, for example, React implementations then we can specify. |
There was a problem hiding this comment.
| All usage guidelines should all live in the CFPB Design System itself and not in the DSR. If we are referring to something more specific here, for example, React implementations then we can specify. |
| import type { Meta, StoryObj } from '@storybook/react-vite'; | ||
| import ComponentTemplate from './ComponentTemplate'; | ||
|
|
||
| // Best practice checklist: |
There was a problem hiding this comment.
At a later date we should bring together the verification checklist, this checklist, and any other user documentation checklists and determine where the different content should live so that we are only maintaining it in one place.
We have this place: https://cfpb.github.io/design-system-react/?path=/docs/guides-introduction--overview. Maybe that would be the place to put these types of process lists. Templates like these could link back out to that page https://cfpb.github.io/design-system-react/?path=/docs/guides-introduction--overview. And then this template could just be a content template for the page type. Not something we need to figure out yet.
There was a problem hiding this comment.
Actually, I think this is a nicer approach, rather than linking to the introduction page - https://govuk-react.github.io/govuk-react/?path=/docs/docs-contributing--docs](#484 (comment))
| }; | ||
|
|
||
| export const WithCustomRender: Story = { | ||
| name: 'Custom render', |
There was a problem hiding this comment.
What is the use case for custom render?
There was a problem hiding this comment.
It's just another story example for the page. We can remove it.
| const meta: Meta<typeof ComponentTemplate> = { | ||
| // TODO: Update to your component's category and name. | ||
| title: 'Templates/Component Template', | ||
| component: ComponentTemplate, |
There was a problem hiding this comment.
Can we change the heading on this page to "Component name" (sentence case)?
<h1 class="sbdocs-title sb-unstyled css-1006lt">Component name``
cff2526 to
35934ac
Compare
natalia-fitzgerald
left a comment
There was a problem hiding this comment.
@flacoman91 - A few additional suggestion included here.
Also, if we plan to show the templates in actual UI we should update the menu items to whatever names we want to use to refer to each of these templates (rather than having the menu items pull from the first heading on each template page). Or do we plan to remove these from view once we complete the review process?
| </Paragraph> | ||
|
|
||
| <Paragraph> | ||
| The only use case for this format is for when we have components that live under a single parent where the types (or variants) have their own states. This template should be used very rarely. |
There was a problem hiding this comment.
| The only use case for this format is for when we have components that live under a single parent where the types (or variants) have their own states. This template should be used very rarely. |
|
This is a nice approach to how/where to document the contribution guidelines: https://govuk-react.github.io/govuk-react/?path=/docs/docs-contributing--docs. They created a section within the storybook documentation itself for "Documentation."
|
natalia-fitzgerald
left a comment
There was a problem hiding this comment.
@flacoman91
What do you think of this naming for the files to make it simpler:
src/components/templates
- Component.stories.tsx
- Component.test.tsx
- Component.tsx
- ComponentGroup.mdx
I don't know where to put this but when the ComponentTemplate.stories (Component.stories.tsx) template is used with the ComponentTemplateOverview.mdx (ComponentGroup.mdx) we do not include the CFPB Design System component description on the stories page. In these use cases the component description from the CFPB Design System only lives on the ComponentTemplateOverview.mdx (ComponentGroup.mdx) page.
There was a problem hiding this comment.
Is this one the unit test?
There was a problem hiding this comment.
Yes, its just a basic test. We should also note that devs should aim for 100% coverage (or whatever threshold)
There was a problem hiding this comment.
Is this test the same one that is mentioned in the verification checklist?
- "Verify component unit tests are implemented and passing - 85% or greater (ex: yarn vitest ComponentName)"
If so I'd like to link to this template from the checklist. For the naming is "Component.test.tsx" specific enough? As in are there component tests and unit tests or component unit tests? This is clearly not my area of expertise, I am asking for the sake of consistent language between the way we refer to these things in the checklist and the template naming (and so that we use the naming that makes the most sense to developers like you).
| /** | ||
| * Copy the component description from the CFPB Design System page for the component in the component file JSDoc block (autodocs uses it). | ||
| * Add the link to the component's CFPB Design System documentation page below | ||
| * | ||
| * Source: https://cfpb.github.io/design-system/components/[Component-Name] | ||
| */ |
There was a problem hiding this comment.
Does this text belong here or does it only belong on the stories template page?
There was a problem hiding this comment.
We can put a reminder on the stories template page to remind users to update this info.
I would only add this information here in the JSDocs. Autodocs pulls the component description from the component’s JSDoc consistently across all stories and consumers. If you have this info in the storybook, devs don't see it appear in the IDE intellisense feature.
If you want the IDE to actually show the component details when you're coding, you want this info here. This way it will appear in both the IDE and in the stories in storybook.
It looks like the way we have it declared in other components are set up are a little inconsistent.
| * Label text for the component. | ||
| */ | ||
| label: string; | ||
| /** | ||
| * Optional helper text shown below the label. | ||
| */ | ||
| helperText?: string; |
There was a problem hiding this comment.
Here we should indicate that the sample text we use in these components should match the CFPB Design System component page example.
There was a problem hiding this comment.
I added this in the stories template since that is what determines how you view it in storybook.
7765e90 to
bb0012e
Compare
add the design system link, add mdx file add component example adding test file update move template update text update name update template Apply suggestion from @natalia-fitzgerald Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> Apply suggestion from @natalia-fitzgerald Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> Apply suggestion from @natalia-fitzgerald Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> Apply suggestion from @natalia-fitzgerald Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> Apply suggestion from @natalia-fitzgerald Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> Apply suggestion from @natalia-fitzgerald Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> Apply suggestion from @natalia-fitzgerald Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> Apply suggestion from @natalia-fitzgerald Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> Apply suggestions from code review Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> Apply suggestion from @natalia-fitzgerald Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> Apply suggestion from @natalia-fitzgerald Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> Apply suggestion from @natalia-fitzgerald Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> Apply suggestion from @natalia-fitzgerald Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> fixing formatting remove template Apply suggestion from @natalia-fitzgerald Co-authored-by: Natalia Fitzgerald <77348967+natalia-fitzgerald@users.noreply.github.com> remove p rename file to kebab
bb0012e to
69145a3
Compare
I like this and the contribution guide section! |
|
@natalia-fitzgerald we already have a guides section at the top with introduction. we can add the template there as well as any other contribution guidlines?
|
@flacoman91 Folder: Getting started
Folder: Contributing
It's possible that if we build this structure we will have to modify it later but I think having a broad folder at the top that serves as the front door and a narrowly focused folder at the bottom for contributing might be a good start? |




I've looked at the other stories in our project and created a basic example devs can work off of when starting off a new component.