@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.
@@ -1,31 +1,39 @@
1
1
 
2
2
 
3
- > @cappa/plugin-storybook@0.0.10 build /home/tim/cappa/packages/plugins/plugin-storybook
4
- > tsdown
3
+ > @cappa/plugin-storybook@0.0.11 build /home/tim/cappa/packages/plugins/plugin-storybook
4
+ > tsup
5
5
 
6
- ℹ tsdown v0.14.1 powered by rolldown v1.0.0-beta.37
7
- ℹ Using tsdown config: /home/tim/cappa/packages/plugins/plugin-storybook/tsdown.config.ts
8
- (node:239692) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/tim/cappa/packages/plugins/plugin-storybook/tsdown.config.ts is not specified and it doesn't parse as CommonJS.
9
- Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
10
- To eliminate this warning, add "type": "module" to /home/tim/cappa/packages/plugins/plugin-storybook/package.json.
11
- (Use `node --trace-warnings ...` to show where the warning was created)
12
- ℹ entry: src/index.ts
13
- ℹ tsconfig: ../../../tsconfig.json
14
- ℹ Build start
15
- ℹ Cleaning 6 files
16
- Warning: Invalid input options (1 issue found)
17
- - For the "resolve.tsconfigFilename". It is deprecated. Please use the top-level `tsconfig` option instead. 
18
- Warning: Invalid input options (1 issue found)
19
- - For the "resolve.tsconfigFilename". It is deprecated. Please use the top-level `tsconfig` option instead. 
20
- ℹ [CJS] dist/index.js  7.48 kB │ gzip: 2.60 kB
21
- ℹ [CJS] dist/index.js.map 13.21 kB │ gzip: 4.15 kB
22
- ℹ [CJS] 2 files, total: 20.68 kB
23
- Warning: Invalid input options (1 issue found)
24
- - For the "resolve.tsconfigFilename". It is deprecated. Please use the top-level `tsconfig` option instead. 
25
- ℹ [ESM] dist/index.mjs  6.38 kB │ gzip: 2.19 kB
26
- ℹ [ESM] dist/index.mjs.map 13.19 kB │ gzip: 4.16 kB
27
- ℹ [ESM] dist/index.d.mts  0.71 kB │ gzip: 0.39 kB
28
- ℹ [ESM] 3 files, total: 20.28 kB
29
- ℹ [CJS] dist/index.d.ts 0.71 kB │ gzip: 0.38 kB
30
- ℹ [CJS] 1 files, total: 0.71 kB
31
- ✔ Build complete in 1416ms
6
+ CLI Building entry: src/index.ts
7
+ CLI Using tsconfig: ../../../tsconfig.json
8
+ CLI tsup v8.5.0
9
+ CLI Using tsup config: /home/tim/cappa/packages/plugins/plugin-storybook/tsup.config.ts
10
+ CLI Building entry: src/storybook/addon/preview.ts
11
+ CLI Using tsconfig: ../../../tsconfig.json
12
+ CLI tsup v8.5.0
13
+ CLI Using tsup config: /home/tim/cappa/packages/plugins/plugin-storybook/tsup.config.ts
14
+ CLI Building entry: src/storybook/addon/browser.ts
15
+ CLI Using tsconfig: ../../../tsconfig.json
16
+ CLI tsup v8.5.0
17
+ CLI Using tsup config: /home/tim/cappa/packages/plugins/plugin-storybook/tsup.config.ts
18
+ CLI Target: esnext
19
+ CLI Target: node16
20
+ CLI Target: es2015
21
+ CLI Cleaning output folder
22
+ CJS Build start
23
+ ESM Build start
24
+ CLI Cleaning output folder
25
+ ESM Build start
26
+ CLI Cleaning output folder
27
+ ESM Build start
28
+ ESM dist/browser.mjs 138.00 B
29
+ ESM ⚡️ Build success in 9ms
30
+ ESM dist/preview.mjs 1.49 KB
31
+ ESM ⚡️ Build success in 11ms
32
+ ESM dist/index.mjs 6.01 KB
33
+ ESM ⚡️ Build success in 13ms
34
+ CJS dist/index.js 7.32 KB
35
+ CJS ⚡️ 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
@@ -1,5 +1,13 @@
1
1
  # @cappa/plugin-storybook
2
2
 
3
+ ## 0.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 4e529fd: New options
8
+ - Updated dependencies [4e529fd]
9
+ - @cappa/core@0.0.12
10
+
3
11
  ## 0.0.11
4
12
 
5
13
  ### Patch Changes
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.
@@ -0,0 +1,7 @@
1
+ // src/storybook/addon/browser.ts
2
+ var isCappa = () => {
3
+ return navigator.userAgent.includes("CappaStorybook");
4
+ };
5
+ export {
6
+ isCappa
7
+ };
package/dist/index.d.mts CHANGED
@@ -1,25 +1,22 @@
1
- import { Plugin } from "@cappa/core";
1
+ import { Plugin } from '@cappa/core';
2
2
 
3
- //#region src/cappa/plugin.d.ts
4
3
  interface StorybookPluginOptions {
5
- storybookUrl: string;
6
- includeStories?: string[];
7
- excludeStories?: string[];
8
- defaultViewport?: {
9
- width: number;
10
- height: number;
11
- };
12
- waitForSelector?: string;
13
- waitForTimeout?: number;
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
- //#endregion
21
- //#region src/storybook/decorator.d.ts
22
- declare const withCappaDecorator: (...args: any) => any;
23
- //#endregion
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 "@cappa/core";
1
+ import { Plugin } from '@cappa/core';
2
2
 
3
- //#region src/cappa/plugin.d.ts
4
3
  interface StorybookPluginOptions {
5
- storybookUrl: string;
6
- includeStories?: string[];
7
- excludeStories?: string[];
8
- defaultViewport?: {
9
- width: number;
10
- height: number;
11
- };
12
- waitForSelector?: string;
13
- waitForTimeout?: number;
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
- //#endregion
21
- //#region src/storybook/decorator.d.ts
22
- declare const withCappaDecorator: (...args: any) => any;
23
- //#endregion
24
- export { cappaPluginStorybook, withCappaDecorator };
25
- //# sourceMappingURL=index.d.ts.map
19
+
20
+ declare const previewAnnotations: string[];
21
+
22
+ export { cappaPluginStorybook, previewAnnotations };