Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 8.5.3

- Preview: Add `globals` to `extract()` - [#30415](https://github.com/storybookjs/storybook/pull/30415), thanks @ndelangen!
- Vite: Fix add component UI invalidation - [#30438](https://github.com/storybookjs/storybook/pull/30438), thanks @shilman!

## 8.5.2

- Addon Test: Support Vitest 3 browser.test.instances field - [#30309](https://github.com/storybookjs/storybook/pull/30309), thanks @valentinpalkovic!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export function codeGeneratorPlugin(options: Options): Plugin {
// TODO maybe use the stories declaration in main
if (/\.stories\.([tj])sx?$/.test(path) || /\.mdx$/.test(path)) {
// We need to emit a change event to trigger HMR
server.watcher.emit('change', SB_VIRTUAL_FILES.VIRTUAL_STORIES_FILE);
server.watcher.emit(
'change',
getResolvedVirtualModuleId(SB_VIRTUAL_FILES.VIRTUAL_STORIES_FILE)
);
}
});
},
Expand Down
12 changes: 12 additions & 0 deletions code/core/src/preview-api/modules/preview-web/PreviewWeb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3793,6 +3793,9 @@ describe('PreviewWeb', () => {
},
"component": undefined,
"componentId": "component-one",
"globals": {
"a": "b",
},
"id": "component-one--a",
"initialArgs": {
"foo": "a",
Expand Down Expand Up @@ -3844,6 +3847,9 @@ describe('PreviewWeb', () => {
},
"component": undefined,
"componentId": "component-one",
"globals": {
"a": "b",
},
"id": "component-one--b",
"initialArgs": {
"foo": "b",
Expand Down Expand Up @@ -3876,6 +3882,9 @@ describe('PreviewWeb', () => {
"args": {},
"component": undefined,
"componentId": "component-one",
"globals": {
"a": "b",
},
"id": "component-one--e",
"initialArgs": {},
"kind": "Component One",
Expand Down Expand Up @@ -3914,6 +3923,9 @@ describe('PreviewWeb', () => {
},
"component": undefined,
"componentId": "component-two",
"globals": {
"a": "b",
},
"id": "component-two--c",
"initialArgs": {
"foo": "c",
Expand Down
21 changes: 21 additions & 0 deletions code/core/src/preview-api/modules/store/StoryStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ describe('StoryStore', () => {
},
"component": undefined,
"componentId": "component-one",
"globals": {
"a": "b",
},
"id": "component-one--a",
"initialArgs": {
"foo": "a",
Expand Down Expand Up @@ -471,6 +474,9 @@ describe('StoryStore', () => {
},
"component": undefined,
"componentId": "component-one",
"globals": {
"a": "b",
},
"id": "component-one--a",
"initialArgs": {
"foo": "a",
Expand Down Expand Up @@ -514,6 +520,9 @@ describe('StoryStore', () => {
},
"component": undefined,
"componentId": "component-one",
"globals": {
"a": "b",
},
"id": "component-one--b",
"initialArgs": {
"foo": "b",
Expand Down Expand Up @@ -557,6 +566,9 @@ describe('StoryStore', () => {
},
"component": undefined,
"componentId": "component-two",
"globals": {
"a": "b",
},
"id": "component-two--c",
"initialArgs": {
"foo": "c",
Expand Down Expand Up @@ -847,6 +859,9 @@ describe('StoryStore', () => {
},
"component": undefined,
"componentId": "component-one",
"globals": {
"a": "b",
},
"id": "component-one--a",
"initialArgs": {
"foo": "a",
Expand Down Expand Up @@ -890,6 +905,9 @@ describe('StoryStore', () => {
},
"component": undefined,
"componentId": "component-one",
"globals": {
"a": "b",
},
"id": "component-one--b",
"initialArgs": {
"foo": "b",
Expand Down Expand Up @@ -933,6 +951,9 @@ describe('StoryStore', () => {
},
"component": undefined,
"componentId": "component-two",
"globals": {
"a": "b",
},
"id": "component-two--c",
"initialArgs": {
"foo": "c",
Expand Down
10 changes: 9 additions & 1 deletion code/core/src/preview-api/modules/store/StoryStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,15 @@ export class StoryStore<TRenderer extends Renderer> {
}
return Object.assign(storyAcc, { [key]: value });
},
{ args: story.initialArgs }
{
//
args: story.initialArgs,
globals: {
...this.userGlobals.initialGlobals,
...this.userGlobals.globals,
...story.storyGlobals,
},
}
);
return acc;
},
Expand Down
49 changes: 3 additions & 46 deletions code/frameworks/preact-vite/README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,4 @@
# Storybook for Preact <!-- omit in toc -->
# Storybook for Preact & Vite

## Requirements

- [Preact](https://preactjs.com/) >= 10.x
- [Storybook](https://storybook.js.org/) >= 7.x

## Getting Started

### In a project without Storybook

Follow the prompts after running this command in your Preact project's root directory:

```bash
npx storybook@latest init
```

[More on getting started with Storybook](https://storybook.js.org/docs/get-started/install?renderer=preact)

### In a project with Storybook

This framework is designed to work with Storybook 7. If you’re not already using v7, upgrade with this command:

```bash
npx storybook@latest upgrade
```

#### Manual migration

Install the framework:

```bash
yarn add --dev @storybook/preact-vite
```

Update your `main.js` to change the framework property:

```js
// .storybook/main.js
export default {
// ...
framework: {
name: '@storybook/preact-vite', // <- Change this
options: {},
},
};
```
See [documentation](https://storybook.js.org/docs/get-started/frameworks/preact-vite?renderer=preact) for installation instructions, usage examples, APIs, and more.
`;
3 changes: 2 additions & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,6 @@
"Dependency Upgrades"
]
]
}
},
"deferredNextVersion": "8.5.3"
}
24 changes: 12 additions & 12 deletions docs/_snippets/my-component-play-function-with-canvas.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const ExampleStory: Story = {

// Starts querying from the component's root element
await userEvent.type(canvas.getByTestId('example-element'), 'something');
await userEvent.click(canvas.getByRole('another-element'));
await userEvent.click(canvas.getByRole('button'));
},
};
```
Expand Down Expand Up @@ -49,7 +49,7 @@ export const ExampleStory: Story = {

// Starts querying from the component's root element
await userEvent.type(canvas.getByTestId('example-element'), 'something');
await userEvent.click(canvas.getByRole('another-element'));
await userEvent.click(canvas.getByRole('button'));
}} />
```

Expand All @@ -69,7 +69,7 @@ export const ExampleStory = {

// Starts querying from the component's root element
await userEvent.type(canvas.getByTestId('example-element'), 'something');
await userEvent.click(canvas.getByRole('another-element'));
await userEvent.click(canvas.getByRole('button'));
},
};
```
Expand All @@ -90,7 +90,7 @@ export const ExampleStory = {

// Starts querying from the component's root element
await userEvent.type(canvas.getByTestId('example-element'), 'something');
await userEvent.click(canvas.getByRole('another-element'));
await userEvent.click(canvas.getByRole('button'));
},
};
```
Expand All @@ -116,7 +116,7 @@ export const ExampleStory = {

// Starts querying from the component's root element
await userEvent.type(canvas.getByTestId('example-element'), 'something');
await userEvent.click(canvas.getByRole('another-element'));
await userEvent.click(canvas.getByRole('button'));
}} />
```

Expand All @@ -141,7 +141,7 @@ export const ExampleStory: Story = {

// Starts querying from the component's root element
await userEvent.type(canvas.getByTestId('example-element'), 'something');
await userEvent.click(canvas.getByRole('another-element'));
await userEvent.click(canvas.getByRole('button'));
},
};
```
Expand All @@ -168,7 +168,7 @@ export const ExampleStory: Story = {

// Starts querying from the component's root element
await userEvent.type(canvas.getByTestId('example-element'), 'something');
await userEvent.click(canvas.getByRole('another-element'));
await userEvent.click(canvas.getByRole('button'));
},
};
```
Expand All @@ -193,7 +193,7 @@ export const ExampleStory: Story = {

// Starts querying from the component's root element
await userEvent.type(canvas.getByTestId('example-element'), 'something');
await userEvent.click(canvas.getByRole('another-element'));
await userEvent.click(canvas.getByRole('button'));
}} />
```

Expand All @@ -218,7 +218,7 @@ export const ExampleStory: Story = {

// Starts querying from the component's root element
await userEvent.type(canvas.getByTestId('example-element'), 'something');
await userEvent.click(canvas.getByRole('another-element'));
await userEvent.click(canvas.getByRole('button'));
},
};
```
Expand All @@ -245,7 +245,7 @@ export const ExampleStory: Story = {

// Starts querying from the component's root element
await userEvent.type(canvas.getByTestId('example-element'), 'something');
await userEvent.click(canvas.getByRole('another-element'));
await userEvent.click(canvas.getByRole('button'));
},
};
```
Expand All @@ -264,7 +264,7 @@ export const ExampleStory = {

// Starts querying from the component's root element
await userEvent.type(canvas.getByTestId('example-element'), 'something');
await userEvent.click(canvas.getByRole('another-element'));
await userEvent.click(canvas.getByRole('button'));
},
};
```
Expand All @@ -287,7 +287,7 @@ export const ExampleStory: Story = {

// Starts querying from the component's root element
await userEvent.type(canvas.getByTestId('example-element'), 'something');
await userEvent.click(canvas.getByRole('another-element'));
await userEvent.click(canvas.getByRole('button'));
},
};
```
19 changes: 19 additions & 0 deletions docs/_snippets/preact-vite-add-framework.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```js filename=".storybook/main.js" renderer="preact" language="js"
export default {
// ...
// framework: '@storybook/preact-webpack5', 👈 Remove this
framework: '@storybook/preact-vite', // 👈 Add this
};
```

```ts filename=".storybook/main.ts" renderer="preact" language="ts"
import { StorybookConfig } from '@storybook/preact-vite';

const config: StorybookConfig = {
// ...
// framework: '@storybook/preact-webpack5', 👈 Remove this
framework: '@storybook/preact-vite', // 👈 Add this
};

export default config;
```
25 changes: 25 additions & 0 deletions docs/_snippets/preact-vite-framework-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
```js filename=".storybook/main.js" renderer="preact" language="js"
export default {
framework: {
name: '@storybook/preact-vite',
options: {
// ...
},
},
};
```

```ts filename=".storybook/main.ts" renderer="preact" language="ts"
import type { StorybookConfig } from '@storybook/preact-vite';

const config: StorybookConfig = {
framework: {
name: '@storybook/preact-vite',
options: {
// ...
},
},
};

export default config;
```
11 changes: 11 additions & 0 deletions docs/_snippets/preact-vite-install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```shell renderer="preact" language="js" packageManager="npm"
npm install --save-dev @storybook/preact-vite
```

```shell renderer="preact" language="js" packageManager="pnpm"
pnpm add --save-dev @storybook/preact-vite
```

```shell renderer="preact" language="js" packageManager="yarn"
yarn add --dev @storybook/preact-vite
```
2 changes: 1 addition & 1 deletion docs/get-started/frameworks/nextjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ Storybook for Next.js is a [framework](../../contribute/framework.mdx) that make

Next.js lets you [customize PostCSS config](https://nextjs.org/docs/pages/building-your-application/configuring/post-css). Thus this framework will automatically handle your PostCSS config for you.

This allows for cool things like zero-config Tailwind! (See [Next.js' example](https://github.com/vercel/next.js/tree/canary/examples/with-tailwindcss))
This allows for cool things like zero-config Tailwind! (See [Next.js' example](https://github.com/vercel/next.js/tree/canary/packages/create-next-app/templates/default-tw))

## Absolute imports

Expand Down
Loading