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

Vue: Consider custom code snippet in story code panel #30179

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

larsrickert
Copy link
Contributor

@larsrickert larsrickert commented Jan 3, 2025

Follow up PR for #29253

What I did

  • Update the story "Code" panel added in Docs: Add code snippet to addons panel #29253 to consider custom code snippets. Previously, stories with custom code snippets did not show any code snippet or reused the one from the previously opened story
  • remove default "html" format which breaks react/JSX snippets/formatting
  • updated the styles to remove unnecessary margin and made the code full panel height
  • replace useAddonState with useState because the code snippets are individual per story so persisting the state globally does not make sense / is not needed

image

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

  1. Run a sandbox for template, e.g. yarn task --task sandbox --start-from auto --template react-vite/default-ts
  2. Open Storybook in your browser
  3. Access story: http://localhost:6006/?path=/story/addons-docs-codepanel--custom-code

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.8 MB 77.8 MB 0 B 1.88 0%
initSize 133 MB 133 MB 1.33 kB -0.57 0%
diffSize 55.3 MB 55.3 MB 1.33 kB -0.57 0%
buildSize 7.19 MB 7.19 MB 187 B -0.9 0%
buildSbAddonsSize 1.85 MB 1.85 MB 187 B -0.92 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.87 MB 1.87 MB 0 B 0.71 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.91 MB 3.91 MB 187 B -0.9 0%
buildPreviewSize 3.28 MB 3.28 MB 0 B - 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 19s 17.4s -1s -560ms 1.24 🔰-8.9%
generateTime 19.6s 20.3s 664ms 0.06 3.3%
initTime 14.2s 13.6s -559ms -0.28 -4.1%
buildTime 8.8s 10.5s 1.6s 0.89 15.9%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5s 6.3s 1.3s 1.36 🔺21.7%
devManagerResponsive 3.6s 4.7s 1s 1.78 🔺22.3%
devManagerHeaderVisible 594ms 583ms -11ms -0.5 -1.9%
devManagerIndexVisible 652ms 719ms 67ms 0.33 9.3%
devStoryVisibleUncached 2s 1.9s -100ms 0.19 -5.1%
devStoryVisible 651ms 720ms 69ms 0.26 9.6%
devAutodocsVisible 549ms 636ms 87ms 0.68 13.7%
devMDXVisible 522ms 633ms 111ms 0.6 17.5%
buildManagerHeaderVisible 549ms 771ms 222ms 1.18 28.8%
buildManagerIndexVisible 644ms 920ms 276ms 1.47 🔺30%
buildStoryVisible 537ms 755ms 218ms 1.31 🔺28.9%
buildAutodocsVisible 484ms 563ms 79ms 0.71 14%
buildMDXVisible 430ms 627ms 197ms 1.62 🔺31.4%

Greptile Summary

Enhanced the code panel functionality in Storybook to properly handle custom code snippets and improve styling, particularly for Vue components.

  • Added support for custom code snippets in code/addons/docs/src/manager.tsx using useState for state management
  • Improved Source component styling with full panel height and removed unnecessary margins
  • Added test stories in code/addons/docs/template/stories/codePanel/index.stories.tsx demonstrating custom code and panel disabling
  • Exported SourceParameters type from code/lib/blocks/src/blocks/Source.tsx for better type integration

💡 (3/5) Reply to the bot's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

code/addons/docs/src/manager.tsx Outdated Show resolved Hide resolved
code/addons/docs/src/manager.tsx Show resolved Hide resolved
Copy link

nx-cloud bot commented Jan 3, 2025

View your CI Pipeline Execution ↗ for commit 2b41a51.

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 38s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-03 08:17:49 UTC

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

LGTM

4 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants