@cappa/plugin-storybook 0.1.3 → 0.2.1

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,18 +1,18 @@
1
1
 
2
2
 
3
- > @cappa/plugin-storybook@0.1.2 build /home/tim/cappa/packages/plugins/plugin-storybook
3
+ > @cappa/plugin-storybook@0.2.0 build /home/tim/cappa/packages/plugins/plugin-storybook
4
4
  > tsup
5
5
 
6
6
  CLI Building entry: src/index.ts
7
- CLI Using tsconfig: ../../../tsconfig.json
7
+ CLI Using tsconfig: tsconfig.json
8
8
  CLI tsup v8.5.0
9
9
  CLI Using tsup config: /home/tim/cappa/packages/plugins/plugin-storybook/tsup.config.ts
10
10
  CLI Building entry: src/storybook/addon/preview.ts
11
- CLI Using tsconfig: ../../../tsconfig.json
11
+ CLI Using tsconfig: tsconfig.json
12
12
  CLI tsup v8.5.0
13
13
  CLI Using tsup config: /home/tim/cappa/packages/plugins/plugin-storybook/tsup.config.ts
14
14
  CLI Building entry: src/storybook/addon/browser.ts
15
- CLI Using tsconfig: ../../../tsconfig.json
15
+ CLI Using tsconfig: tsconfig.json
16
16
  CLI tsup v8.5.0
17
17
  CLI Using tsup config: /home/tim/cappa/packages/plugins/plugin-storybook/tsup.config.ts
18
18
  CLI Target: esnext
@@ -26,14 +26,14 @@
26
26
  CLI Cleaning output folder
27
27
  ESM Build start
28
28
  ESM dist/browser.mjs 138.00 B
29
+ ESM ⚡️ Build success in 10ms
30
+ ESM dist/preview.mjs 1.35 KB
29
31
  ESM ⚡️ Build success in 11ms
30
- ESM dist/preview.mjs 1.34 KB
31
- ESM ⚡️ Build success in 13ms
32
- ESM dist/index.mjs 9.40 KB
33
- ESM ⚡️ Build success in 19ms
34
- CJS dist/index.js 10.79 KB
35
- CJS ⚡️ Build success in 20ms
32
+ ESM dist/index.mjs 11.00 KB
33
+ ESM ⚡️ Build success in 16ms
34
+ CJS dist/index.js 12.33 KB
35
+ CJS ⚡️ Build success in 16ms
36
36
  DTS Build start
37
- DTS ⚡️ Build success in 1069ms
38
- DTS dist/index.d.ts 593.00 B
39
- DTS dist/index.d.mts 593.00 B
37
+ DTS ⚡️ Build success in 1283ms
38
+ DTS dist/index.d.ts 905.00 B
39
+ DTS dist/index.d.mts 905.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @cappa/plugin-storybook
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 526857a: feat: add variant and play function support
8
+ - Updated dependencies [526857a]
9
+ - @cappa/core@0.2.1
10
+ - @cappa/logger@0.0.4
11
+
12
+ ## 0.2.0
13
+
14
+ ### Minor Changes
15
+
16
+ - 5b1f66f: Add support for capturing screenshot variants and configure Storybook stories to request multiple viewport screenshots.
17
+ - 4cd0ee2: Allow configuring Storybook args and globals for captured screenshots.
18
+
19
+ ### Patch Changes
20
+
21
+ - a1d91c6: feat: add viewport options
22
+ - Updated dependencies [5b1f66f]
23
+ - Updated dependencies [87c8ab9]
24
+ - Updated dependencies [a1d91c6]
25
+ - Updated dependencies [88b3648]
26
+ - @cappa/core@0.2.0
27
+
3
28
  ## 0.1.3
4
29
 
5
30
  ### Patch Changes
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tim Richter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,94 +2,4 @@
2
2
 
3
3
  This plugin allows to take screenshots of Storybook stories with Cappa.
4
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
- | fullPage | Whether to take a full page screenshot | true |
53
- | mask | An array of selectors to mask in the screenshot | [] |
54
- | omitBackground | Whether to omit the background in the screenshot | false |
55
-
56
- #### Example
57
-
58
- ```ts
59
- export const Primary: Story = {
60
- parameters: {
61
- cappa: {
62
- skip: true,
63
- delay: 1000,
64
- fullPage: false,
65
- mask: ["#my-element", ".my-class"],
66
- },
67
- },
68
- };
69
- ```
70
-
71
- ## Flakiness
72
-
73
- 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`):
74
-
75
- ```ts
76
- import { isCappa } from '@cappa/plugin-storybook/browser';
77
-
78
- if (isCappa()) {
79
- import("disable-animations.css");
80
- MotionGlobalConfig.disableAnimations = true;
81
- }
82
- ```
83
-
84
- ### DOM Mutations
85
-
86
- Cappa waits for DOM mutations to be idle before taking the screenshot. It does so by querying the DOM for mutations and waiting for a certain amount of time to pass, until the page is considered idle.
87
-
88
- ### Fonts & Images
89
-
90
- Cappa waits for fonts and images to be loaded before taking the screenshot.
91
-
92
- ### SVG's
93
-
94
- Cappa sets global css styles to render svg images more consistently. You might experience
95
- differences between actual browsers and cappa screenshots, but that is expected and wanted behavior, since browsers tend to render svg images differently.
5
+ For documentation, see the [Storybook Plugin documentation](https://tim-richter.github.io/cappa/storybook).
package/dist/index.d.mts CHANGED
@@ -1,5 +1,35 @@
1
1
  import { Plugin } from '@cappa/core';
2
2
 
3
+ interface StorybookRenderOptions {
4
+ viewMode?: "story" | "docs";
5
+ args?: Record<string, unknown>;
6
+ globals?: Record<string, string | number | boolean>;
7
+ query?: Record<string, string | number | boolean>;
8
+ fullscreen?: boolean;
9
+ singleStory?: boolean;
10
+ }
11
+ interface ScreenshotVariantOverrideStorybook {
12
+ fullPage?: boolean;
13
+ delay?: number;
14
+ skip?: boolean;
15
+ mask?: string[];
16
+ omitBackground?: boolean;
17
+ viewport?: {
18
+ width: number;
19
+ height: number;
20
+ };
21
+ args?: Record<string, unknown>;
22
+ }
23
+ interface ScreenshotVariantOptionsStorybook {
24
+ id: string;
25
+ label?: string;
26
+ filename?: string;
27
+ options?: ScreenshotVariantOverrideStorybook;
28
+ }
29
+ interface ScreenshotOptionsStorybook extends ScreenshotVariantOverrideStorybook {
30
+ variants?: ScreenshotVariantOptionsStorybook[];
31
+ }
32
+
3
33
  interface StorybookPluginOptions {
4
34
  storybookUrl: string;
5
35
  includeStories?: string[];
@@ -10,6 +40,7 @@ interface StorybookPluginOptions {
10
40
  };
11
41
  waitForSelector?: string;
12
42
  waitForTimeout?: number;
43
+ storybook?: StorybookRenderOptions;
13
44
  }
14
45
  /**
15
46
  * Storybook Plugin for Cappa
@@ -19,4 +50,4 @@ declare const cappaPluginStorybook: Plugin<StorybookPluginOptions>;
19
50
 
20
51
  declare const previewAnnotations: string[];
21
52
 
22
- export { cappaPluginStorybook, previewAnnotations };
53
+ export { type ScreenshotOptionsStorybook as CappaStorybookOptions, cappaPluginStorybook, previewAnnotations };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,35 @@
1
1
  import { Plugin } from '@cappa/core';
2
2
 
3
+ interface StorybookRenderOptions {
4
+ viewMode?: "story" | "docs";
5
+ args?: Record<string, unknown>;
6
+ globals?: Record<string, string | number | boolean>;
7
+ query?: Record<string, string | number | boolean>;
8
+ fullscreen?: boolean;
9
+ singleStory?: boolean;
10
+ }
11
+ interface ScreenshotVariantOverrideStorybook {
12
+ fullPage?: boolean;
13
+ delay?: number;
14
+ skip?: boolean;
15
+ mask?: string[];
16
+ omitBackground?: boolean;
17
+ viewport?: {
18
+ width: number;
19
+ height: number;
20
+ };
21
+ args?: Record<string, unknown>;
22
+ }
23
+ interface ScreenshotVariantOptionsStorybook {
24
+ id: string;
25
+ label?: string;
26
+ filename?: string;
27
+ options?: ScreenshotVariantOverrideStorybook;
28
+ }
29
+ interface ScreenshotOptionsStorybook extends ScreenshotVariantOverrideStorybook {
30
+ variants?: ScreenshotVariantOptionsStorybook[];
31
+ }
32
+
3
33
  interface StorybookPluginOptions {
4
34
  storybookUrl: string;
5
35
  includeStories?: string[];
@@ -10,6 +40,7 @@ interface StorybookPluginOptions {
10
40
  };
11
41
  waitForSelector?: string;
12
42
  waitForTimeout?: number;
43
+ storybook?: StorybookRenderOptions;
13
44
  }
14
45
  /**
15
46
  * Storybook Plugin for Cappa
@@ -19,4 +50,4 @@ declare const cappaPluginStorybook: Plugin<StorybookPluginOptions>;
19
50
 
20
51
  declare const previewAnnotations: string[];
21
52
 
22
- export { cappaPluginStorybook, previewAnnotations };
53
+ export { type ScreenshotOptionsStorybook as CappaStorybookOptions, cappaPluginStorybook, previewAnnotations };