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

Release: Prerelease 8.5.0-alpha.22 #30041

Merged
merged 75 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
393e935
React: Fix RSC compatibility with addon-themes
shilman Feb 29, 2024
5461f73
support statsJson in angular schemas
yannbf Sep 27, 2024
9920135
Merge branch 'next' into fix/stats-json-in-angular-executor
yannbf Oct 9, 2024
2217e32
Merge branch 'next' into fix/stats-json-in-angular-executor
yannbf Oct 30, 2024
30293dd
Merge branch 'next' into fix/stats-json-in-angular-executor
yannbf Nov 4, 2024
fd7f82f
Addon Docs: Dynamically import rehype
valentinpalkovic Nov 5, 2024
2a02e13
Fix webpack fsCache not working with @storybook/nextjs
sentience Nov 19, 2024
3453b86
Merge branch 'next' into fix/stats-json-in-angular-executor
yannbf Nov 22, 2024
0a3e05b
Fix crash when framework is not specified with options
sentience Nov 27, 2024
83a1f24
Defer all imports from webpack until after Next.js has loaded its int…
sentience Dec 3, 2024
c00c054
Undo unintentional formatting change
sentience Dec 3, 2024
bac7061
Nextjs: Add TS docgen support for Vite implementation
yannbf Dec 5, 2024
c7b1761
Merge branch 'next' into 26239-rsc-themes-compatibilty
yannbf Dec 5, 2024
a91b0ba
feat: add code snippet panel to single story view mode
larsrickert Oct 1, 2024
107c40b
remove console log
larsrickert Oct 1, 2024
a283cea
use dark theme
larsrickert Nov 25, 2024
1fa0e7d
feat: support `docs.source.addonPanel` parameter
larsrickert Nov 25, 2024
01e11e5
Addon-docs: Fix and document source panel disabling
shilman Dec 3, 2024
2be1769
fix typos
larsrickert Dec 4, 2024
33ce8f9
move docs source panel order
larsrickert Dec 4, 2024
db146c3
fix react code snippet format
larsrickert Dec 4, 2024
ad65bda
Merge branch 'next' into larsrickert/1898-story-code-panel
shilman Dec 9, 2024
75f235a
Fix merge conflict remnants
shilman Dec 9, 2024
8408f76
Merge branch 'next' into larsrickert/1898-story-code-panel
yannbf Dec 9, 2024
4591ef9
Wait for 2 seconds before showing result mismatch warning
ghengeveld Dec 10, 2024
b1cc74d
Use local storybook binary instead
kasperpeulen Dec 11, 2024
69bcbaa
Handle telemetry where we determine the test discrepancy, not in the UI
ghengeveld Dec 11, 2024
3375c96
Merge branch 'next' into 29703-bug-test-discrepancy-handling-is-not-a…
ghengeveld Dec 11, 2024
aa75a98
remove existing test.include config
JReinhold Dec 11, 2024
9a680a3
remove unnecessary test.include in test kitchen sink
JReinhold Dec 11, 2024
d5b2286
Merge branch 'next' into jeppe/fix-duplicate-include
JReinhold Dec 11, 2024
6fb17c9
Docs updates for Storybook Test
kylegach Dec 12, 2024
d3c37c9
Update E2E tests with wording changes
ghengeveld Dec 12, 2024
0ece491
Merge branch 'next' of github.com:storybookjs/storybook into jeppe/fi…
JReinhold Dec 12, 2024
9cce225
Fix a11y addon docs
valentinpalkovic Dec 12, 2024
ef170fd
Merge branch 'next' into larsrickert/1898-story-code-panel
larsrickert Dec 12, 2024
36d2413
Merge pull request #30036 from storybookjs/valentin/update-a11y-docs
valentinpalkovic Dec 12, 2024
30b6933
Merge branch 'next' into 29703-bug-test-discrepancy-handling-is-not-a…
ghengeveld Dec 12, 2024
db024c7
Merge pull request #30021 from storybookjs/kasper/use-local
kasperpeulen Dec 12, 2024
6e9fb74
Merge pull request #30029 from storybookjs/jeppe/fix-duplicate-include
JReinhold Dec 12, 2024
d749986
refactor: update parameter to disable code panel
larsrickert Dec 12, 2024
47cbf5a
Merge pull request #30002 from storybookjs/29703-bug-test-discrepancy…
ghengeveld Dec 12, 2024
c2ab01c
Merge pull request #29824 from storybookjs/yann/add-ts-docgen-support…
yannbf Dec 12, 2024
7fd0f08
Merge branch 'next-release' into next
storybook-bot Dec 12, 2024
f9be665
Remove usage of preview hooks in decorators
yannbf Dec 12, 2024
835e188
Merge branch 'next' into 26239-rsc-themes-compatibilty
yannbf Dec 12, 2024
afcb243
Retry scrolling to newly created story
ghengeveld Dec 12, 2024
d5bdc51
Consider height of the testing module and notifications when deciding…
ghengeveld Dec 12, 2024
6c9d375
Reimplement time rendering logic and add stories
ghengeveld Dec 12, 2024
508c825
Refactor for clarity
ghengeveld Dec 12, 2024
20dfae6
Pull test count out of RelativeTime
ghengeveld Dec 12, 2024
808b493
Apply suggestions from code review
kylegach Dec 12, 2024
c3df3f5
Address feedback
kylegach Dec 12, 2024
e76a66a
Add/update assets
kylegach Dec 12, 2024
2511d20
Merge pull request #30035 from storybookjs/docs-sb-test-2
kylegach Dec 12, 2024
f88023a
Remove stray dollar sign
ghengeveld Dec 13, 2024
fb986dc
Set environment variable for Vitest to indicate Storybook integration
valentinpalkovic Dec 13, 2024
6e0da96
Merge pull request #30044 from storybookjs/ui-fixes
ghengeveld Dec 13, 2024
980282f
Merge branch 'next' into fix-nextjs-webpack-fscache
valentinpalkovic Dec 13, 2024
a6a89d8
Merge pull request #29544 from storybookjs/valentin/dynamic-import-of…
valentinpalkovic Dec 13, 2024
9c4d4f0
Experimental Nextjs: Add docgen types to main config
yannbf Dec 12, 2024
c20e364
Merge pull request #30054 from storybookjs/valentin/fix-environment-d…
valentinpalkovic Dec 13, 2024
bb323de
simplify config types in experimental-nextjs-vite by reutilizing reac…
yannbf Dec 13, 2024
47c5b01
Merge branch 'next' into 26239-rsc-themes-compatibilty
yannbf Dec 13, 2024
881bed7
Merge pull request #26243 from storybookjs/26239-rsc-themes-compatibilty
yannbf Dec 13, 2024
27eb245
Merge pull request #30042 from storybookjs/yann/next-vite-docgen-types
yannbf Dec 13, 2024
8690ee9
Merge pull request #29233 from storybookjs/fix/stats-json-in-angular-…
yannbf Dec 13, 2024
902dc18
Fix webpack DefinePlugin import to use default export
valentinpalkovic Dec 13, 2024
6dc2790
UI: Fix controls and parameters on tag-filtered stories
shilman Dec 12, 2024
46bf7b6
Merge branch 'next' into larsrickert/1898-story-code-panel
shilman Dec 13, 2024
cf24c98
Merge pull request #29654 from sentience/fix-nextjs-webpack-fscache
valentinpalkovic Dec 13, 2024
f2a8af8
Fix typechecks
shilman Dec 13, 2024
d3cce51
Merge pull request #30038 from storybookjs/shilman/fix-tag-filtered-c…
shilman Dec 13, 2024
b98a73b
Merge pull request #29253 from storybookjs/larsrickert/1898-story-cod…
shilman Dec 13, 2024
42b895d
Write changelog for 8.5.0-alpha.22 [skip ci]
storybook-bot Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.prerelease.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 8.5.0-alpha.22

