Skip to content

Conversation

@yannbf
Copy link
Member

@yannbf yannbf commented Dec 19, 2024

Closes #

What I did

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!

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 3.95 0%
initSize 136 MB 136 MB 1 B 1.78 0%
diffSize 58.4 MB 58.4 MB 1 B -1.6 0%
buildSize 7.23 MB 7.23 MB 1 B -2.83 0%
buildSbAddonsSize 1.86 MB 1.86 MB 1 B -3 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.87 MB 1.87 MB 0 B 2 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.92 MB 3.92 MB 1 B -2.82 0%
buildPreviewSize 3.3 MB 3.3 MB 0 B -0.52 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 17.2s 24.3s 7s 1.3 🔺29%
generateTime 21.2s 20.4s -718ms -0.29 -3.5%
initTime 16.4s 13.7s -2s -751ms -0.95 -20%
buildTime 9s 7.7s -1s -226ms -1.89 🔰-15.7%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4.5s 4.6s 155ms -0.94 3.3%
devManagerResponsive 3.3s 3.5s 114ms -0.97 3.3%
devManagerHeaderVisible 511ms 570ms 59ms -0.94 10.4%
devManagerIndexVisible 522ms 603ms 81ms -0.91 13.4%
devStoryVisibleUncached 1.6s 1.8s 115ms -0.14 6.3%
devStoryVisible 544ms 605ms 61ms -0.93 10.1%
devAutodocsVisible 450ms 563ms 113ms -0.19 20.1%
devMDXVisible 492ms 478ms -14ms -0.99 -2.9%
buildManagerHeaderVisible 517ms 603ms 86ms -0.56 14.3%
buildManagerIndexVisible 608ms 703ms 95ms -0.52 13.5%
buildStoryVisible 510ms 584ms 74ms -0.42 12.7%
buildAutodocsVisible 403ms 464ms 61ms -0.36 13.1%
buildMDXVisible 417ms 491ms 74ms -0.16 15.1%

Greptile Summary

Here's my concise review of the changes:

Deprecates the useThemeParameters hook in favor of direct context access for theme parameters in the Storybook addon-themes package, improving code maintainability.

  • Added deprecation notice in code/addons/themes/docs/api.md with migration instructions
  • Updated code/addons/themes/src/decorators/helpers.ts to handle deprecated hook usage with warning
  • Updated Vuetify example to demonstrate recommended context-based approach
  • Improved parameter fallback logic using nullish coalescing operator

The changes are focused on removing an unnecessary abstraction layer while maintaining backward compatibility through proper deprecation notices.

@yannbf yannbf added maintenance User-facing maintenance tasks ci:normal addon: themes labels Dec 19, 2024
@yannbf yannbf self-assigned this Dec 19, 2024
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.

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


export function useThemeParameters(context: StoryContext): ThemeParameters {
return context.parameters[PARAM_KEY] || DEFAULT_THEME_PARAMETERS;
if (!context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: checking for !context seems incorrect - context should always be provided in valid usage

`
);

return useParameter<ThemeParameters>(PARAM_KEY, DEFAULT_THEME_PARAMETERS) as ThemeParameters;
Copy link
Contributor

Choose a reason for hiding this comment

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

style: casting to ThemeParameters may hide type errors - consider using type guards instead

@nx-cloud
Copy link

nx-cloud bot commented Dec 19, 2024

View your CI Pipeline Execution ↗ for commit 1ded935.

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

☁️ Nx Cloud last updated this comment at 2024-12-19 16:14:30 UTC

@yannbf yannbf changed the title Addon Themes: deprecate useThemeParameters Addon Themes: Deprecate useThemeParameters Dec 19, 2024
@yannbf yannbf force-pushed the fix-addon-themes-issue branch from 191ca46 to 1ded935 Compare December 19, 2024 16:10
Copy link
Contributor

@kylegach kylegach left a comment

Choose a reason for hiding this comment

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

Docs are good; thanks!

(The rest seems good to me, too, fwiw.)

@yannbf yannbf merged commit 5f2a0e1 into next Dec 20, 2024
58 checks passed
@yannbf yannbf deleted the fix-addon-themes-issue branch December 20, 2024 10:59
@github-actions github-actions bot mentioned this pull request Dec 20, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addon: themes ci:normal maintenance User-facing maintenance tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants