@cappa/plugin-storybook 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +36 -28
- package/CHANGELOG.md +8 -0
- package/README.md +96 -0
- package/dist/browser.mjs +7 -0
- package/dist/index.d.mts +14 -17
- package/dist/index.d.ts +14 -17
- package/dist/index.js +190 -182
- package/dist/index.mjs +168 -166
- package/dist/preview.mjs +58 -0
- package/package.json +12 -7
- package/src/cappa/plugin.ts +5 -1
- package/src/index.ts +2 -1
- package/src/storybook/addon/browser.ts +6 -0
- package/src/storybook/{decorator.ts → addon/decorator.ts} +6 -1
- package/src/storybook/addon/preview.ts +15 -0
- package/tsup.config.ts +29 -0
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/tsdown.config.ts +0 -10
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @cappa/plugin-storybook@0.0.
|
|
4
|
-
>
|
|
3
|
+
> @cappa/plugin-storybook@0.0.11 build /home/tim/cappa/packages/plugins/plugin-storybook
|
|
4
|
+
> tsup
|
|
5
5
|
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
|
|
18
|
-
[
|
|
19
|
-
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
6
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
7
|
+
[34mCLI[39m Using tsconfig: ../../../tsconfig.json
|
|
8
|
+
[34mCLI[39m tsup v8.5.0
|
|
9
|
+
[34mCLI[39m Using tsup config: /home/tim/cappa/packages/plugins/plugin-storybook/tsup.config.ts
|
|
10
|
+
[34mCLI[39m Building entry: src/storybook/addon/preview.ts
|
|
11
|
+
[34mCLI[39m Using tsconfig: ../../../tsconfig.json
|
|
12
|
+
[34mCLI[39m tsup v8.5.0
|
|
13
|
+
[34mCLI[39m Using tsup config: /home/tim/cappa/packages/plugins/plugin-storybook/tsup.config.ts
|
|
14
|
+
[34mCLI[39m Building entry: src/storybook/addon/browser.ts
|
|
15
|
+
[34mCLI[39m Using tsconfig: ../../../tsconfig.json
|
|
16
|
+
[34mCLI[39m tsup v8.5.0
|
|
17
|
+
[34mCLI[39m Using tsup config: /home/tim/cappa/packages/plugins/plugin-storybook/tsup.config.ts
|
|
18
|
+
[34mCLI[39m Target: esnext
|
|
19
|
+
[34mCLI[39m Target: node16
|
|
20
|
+
[34mCLI[39m Target: es2015
|
|
21
|
+
[34mCLI[39m Cleaning output folder
|
|
22
|
+
[34mCJS[39m Build start
|
|
23
|
+
[34mESM[39m Build start
|
|
24
|
+
[34mCLI[39m Cleaning output folder
|
|
25
|
+
[34mESM[39m Build start
|
|
26
|
+
[34mCLI[39m Cleaning output folder
|
|
27
|
+
[34mESM[39m Build start
|
|
28
|
+
[32mESM[39m [1mdist/browser.mjs [22m[32m138.00 B[39m
|
|
29
|
+
[32mESM[39m ⚡️ Build success in 9ms
|
|
30
|
+
[32mESM[39m [1mdist/preview.mjs [22m[32m1.49 KB[39m
|
|
31
|
+
[32mESM[39m ⚡️ Build success in 11ms
|
|
32
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m6.01 KB[39m
|
|
33
|
+
[32mESM[39m ⚡️ Build success in 13ms
|
|
34
|
+
[32mCJS[39m [1mdist/index.js [22m[32m7.32 KB[39m
|
|
35
|
+
[32mCJS[39m ⚡️ Build success in 15ms
|
|
36
|
+
DTS Build start
|
|
37
|
+
DTS ⚡️ Build success in 914ms
|
|
38
|
+
DTS dist/index.d.ts 593.00 B
|
|
39
|
+
DTS dist/index.d.mts 593.00 B
|
package/CHANGELOG.md
CHANGED
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Storybook Plugin for Cappa
|
|
2
|
+
|
|
3
|
+
This plugin allows to take screenshots of Storybook stories with Cappa.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -D @cappa/plugin-storybook
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Add the plugin to your cappa config:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { defineConfig } from "@cappa/core";
|
|
17
|
+
import { cappaPluginStorybook } from "@cappa/plugin-storybook";
|
|
18
|
+
|
|
19
|
+
export default defineConfig({
|
|
20
|
+
plugins: [cappaPluginStorybook({ storybookUrl: "http://localhost:8080" })],
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
> Make sure to have a running Storybook server on the given url.
|
|
25
|
+
|
|
26
|
+
Add the plugin to your storybook config:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
const config: StorybookConfig = {
|
|
30
|
+
addons: ["@cappa/plugin-storybook"],
|
|
31
|
+
};
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Run cappa cli in the directory of your cappa config:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cappa
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Options
|
|
41
|
+
|
|
42
|
+
## Storybook options
|
|
43
|
+
|
|
44
|
+
Cappa uses a storybook addon that allows you to pass options from storybook into cappa.
|
|
45
|
+
|
|
46
|
+
### Parameters
|
|
47
|
+
|
|
48
|
+
| Option | Description | Default |
|
|
49
|
+
| ------ | ---------------------------------------------- | --------------- |
|
|
50
|
+
| skip | Whether to skip the screenshot | false |
|
|
51
|
+
| delay | The delay to wait before taking the screenshot | null (no delay) |
|
|
52
|
+
|
|
53
|
+
#### Example
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
export const Primary: Story = {
|
|
57
|
+
parameters: {
|
|
58
|
+
cappa: {
|
|
59
|
+
skip: true,
|
|
60
|
+
delay: 1000,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Play function
|
|
67
|
+
|
|
68
|
+
cappa automatically waits for the play function to finish, before taking screenshots. This allows you to define 'actions' that are executed before the screenshot is taken e.g. clicking on a button.
|
|
69
|
+
|
|
70
|
+
> `delay` is added "on top" of the play function execution.
|
|
71
|
+
|
|
72
|
+
#### Example
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
export const Primary: Story = {
|
|
76
|
+
play: async ({ canvasElement }) => {
|
|
77
|
+
const canvas = within(canvasElement);
|
|
78
|
+
await userEvent.click(canvas.getByRole("button"));
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Flakiness
|
|
84
|
+
|
|
85
|
+
To avoid flakiness, cappa disables css animations and transitions by default. For additional use cases or animation libraries, you can use the `isCappa` function to check if the current window is a cappa window. You can use it inside of your storybook preview file (`.storybook/preview.ts`):
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
if (isCappa()) {
|
|
89
|
+
import("disable-animations.css");
|
|
90
|
+
MotionGlobalConfig.disableAnimations = true;
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## How it works
|
|
95
|
+
|
|
96
|
+
cappa uses a 'one way binding' to pass options from storybook into cappa. That means that the storybook addon is responsible for passing options into cappa and 'communicating' the correct timing to take the screenshot.
|
package/dist/browser.mjs
ADDED
package/dist/index.d.mts
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import { Plugin } from
|
|
1
|
+
import { Plugin } from '@cappa/core';
|
|
2
2
|
|
|
3
|
-
//#region src/cappa/plugin.d.ts
|
|
4
3
|
interface StorybookPluginOptions {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
storybookUrl: string;
|
|
5
|
+
includeStories?: string[];
|
|
6
|
+
excludeStories?: string[];
|
|
7
|
+
defaultViewport?: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
waitForSelector?: string;
|
|
12
|
+
waitForTimeout?: number;
|
|
14
13
|
}
|
|
15
14
|
/**
|
|
16
15
|
* Storybook Plugin for Cappa
|
|
17
16
|
* Fetches stories from a running Storybook server and takes screenshots of each story
|
|
18
17
|
*/
|
|
19
18
|
declare const cappaPluginStorybook: Plugin<StorybookPluginOptions>;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export { cappaPluginStorybook, withCappaDecorator };
|
|
25
|
-
//# sourceMappingURL=index.d.mts.map
|
|
19
|
+
|
|
20
|
+
declare const previewAnnotations: string[];
|
|
21
|
+
|
|
22
|
+
export { cappaPluginStorybook, previewAnnotations };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import { Plugin } from
|
|
1
|
+
import { Plugin } from '@cappa/core';
|
|
2
2
|
|
|
3
|
-
//#region src/cappa/plugin.d.ts
|
|
4
3
|
interface StorybookPluginOptions {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
storybookUrl: string;
|
|
5
|
+
includeStories?: string[];
|
|
6
|
+
excludeStories?: string[];
|
|
7
|
+
defaultViewport?: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
waitForSelector?: string;
|
|
12
|
+
waitForTimeout?: number;
|
|
14
13
|
}
|
|
15
14
|
/**
|
|
16
15
|
* Storybook Plugin for Cappa
|
|
17
16
|
* Fetches stories from a running Storybook server and takes screenshots of each story
|
|
18
17
|
*/
|
|
19
18
|
declare const cappaPluginStorybook: Plugin<StorybookPluginOptions>;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export { cappaPluginStorybook, withCappaDecorator };
|
|
25
|
-
//# sourceMappingURL=index.d.ts.map
|
|
19
|
+
|
|
20
|
+
declare const previewAnnotations: string[];
|
|
21
|
+
|
|
22
|
+
export { cappaPluginStorybook, previewAnnotations };
|