- Addon Docs: Dynamically import rehype - [#29544](https://github.com/storybookjs/storybook/pull/29544), thanks @valentinpalkovic!
- Addon Test: Fix duplicate `test.include` patterns - [#30029](https://github.com/storybookjs/storybook/pull/30029), thanks @JReinhold!
- Addon Test: Fix environment variable for Vitest Storybook integration - [#30054](https://github.com/storybookjs/storybook/pull/30054), thanks @valentinpalkovic!
- Addon Test: Use local storybook binary instead - [#30021](https://github.com/storybookjs/storybook/pull/30021), thanks @kasperpeulen!
- Addon Test: Wait for 2 seconds before showing result mismatch warning - [#30002](https://github.com/storybookjs/storybook/pull/30002), thanks @ghengeveld!
- Angular: Support statsJson in angular schemas - [#29233](https://github.com/storybookjs/storybook/pull/29233), thanks @yannbf!
- Core: Fix `scrollIntoView` behavior and reimplement testing module time rendering - [#30044](https://github.com/storybookjs/storybook/pull/30044), thanks @ghengeveld!
- Docs: Add code snippet to addons panel - [#29253](https://github.com/storybookjs/storybook/pull/29253), thanks @larsrickert!
- Next.js: Fix webpack fsCache not working - [#29654](https://github.com/storybookjs/storybook/pull/29654), thanks @sentience!
- Nextjs-Vite: Add TS docgen support - [#29824](https://github.com/storybookjs/storybook/pull/29824), thanks @yannbf!
- Nextjs-Vite: Fix docgen types in main config - [#30042](https://github.com/storybookjs/storybook/pull/30042), thanks @yannbf!
- React: Fix RSC compatibility with addon-themes and hooks - [#26243](https://github.com/storybookjs/storybook/pull/26243), thanks @shilman!
- UI: Fix controls and parameters on tag-filtered stories - [#30038](https://github.com/storybookjs/storybook/pull/30038), thanks @shilman!

## 8.5.0-alpha.21

- Addon A11y: Add typesVersions support for TypeScript definitions in a11y package - [#30005](https://github.com/storybookjs/storybook/pull/30005), thanks @valentinpalkovic!
Expand Down
25 changes: 22 additions & 3 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<h1>Migration</h1>

- [From version 8.4.x to 8.5.x](#from-version-84x-to-85x)
- [Added source code panel to docs](#added-source-code-panel-to-docs)
- [Addon-a11y: Component test integration](#addon-a11y-component-test-integration)
- [Addon-a11y: Deprecated `parameters.a11y.manual`](#addon-a11y-deprecated-parametersa11ymanual)
- [Indexing behavior of @storybook/experimental-addon-test is changed](#indexing-behavior-of-storybookexperimental-addon-test-is-changed)
Expand Down Expand Up @@ -425,14 +426,32 @@

## From version 8.4.x to 8.5.x

### Added source code panel to docs

Starting in 8.5, Storybook Docs (`@storybook/addon-docs`) automatically adds a new addon panel to stories that displays a source snippet beneath each story. This works similarly to the existing [source snippet doc block](https://storybook.js.org/docs/writing-docs/doc-blocks#source), but in the story view. It is intended to replace the [Storysource addon](https://storybook.js.org/addons/@storybook/addon-storysource).

If you wish to disable this panel globally, add the following line to your `.storybook/preview.js` project configuration. You can also selectively disable/enable at the story level.

```js
export default {
parameters: {
docs: {
codePanel: false,
},
},
};
```

### Addon-a11y: Component test integration

In Storybook 8.4, we introduced a new addon called [addon test](https://storybook.js.org/docs/writing-tests/test-addon). Powered by Vitest under the hood, this addon lets you watch, run, and debug your component tests directly in Storybook.
In Storybook 8.4, we introduced the [Test addon](https://storybook.js.org/docs/writing-tests/test-addon) (`@storybook/experimental-addon-test`). Powered by Vitest under the hood, this addon lets you watch, run, and debug your component tests directly in Storybook.

In Storybook 8.5, we revamped the [Accessibility addon](https://storybook.js.org/docs/writing-tests/accessibility-testing) (`@storybook/addon-a11y`) to integrate it with the component tests feature. This means you can now extend your component tests to include accessibility tests.

In Storybook 8.5, we revamped the Accessibility addon (`@storybook/addon-a11y`) to integrate it with the component tests feature. This means you can now extend your component tests to include accessibility tests. If you upgrade to Storybook 8.5 via `npx storybook@latest upgrade`, the Accessibility addon will be automatically configured to work with the component tests. However, if you're upgrading manually and you have the [addon test](https://storybook.js.org/docs/writing-tests/test-addon) installed, adjust your configuration as follows:
If you upgrade to Storybook 8.5 via `npx storybook@latest upgrade`, the Accessibility addon will be automatically configured to work with the component tests. However, if you're upgrading manually and you have the Test addon installed, adjust your configuration as follows:

```diff
// .storybook/vitest.config.ts
// .storybook/vitest.setup.ts
...
+import * as a11yAddonAnnotations from '@storybook/addon-a11y/preview';

Expand Down
13 changes: 11 additions & 2 deletions code/addons/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@
"./angular": "./angular/index.js",
"./angular/index.js": "./angular/index.js",
"./web-components/index.js": "./web-components/index.js",
"./package.json": "./package.json"
"./package.json": "./package.json",
"./manager": {
"types": "./dist/manager.d.ts",
"import": "./dist/manager.mjs",
"require": "./dist/manager.js"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -129,7 +134,11 @@
"./src/preview.ts",
"./src/blocks.ts",
"./src/shims/mdx-react-shim.ts",
"./src/mdx-loader.ts"
"./src/mdx-loader.ts",
"./src/manager.tsx"
],
"managerEntries": [
"./src/manager.tsx"
]
},
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae16",
Expand Down
57 changes: 57 additions & 0 deletions code/addons/docs/src/manager.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from 'react';

import { AddonPanel, type SyntaxHighlighterFormatTypes } from 'storybook/internal/components';
import { ADDON_ID, PANEL_ID, PARAM_KEY, SNIPPET_RENDERED } from 'storybook/internal/docs-tools';
import { addons, types, useAddonState, useChannel } from 'storybook/internal/manager-api';

import { Source } from '@storybook/blocks';

addons.register(ADDON_ID, (api) => {
addons.add(PANEL_ID, {
title: 'Code',
type: types.PANEL,
paramKey: PARAM_KEY,
/**
* This code panel can be disabled by the user by adding this parameter:
*
* @example
*
* ```ts
* parameters: {
* docs: {
* codePanel: false,
* },
* },
* ```
*/
disabled: (parameters) => {
return (
!!parameters &&
typeof parameters[PARAM_KEY] === 'object' &&
parameters[PARAM_KEY].codePanel === false
);
},
match: ({ viewMode }) => viewMode === 'story',
render: ({ active }) => {
const [codeSnippet, setSourceCode] = useAddonState<{
source: string;
format: SyntaxHighlighterFormatTypes;
}>(ADDON_ID, {
source: '',
format: 'html',
});

useChannel({
[SNIPPET_RENDERED]: ({ source, format }) => {
setSourceCode({ source, format });
},
});

return (
<AddonPanel active={!!active}>
<Source code={codeSnippet.source} format={codeSnippet.format} dark />
</AddonPanel>
);
},
});
});
5 changes: 3 additions & 2 deletions code/addons/docs/src/plugins/mdx-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { dirname, join } from 'node:path';
import type { Options } from 'storybook/internal/types';

import { createFilter } from '@rollup/pluginutils';
import rehypeExternalLinks from 'rehype-external-links';
import rehypeSlug from 'rehype-slug';
import type { Plugin } from 'vite';

import type { CompileOptions } from '../compiler';
Expand All @@ -24,6 +22,9 @@ export async function mdxPlugin(options: Options): Promise<Plugin> {
const presetOptions = await presets.apply<Record<string, any>>('options', {});
const mdxPluginOptions = presetOptions?.mdxPluginOptions as CompileOptions;

const rehypeSlug = (await import('rehype-slug')).default;
const rehypeExternalLinks = (await import('rehype-external-links')).default;

return {
name: 'storybook:mdx-plugin',
enforce: 'pre',
Expand Down
9 changes: 6 additions & 3 deletions code/addons/docs/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import type { DocsOptions, Options, PresetProperty } from 'storybook/internal/ty

import type { CsfPluginOptions } from '@storybook/csf-plugin';

import rehypeExternalLinks from 'rehype-external-links';
import rehypeSlug from 'rehype-slug';

import type { CompileOptions } from './compiler';

/**
Expand Down Expand Up @@ -42,6 +39,9 @@ async function webpack(

const { csfPluginOptions = {}, mdxPluginOptions = {} } = options;

const rehypeSlug = (await import('rehype-slug')).default;
const rehypeExternalLinks = (await import('rehype-external-links')).default;

const mdxLoaderOptions: CompileOptions = await options.presets.apply('mdxLoaderOptions', {
...mdxPluginOptions,
mdxCompileOptions: {
Expand Down Expand Up @@ -175,6 +175,9 @@ export const viteFinal = async (config: any, options: Options) => {
const { plugins = [] } = config;
const { mdxPlugin } = await import('./plugins/mdx-plugin');

const rehypeSlug = (await import('rehype-slug')).default;
const rehypeExternalLinks = (await import('rehype-external-links')).default;

// Use the resolvedReact preset to alias react and react-dom to either the users version or the version shipped with addon-docs
const { react, reactDom, mdx } = await getResolvedReact(options);

Expand Down
23 changes: 23 additions & 0 deletions code/addons/docs/template/stories/sourcePanel/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export default {
component: globalThis.Components.Button,
tags: ['autodocs'],
parameters: {
chromatic: { disable: true },
docs: {
codePanel: false,
},
},
};

export const One = { args: { label: 'One' } };

export const Two = { args: { label: 'Two' } };

export const WithSource = {
args: { label: 'Three' },
parameters: {
docs: {
codePanel: true,
},
},
};
5 changes: 5 additions & 0 deletions code/addons/essentials/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
"./backgrounds/manager": "./dist/backgrounds/manager.js",
"./controls/manager": "./dist/controls/manager.js",
"./docs/manager": "./dist/docs/manager.js",
"./docs/preview": {
"types": "./dist/docs/preview.d.ts",
"import": "./dist/docs/preview.mjs",
Expand Down Expand Up @@ -114,10 +115,14 @@
"./src/docs/preset.ts",
"./src/docs/mdx-react-shim.ts"
],
"entries": [
"./src/docs/manager.ts"
],
"managerEntries": [
"./src/actions/manager.ts",
"./src/backgrounds/manager.ts",
"./src/controls/manager.ts",
"./src/docs/manager.ts",
"./src/measure/manager.ts",
"./src/outline/manager.ts",
"./src/toolbars/manager.ts",
Expand Down
2 changes: 2 additions & 0 deletions code/addons/essentials/src/docs/manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @ts-expect-error (no types needed for this)
export * from '@storybook/addon-docs/manager';
2 changes: 1 addition & 1 deletion code/addons/essentials/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ export function addons(options: PresetOptions) {

// NOTE: The order of these addons is important.
return [
'docs',
'controls',
'actions',
'docs',
'backgrounds',
'viewport',
'toolbars',
Expand Down
8 changes: 4 additions & 4 deletions code/addons/test/src/components/Description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export function Description({ state, ...props }: DescriptionProps) {
);
} else if (state.progress?.finishedAt) {
description = (
<RelativeTime
timestamp={new Date(state.progress.finishedAt)}
testCount={state.progress.numTotalTests}
/>
<>
Ran {state.progress.numTotalTests} {state.progress.numTotalTests === 1 ? 'test' : 'tests'}{' '}
<RelativeTime timestamp={state.progress.finishedAt} />
</>
);
} else if (state.watching) {
description = 'Watching for file changes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const meta = {
endRef: null,
// prop for the AddonPanel used as wrapper of Panel
active: true,
storyId: 'story-id',
},
} as Meta<typeof InteractionsPanel>;

Expand Down
12 changes: 1 addition & 11 deletions code/addons/test/src/components/InteractionsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ interface InteractionsPanelProps {
onScrollToEnd?: () => void;
hasResultMismatch?: boolean;
browserTestStatus?: CallStates;
storyId: StoryId;
testRunId: string;
}

const Container = styled.div(({ theme }) => ({
Expand Down Expand Up @@ -105,20 +103,12 @@ export const InteractionsPanel: React.FC<InteractionsPanelProps> = React.memo(
endRef,
hasResultMismatch,
browserTestStatus,
storyId,
testRunId,
}) {
const filter = useAnsiToHtmlFilter();

return (
<Container>
{hasResultMismatch && (
<TestDiscrepancyMessage
browserTestStatus={browserTestStatus}
storyId={storyId}
testRunId={testRunId}
/>
)}
{hasResultMismatch && <TestDiscrepancyMessage browserTestStatus={browserTestStatus} />}
{(interactions.length > 0 || hasException) && (
<Subnav
controls={controls}
Expand Down
Loading
Loading