-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: Add Preact-vite framework docs #30271
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
```js filename=".storybook/main.js" renderer="react" language="js" | ||
export default { | ||
// ... | ||
// framework: '@storybook/preact-webpack5', 👈 Remove this | ||
framework: '@storybook/preact-vite', // 👈 Add this | ||
}; | ||
``` | ||
|
||
```ts filename=".storybook/main.ts" renderer="react" 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; | ||
``` | ||
Comment on lines
+9
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: renderer should be 'preact' instead of 'react' since this is Preact-specific documentation |
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; | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
```shell renderer="react" language="js" packageManager="npm" | ||
npm install --save-dev @storybook/preact-vite | ||
``` | ||
|
||
```shell renderer="react" language="js" packageManager="pnpm" | ||
pnpm add --save-dev @storybook/preact-vite | ||
``` | ||
|
||
```shell renderer="react" language="js" packageManager="yarn" | ||
yarn add --dev @storybook/preact-vite | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- | ||
title: Storybook for Preact & Vite | ||
sidebar: | ||
order: 13 | ||
title: Preact & Vite | ||
--- | ||
|
||
Storybook for Preact & Vite is a [framework](../../contribute/framework.mdx) that makes it easy to develop and test UI components in isolation for [Preact](https://preactjs.com/) applications built with [Vite](https://vitejs.dev/). It includes: | ||
|
||
* 🏎️ Pre-bundled for performance | ||
* 🪄 Zero config | ||
* 💫 and more! | ||
|
||
<If notRenderer="Preact"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Case mismatch in notRenderer="Preact" - should be lowercase 'preact' to match renderer="preact" usage below |
||
<Callout variant="info"> | ||
Storybook for Preact & Vite is only supported in [Preact](?renderer=preact) projects. | ||
</Callout> | ||
|
||
{/* End non-supported renderers */} | ||
</If> | ||
|
||
<If renderer="preact"> | ||
## Requirements | ||
|
||
* Preact 8.x || 10.x | ||
* Vite ≥ 4.0 | ||
* Storybook ≥ 8.0 | ||
|
||
## Getting started | ||
|
||
### In a project without Storybook | ||
|
||
Follow the prompts after running this command in your React project's root directory: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: 'React project' should be 'Preact project' since this is Preact-specific documentation |
||
|
||
{/* prettier-ignore-start */} | ||
|
||
<CodeSnippets path="init-command.md" /> | ||
|
||
{/* prettier-ignore-end */} | ||
|
||
[More on getting started with Storybook.](../install.mdx) | ||
|
||
### 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: | ||
|
||
{/* prettier-ignore-start */} | ||
|
||
<CodeSnippets path="storybook-upgrade.md" /> | ||
|
||
{/* prettier-ignore-end */} | ||
|
||
#### Automatic migration | ||
|
||
When running the `upgrade` command above, you should get a prompt asking you to migrate to `@storybook/preact-vite`, which should handle everything for you. In case that auto-migration does not work for your project, refer to the manual migration below. | ||
|
||
#### Manual migration | ||
|
||
First, install the framework: | ||
|
||
{/* prettier-ignore-start */} | ||
|
||
<CodeSnippets path="preact-vite-install.md" /> | ||
|
||
{/* prettier-ignore-end */} | ||
|
||
Then, update your `.storybook/main.js|ts` to change the framework property: | ||
|
||
{/* prettier-ignore-start */} | ||
|
||
<CodeSnippets path="preact-vite-add-framework.md" /> | ||
|
||
{/* prettier-ignore-end */} | ||
|
||
## Run the Setup Wizard | ||
|
||
If all goes well, you should see a setup wizard that will help you get started with Storybook introducing you to the main concepts and features, including how the UI is organized, how to write your first story, and how to test your components' response to various inputs utilizing [controls](../../essentials/controls.mdx). | ||
|
||
![Storybook onboarding](../../_assets/get-started/example-onboarding-wizard.png) | ||
|
||
If you skipped the wizard, you can always run it again by adding the `?path=/onboarding` query parameter to the URL of your Storybook instance, provided that the example stories are still available. | ||
|
||
## API | ||
|
||
### Options | ||
|
||
You can pass an options object for additional configuration if needed: | ||
|
||
{/* prettier-ignore-start */} | ||
|
||
<CodeSnippets path="preact-vite-framework-options.md" /> | ||
|
||
{/* prettier-ignore-end */} | ||
|
||
#### `builder` | ||
|
||
Type: `Record<string, any>` | ||
|
||
Configure options for the [framework's builder](../../api/main-config/main-config-framework.mdx#optionsbuilder). For this framework, available options can be found in the [Vite builder docs](../../builders/vite.mdx). | ||
|
||
{/* End supported renderers */} | ||
</If> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: renderer should be 'preact' instead of 'react' since this is Preact-specific documentation