Skip to content

Commit 56f0646

Browse files
docs: replace placeholder README
1 parent c9160ae commit 56f0646

File tree

1 file changed

+4
-209
lines changed

1 file changed

+4
-209
lines changed

README.md

Lines changed: 4 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,11 @@
1-
# Storybook Addon Lambda Feedback Sandbox Addon
2-
lambda feedback sandbox addon
3-
4-
### Development scripts
5-
6-
- `npm run start` runs babel in watch mode and starts Storybook
7-
- `npm run build` build and package your addon code
8-
9-
### Switch from TypeScript to JavaScript
10-
11-
Don't want to use TypeScript? We offer a handy eject command: `npm run eject-ts`
12-
13-
This will convert all code to JS. It is a destructive process, so we recommended running this before you start writing any code.
14-
15-
## What's included?
16-
17-
![Demo](https://user-images.githubusercontent.com/42671/107857205-e7044380-6dfa-11eb-8718-ad02e3ba1a3f.gif)
18-
19-
The addon code lives in `src`. It demonstrates all core addon related concepts. The three [UI paradigms](https://storybook.js.org/docs/react/addons/addon-types#ui-based-addons)
20-
21-
- `src/Tool.tsx`
22-
- `src/Panel.tsx`
23-
- `src/Tab.tsx`
24-
25-
Which, along with the addon itself, are registered in `src/manager.ts`.
26-
27-
Managing State and interacting with a story:
28-
29-
- `src/withGlobals.ts` & `src/Tool.tsx` demonstrates how to use `useGlobals` to manage global state and modify the contents of a Story.
30-
- `src/withRoundTrip.ts` & `src/Panel.tsx` demonstrates two-way communication using channels.
31-
- `src/Tab.tsx` demonstrates how to use `useParameter` to access the current story's parameters.
32-
33-
Your addon might use one or more of these patterns. Feel free to delete unused code. Update `src/manager.ts` and `src/preview.ts` accordingly.
34-
35-
Lastly, configure you addon name in `src/constants.ts`.
36-
37-
### Bundling
38-
39-
Addons can interact with a Storybook project in multiple ways. It is recommended to familiarize yourself with [the basics](https://storybook.js.org/docs/react/addons/introduction) before getting started.
40-
41-
- Manager entries are used to add UI or behavior to the Storybook manager UI.
42-
- Preview entries are used to add UI or behavior to the preview iframe where stories are rendered.
43-
- Presets are used to modify the Storybook configuration, similar to how [users can configure their `main.ts` configurations](https://storybook.js.org/docs/react/api/main-config).
44-
45-
Since each of these places represents a different environment with different features and modules, it is also recommended to split and build your modules accordingly. This addon-kit comes with a preconfigured [bundling configuration](./tsup.config.ts) that supports this split, and you are free to modify and extend it as needed.
46-
47-
You can define which modules match which environments in the [`package.json#bundler`](./package.json) property:
48-
49-
- `exportEntries` is a list of module entries that users can manually import from anywhere they need to. For example, you could have decorators that users need to import into their `preview.ts` file or utility functions that can be used in their `main.ts` files.
50-
- `managerEntries` is a list of module entries meant only for the manager UI. These modules will be bundled to ESM and won't include types since they are mostly loaded by Storybook directly.
51-
- `previewEntries` is a list of module entries meant only for the preview UI. These modules will be bundled to ESM and won't include types since they are mostly loaded by Storybook directly.
52-
53-
Manager and preview entries are only used in the browser so they only output ESM modules. Export entries could be used both in the browser and in Node depending on their use case, so they both output ESM and CJS modules.
54-
55-
#### Globalized packages
56-
57-
Storybook provides a predefined set of packages that are available in the manager UI and the preview UI. In the final bundle of your addon, these packages should not be included. Instead, the imports should stay in place, allowing Storybook to replace those imports with the actual packages during the Storybook build process.
58-
59-
The list of packages differs between the manager and the preview, which is why there is a slight difference between `managerEntries` and `previewEntries`. Most notably, `react` and `react-dom` are prebundled in the manager but not in the preview. This means that your manager entries can use React to build UI without bundling it or having a direct reference to it. Therefore, it is safe to have React as a `devDependency` even though you are using it in production. _Requiring React as a peer dependency would unnecessarily force your users to install React._
60-
61-
An exception to this rule is if you are using React to inject UI into the preview, which does not come prebundled with React. In such cases, you need to move `react` and `react-dom` to a peer dependency. However, we generally advise against this pattern since it would limit the usage of your addon to React-based Storybooks.
62-
63-
### Metadata
64-
65-
Storybook addons are listed in the [catalog](https://storybook.js.org/addons) and distributed via npm. The catalog is populated by querying npm's registry for Storybook-specific metadata in `package.json`. This project has been configured with sample data. Learn more about available options in the [Addon metadata docs](https://storybook.js.org/docs/react/addons/addon-catalog#addon-metadata).
66-
67-
## Documentation
68-
69-
To help the community use your addon and understand its capabilities, please document it thoroughly.
70-
71-
To get started, replace this README with the content in this sample template, modeled after how essential addons (like [Actions](https://storybook.js.org/docs/essentials/actions)) are documented. Then update the content to describe your addon.
72-
73-
### Sample documentation template
74-
75-
````md
76-
# My Addon
1+
# Lambda Feedback Response Area Sandbox Addon
772

783
## Installation
794

805
First, install the package.
816

827
```sh
83-
npm install --save-dev my-addon
8+
npm install --save-dev @lambda-feedback/sandbox-addon
849
```
8510

8611
Then, register it as an addon in `.storybook/main.js`.
@@ -94,140 +19,10 @@ import type { StorybookConfig } from '@storybook/your-framework';
9419
const config: StorybookConfig = {
9520
// ...rest of config
9621
addons: [
97-
'@storybook/addon-essentials'
98-
'my-addon', // 👈 register the addon here
22+
'@storybook/addon-essentials',
23+
'@lambda-feedback/sandbox-addon', // 👈 register the addon here
9924
],
10025
};
10126

10227
export default config;
10328
```
104-
105-
## Usage
106-
107-
The primary way to use this addon is to define the `exampleParameter` parameter. You can do this the
108-
component level, as below, to affect all stories in the file, or you can do it for a single story.
109-
110-
```js
111-
// Button.stories.ts
112-
113-
// Replace your-framework with the name of your framework
114-
import type { Meta } from '@storybook/your-framework';
115-
116-
import { Button } from './Button';
117-
118-
const meta: Meta<typeof Button> = {
119-
component: Button,
120-
parameters: {
121-
myAddon: {
122-
exampleParameter: true,
123-
// See API section below for available parameters
124-
}
125-
}
126-
};
127-
128-
export default meta;
129-
```
130-
131-
Another way to use the addon is...
132-
133-
## API
134-
135-
### Parameters
136-
137-
This addon contributes the following parameters to Storybook, under the `myAddon` namespace:
138-
139-
#### `disable`
140-
141-
Type: `boolean`
142-
143-
Disable this addon's behavior. This parameter is most useful to allow overriding at more specific
144-
levels. For example, if this parameter is set to true at the project level, it could then be
145-
re-enabled by setting it to false at the meta (component) or story level.
146-
147-
### Options
148-
149-
When registering this addon, you can configure it with the following options, which are passed when
150-
registering the addon, like so:
151-
152-
```ts
153-
// .storybook/main.ts
154-
155-
// Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite)
156-
import type { StorybookConfig } from '@storybook/your-framework';
157-
158-
const config: StorybookConfig = {
159-
// ...rest of config
160-
addons: [
161-
'@storybook/essentials',
162-
{
163-
name: 'my-addon',
164-
options: {
165-
// 👈 options for my-addon go here
166-
},
167-
},
168-
],
169-
};
170-
171-
export default config;
172-
```
173-
174-
#### `useExperimentalBehavior`
175-
176-
Type: `boolean`
177-
178-
Enable experimental behavior to...
179-
180-
````
181-
182-
## Release Management
183-
184-
### Setup
185-
186-
This project is configured to use [auto](https://github.com/intuit/auto) for release management. It generates a changelog and pushes it to both GitHub and npm. Therefore, you need to configure access to both:
187-
188-
- [`NPM_TOKEN`](https://docs.npmjs.com/creating-and-viewing-access-tokens#creating-access-tokens) Create a token with both _Read and Publish_ permissions.
189-
- [`GH_TOKEN`](https://github.com/settings/tokens) Create a token with the `repo` scope.
190-
191-
Then open your `package.json` and edit the following fields:
192-
193-
- `name`
194-
- `author`
195-
- `repository`
196-
197-
#### Local
198-
199-
To use `auto` locally create a `.env` file at the root of your project and add your tokens to it:
200-
201-
```bash
202-
GH_TOKEN=<value you just got from GitHub>
203-
NPM_TOKEN=<value you just got from npm>
204-
```
205-
206-
Lastly, **create labels on GitHub**. You’ll use these labels in the future when making changes to the package.
207-
208-
```bash
209-
npx auto create-labels
210-
```
211-
212-
If you check on GitHub, you’ll now see a set of labels that `auto` would like you to use. Use these to tag future pull requests.
213-
214-
#### GitHub Actions
215-
216-
This template comes with GitHub actions already set up to publish your addon anytime someone pushes to your repository.
217-
218-
Go to `Settings > Secrets`, click `New repository secret`, and add your `NPM_TOKEN`.
219-
220-
### Creating a release
221-
222-
To create a release locally you can run the following command, otherwise the GitHub action will make the release for you.
223-
224-
```sh
225-
npm run release
226-
```
227-
228-
That will:
229-
230-
- Build and package the addon code
231-
- Bump the version
232-
- Push a release to GitHub and npm
233-
- Push a changelog to GitHub

0 commit comments

Comments
 (0)