Skip to content

docs: Add 2nd-gen TypeScript style guide and Storybook docs automation#6067

Open
caseyisonit wants to merge 11 commits intomainfrom
caseyisonit/typescript-guide
Open

docs: Add 2nd-gen TypeScript style guide and Storybook docs automation#6067
caseyisonit wants to merge 11 commits intomainfrom
caseyisonit/typescript-guide

Conversation

@caseyisonit
Copy link
Contributor

@caseyisonit caseyisonit commented Mar 6, 2026

Description

Adds a comprehensive TypeScript style guide for 2nd-gen component development and automates publishing contributor docs to Storybook.

Motivation and context

Contributors (human and AI) need clear, consistent guidance for writing 2nd-gen components. This PR provides detailed conventions for file organization, class structure, decorators, types, and composition patterns—all based on the Badge component as the reference implementation.

Additionally, contributor docs are now automatically converted and displayed within Storybook, making them easier to discover and browse alongside component documentation.

Related issue(s)

  • fixes [SWC-1420]

Screenshots (if appropriate)

N/A - documentation changes

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Verify TypeScript guide renders correctly in Storybook

    1. Run yarn storybook in 2nd-gen/packages/swc
    2. Navigate to the Contributor Docs section
    3. Confirm the TypeScript style guide pages load and display properly
  • Verify navigation structure is accurate

    1. Open CONTRIBUTOR-DOCS/02_style-guide/02_typescript/README.md
    2. Confirm all 15 linked guides exist and have correct content

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

Summary of changes:

Area Files Description
TypeScript style guide 15 new docs File organization, class structure, decorators, types, composition patterns
Storybook automation generate-contributor-docs.mjs Converts markdown docs to MDX for Storybook display
Minor fixes Badge, sized mixin Small updates aligned with documented patterns

@caseyisonit caseyisonit requested a review from a team as a code owner March 6, 2026 19:40
@changeset-bot
Copy link

changeset-bot bot commented Mar 6, 2026

⚠️ No Changeset found

Latest commit: 9eb176f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor Author

@caseyisonit caseyisonit Mar 6, 2026

Choose a reason for hiding this comment

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

this correctly keeps 1st-types working but closer to 1st-gen. this is the pattern for correcting 1st-gen types while maintaining code quality in 2nd-gen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Properly reflects the types patterns we are wanting to enforce, the key update with this is NEVER using s2 in any type declarations so we avoid breaking changes in the future to remove that

Copy link
Contributor Author

@caseyisonit caseyisonit Mar 6, 2026

Choose a reason for hiding this comment

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

implements the as const pattern that will aid in IDE support for allowed values

@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

📚 Branch Preview Links

🔍 First Generation Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-6067

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Copy link
Contributor Author

@caseyisonit caseyisonit Mar 6, 2026

Choose a reason for hiding this comment

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

script to auto generate contributor docs to mdx files and work in storybook. CONTRIBUTOR-DOCS remains the source of truth. ties in to yarn start/storybook so it runs when you spin up storybook

],
],
'Contributor docs',
// GENERATED:CONTRIBUTOR-DOCS-SORT - Do not edit manually. Run `yarn generate:contributor-docs` to update.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

script generates a story sort based on the directory and file structure in CONTRIBUTOR-DOCS

2. **Zero-width non-joiner**: Added `⁠` (zero-width non-joiner) between label text and required asterisk icon to prevent text wrapping issues in internationalized content
3. **Static color support**: Added support for `--staticBlack` and `--staticWhite` variants through the `staticColor` parameter

</details>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rogue closing tag that broke rendering

@caseyisonit caseyisonit added the Status:Ready for review PR ready for review or re-review. label Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status:Ready for review PR ready for review or re-review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants