generated from storybookjs/addon-kit
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Storybook CodeSandbox Addon for exporting stories to CodeSa…
…ndbox with support for private dependencies and workspaces.
- Loading branch information
Showing
2 changed files
with
58 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
![Storybook CodeSandbox Addon](https://github.com/codesandbox/sandpack/assets/4838076/96c444fa-dcb0-4501-9024-6986b39f1455) | ||
|
||
# Storybook CodeSandbox Addon | ||
|
||
The `@codesandbox/storybook-addon` is a Storybook addon that facilitates exporting the current story to CodeSandbox. It offers support for private dependencies, workspaces, and more. | ||
|
||
## Configuration | ||
|
||
To run the addon, you'll need to configure it in your Storybook's `.storybook/preview.js` file. | ||
|
||
```js | ||
// .storybook/preview.js | ||
|
||
codesandbox: { | ||
/** | ||
* CodeSandbox workspace id where the sandbox will be created. | ||
* @required | ||
*/ | ||
workspaceId: CUSTOM_WORKSPACE_ID, | ||
|
||
/** | ||
* List of dependencies to install in the sandbox | ||
* @optional | ||
* | ||
* Example: | ||
*/ | ||
dependencies: { | ||
"@radix-ui/themes": "latest", | ||
}, | ||
|
||
/** | ||
* All required providers to run the sandbox properly, such as | ||
* themes, i18n, store, and so on. | ||
* @optional | ||
* | ||
* Example: | ||
*/ | ||
provider: `import { Theme } from "@radix-ui/themes"; | ||
import '@radix-ui/themes/styles.css'; | ||
export default ThemeProvider = ({ children }) => { | ||
return ( | ||
<Theme> | ||
{children} | ||
</Theme> | ||
) | ||
}`, | ||
}, | ||
``` | ||
|
||
Make sure to provide the necessary values for workspaceId and any additional dependencies or providers required for your specific setup. | ||
|
||
## Usage | ||
Once configured, you can use the addon within your Storybook environment to export stories to CodeSandbox effortlessly. | ||
|
||
## Additional Notes | ||
- Ensure that you have proper permissions and access rights to the CodeSandbox workspace specified in the configuration. | ||
- Verify the correctness of the dependencies and providers listed in the configuration to ensure the sandbox runs smoothly. |