Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: 📚 optimize code preview + add table of contents #2605

Merged
merged 4 commits into from
Apr 22, 2024

Conversation

mariohamann
Copy link
Contributor

Preflight Checklist

Issue

There's no connected issue.

Changes

Changes in this pull request:

  • This PR adds prettier formatting to every story. This was done with "Replace all" on extractComponentDescription: () => readme, so stories that don't use this might be missed.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Does this introduce a breaking change?

  • Yes
  • No

Other information

Hey there!

I'm maintainer of two design systems (Synergy Design System, Solid Design System) that use Storybook and Lit as well. Really enjoyed going through your Storybook, but the formatting of your code really bugged me and made it feel "broken".

I therefore propose to introduce automatic formatting, which is described over here in the Storybook docs: https://storybook.js.org/docs/api/doc-block-source#format
As you already use prettier in your codebase yourself, I believe that this might be just "consequent". :)

Example 1

Before

CleanShot 2024-04-22 at 06 55 35@2x

After

CleanShot 2024-04-22 at 06 55 18@2x

Example 2

Before

CleanShot 2024-04-22 at 06 51 49@2x

After

CleanShot 2024-04-22 at 06 57 06@2x

All the best and keep up the cool work!

@github-actions github-actions bot added the pr: peer review required A peer review is required for this pull request label Apr 22, 2024
Copy link
Contributor

@jeripeierSBB jeripeierSBB left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your contribution. I was last week trying to integrate prettier in the browser to achieve better code block formatting. Was also checking storybook docs but just not recognizing the format source format part. So again, thanks for solving my problem! :D
Can you please add the definition to preview.ts so we have to only once configure the formatting?

just add

  docs: {
    source: { format: 'html' },
  },

to export const parameters.

Thank you!

@mariohamann
Copy link
Contributor Author

Done! :)

I wasn't sure, if you want to introduce centralized changes (we use preview.ts in our projects ourself for that.))

And I totally get you... we added an package for code formatting, which even introduced bugs on Safari, until I realized that there's prettier support.

Lowhangig-fruit we did in the same commit – we added Table of Contents: solid-design-system/solid@a09daf9#diff-fa2909f2ae1c2b6b0c3710b27e556083f35005f15d2890089e8d2a431fc4ab43R89

CleanShot 2024-04-22 at 08 50 44@2x

Do you want me to add that, too? I would update the PR title then.

@jeripeierSBB
Copy link
Contributor

If you still like to spend time for us, then go for it :D. thanks!

@mariohamann
Copy link
Contributor Author

CleanShot 2024-04-22 at 09 04 25@2x

That's Open Source. 😆

@mariohamann mariohamann changed the title docs: format all stories with prettier docs: 📚 optimize code preview + add table of contents Apr 22, 2024
@github-actions github-actions bot requested a deployment to preview-main April 22, 2024 07:16 In progress
.storybook/preview.ts Outdated Show resolved Hide resolved
Co-authored-by: Jeri Peier <[email protected]>
Copy link
Contributor

@jeripeierSBB jeripeierSBB left a comment

Choose a reason for hiding this comment

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

LGTM, thanks a lot for your help :)

@mariohamann
Copy link
Contributor Author

CleanShot 2024-04-22 at 09 34 25@2x

Seems like you have to merge. :) Enjoy!

@github-actions github-actions bot requested a deployment to preview-main April 22, 2024 07:40 In progress
@jeripeierSBB jeripeierSBB merged commit 7ce927f into sbb-design-systems:main Apr 22, 2024
11 of 12 checks passed
@github-actions github-actions bot added pr: peer review required A peer review is required for this pull request and removed pr: peer review required A peer review is required for this pull request labels Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: peer review required A peer review is required for this pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants