@repobuddy/storybook 0.13.0 → 0.15.0

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.
@@ -0,0 +1,16 @@
1
+ import type { ClassNameProps, StyleProps } from '@just-web/css';
2
+ import { type UserConfig } from 'htmlfy';
3
+ export type ShowHtmlProps = ClassNameProps & StyleProps & {
4
+ selector?: string | undefined;
5
+ config?: UserConfig | undefined;
6
+ };
7
+ /**
8
+ * A component that displays the HTML of a subject element.
9
+ * Uses `htmlfy` internally to format and prettify the HTML output.
10
+ *
11
+ * @param selector - CSS selector to find the subject element. Defaults to '[data-testid="subject"]'
12
+ * @param config - Configuration options passed to htmlfy's prettify function
13
+ * @param props - Additional props (className, style) passed to the pre element
14
+ * @returns A pre element containing the formatted HTML
15
+ */
16
+ export declare function ShowHtml({ selector, config, ...props }: ShowHtmlProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { prettify } from 'htmlfy';
3
+ import { useEffect, useState } from 'react';
4
+ /**
5
+ * A component that displays the HTML of a subject element.
6
+ * Uses `htmlfy` internally to format and prettify the HTML output.
7
+ *
8
+ * @param selector - CSS selector to find the subject element. Defaults to '[data-testid="subject"]'
9
+ * @param config - Configuration options passed to htmlfy's prettify function
10
+ * @param props - Additional props (className, style) passed to the pre element
11
+ * @returns A pre element containing the formatted HTML
12
+ */
13
+ export function ShowHtml({ selector = '[data-testid="subject"]', config, ...props }) {
14
+ const [html, setHtml] = useState('');
15
+ useEffect(() => {
16
+ const subject = document.querySelector(selector);
17
+ if (subject) {
18
+ setHtml(prettify(subject.outerHTML, {
19
+ tag_wrap: 40,
20
+ ...config
21
+ }));
22
+ }
23
+ else {
24
+ setHtml('No subject found');
25
+ }
26
+ }, [selector]);
27
+ return _jsx("pre", { ...props, children: html });
28
+ }
package/esm/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from '@repobuddy/test';
2
+ export * from './components/show_html.tsx';
2
3
  export * from './decorators/show_doc_source.tsx';
3
- export * from './decorators/when_running_in_test.tsx';
4
4
  export * from './parameters/define_actions_param.ts';
5
5
  export * from './parameters/define_backgrounds_param.ts';
6
6
  export * from './parameters/define_docs_param.ts';
@@ -9,3 +9,4 @@ export * from './parameters/define_parameters.ts';
9
9
  export * from './parameters/define_test_param.ts';
10
10
  export * from './parameters/define_viewport_param.ts';
11
11
  export * from './parameters/story_sort.ts';
12
+ export * from './testing/decorators/when_running_in_test.tsx';
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from '@repobuddy/test';
2
+ export * from "./components/show_html.js";
2
3
  export * from "./decorators/show_doc_source.js";
3
- export * from "./decorators/when_running_in_test.js";
4
4
  export * from "./parameters/define_actions_param.js";
5
5
  export * from "./parameters/define_backgrounds_param.js";
6
6
  export * from "./parameters/define_docs_param.js";
@@ -9,3 +9,4 @@ export * from "./parameters/define_parameters.js";
9
9
  export * from "./parameters/define_test_param.js";
10
10
  export * from "./parameters/define_viewport_param.js";
11
11
  export * from "./parameters/story_sort.js";
12
+ export * from "./testing/decorators/when_running_in_test.js";
@@ -31,6 +31,7 @@ export declare const codeOnlyBadge: TagBadgeParameter;
31
31
  export declare const snapshotBadge: TagBadgeParameter;
32
32
  export declare const unitBadge: TagBadgeParameter;
33
33
  export declare const integrationBadge: TagBadgeParameter;
34
+ export declare const keyboardBadge: TagBadgeParameter;
34
35
  export declare const internalBadge: TagBadgeParameter;
35
36
  export declare const tagBadges: TagBadgeParameters;
36
37
  export {};
@@ -141,6 +141,15 @@ export const integrationBadge = {
141
141
  sidebar: false
142
142
  }
143
143
  };
144
+ export const keyboardBadge = {
145
+ tags: 'keyboard',
146
+ badge: {
147
+ text: '⌨️',
148
+ bgColor: 'transparent',
149
+ borderColor: 'transparent',
150
+ tooltip: 'Keyboard Interaction'
151
+ }
152
+ };
144
153
  export const internalBadge = {
145
154
  tags: 'internal',
146
155
  badge: {
@@ -154,6 +163,7 @@ export const tagBadges = [
154
163
  editorBadge,
155
164
  unitBadge,
156
165
  integrationBadge,
166
+ keyboardBadge,
157
167
  newBadge,
158
168
  betaBadge,
159
169
  deprecatedBadge,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repobuddy/storybook",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "Storybook repo buddy",
5
5
  "keywords": [
6
6
  "storybook",
@@ -43,7 +43,8 @@
43
43
  ],
44
44
  "dependencies": {
45
45
  "@just-web/css": "^0.5.0",
46
- "@repobuddy/test": "^1.0.0"
46
+ "@repobuddy/test": "^1.0.0",
47
+ "htmlfy": "^0.7.5"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@repobuddy/vitest": "^1.2.2",
package/readme.md CHANGED
@@ -64,17 +64,18 @@ addons.setConfig({
64
64
  If you use [`storybook-addon-tag-badges`][`storybook-addon-tag-badges`],
65
65
  we provide a different set of badges that uses emojis:
66
66
 
67
- - ✏️ Editor - Stories with live editor
68
- - 🆕 New components/features
69
- - 🅱️ Beta status
70
- - 🪦 Deprecated notices
71
- - ⚠️ Outdated warnings
72
- - 🚨 Dangerous
73
- - 📋 To-do items
74
- - 📝 Code-only stories
75
- - 📸 Snapshot tests
76
- - 🧪 Unit tests
77
- - 🔗 Integration tests
67
+ - ✏️ `editor` - Live Editor Stories (with [`storybook-addon-code-editor`][`storybook-addon-code-editor`])
68
+ - 🆕 `new` - New components/features
69
+ - 🅱️ `beta` - Beta status
70
+ - 🪦 `deprecated` - Deprecated notices
71
+ - ⚠️ `outdated` - Outdated warnings
72
+ - 🚨 `danger` - Dangerous
73
+ - 📋 `todo` - To-do items
74
+ - 📝 `code-only` - Code-only stories
75
+ - 🔒 `internal` - Internal stories (when set up, hidden from the sidebar in public Storybook)
76
+ - 📸 `snapshot` - Snapshot tests
77
+ - 🧪 `unit` - Unit tests
78
+ - 🔗 `integration` - Integration tests
78
79
  - Version indicators (unchanged)
79
80
 
80
81
  To use them, add them to your `.storybook/manager.ts`:
@@ -110,7 +111,7 @@ import {
110
111
  export const preview: Preview = {
111
112
  parameters: {
112
113
  docs: {
113
- container: createDarkModeDocsContainer()
114
+ container: createDarkModeDocsContainer()
114
115
  },
115
116
  darkMode: defineDarkModeParam({
116
117
  classTarget: 'html',
@@ -127,3 +128,4 @@ export const preview: Preview = {
127
128
  [`@repobuddy/storybook`]: https://github.com/repobuddy/storybook
128
129
  [`storybook-addon-tag-badges`]: https://github.com/Sidnioulz/storybook-addon-tag-badges
129
130
  [`storybook-dark-mode`]: https://github.com/hipstersmoothie/storybook-dark-mode
131
+ [`storybook-addon-code-editor`]: https://github.com/storybookjs/storybook/tree/main/addons/code/code-editor
@@ -0,0 +1,36 @@
1
+ import type { ClassNameProps, StyleProps } from '@just-web/css'
2
+ import { prettify, type UserConfig } from 'htmlfy'
3
+ import { useEffect, useState } from 'react'
4
+
5
+ export type ShowHtmlProps = ClassNameProps &
6
+ StyleProps & {
7
+ selector?: string | undefined
8
+ config?: UserConfig | undefined
9
+ }
10
+
11
+ /**
12
+ * A component that displays the HTML of a subject element.
13
+ * Uses `htmlfy` internally to format and prettify the HTML output.
14
+ *
15
+ * @param selector - CSS selector to find the subject element. Defaults to '[data-testid="subject"]'
16
+ * @param config - Configuration options passed to htmlfy's prettify function
17
+ * @param props - Additional props (className, style) passed to the pre element
18
+ * @returns A pre element containing the formatted HTML
19
+ */
20
+ export function ShowHtml({ selector = '[data-testid="subject"]', config, ...props }: ShowHtmlProps) {
21
+ const [html, setHtml] = useState('')
22
+ useEffect(() => {
23
+ const subject = document.querySelector(selector)
24
+ if (subject) {
25
+ setHtml(
26
+ prettify(subject.outerHTML, {
27
+ tag_wrap: 40,
28
+ ...config
29
+ })
30
+ )
31
+ } else {
32
+ setHtml('No subject found')
33
+ }
34
+ }, [selector])
35
+ return <pre {...props}>{html}</pre>
36
+ }
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from '@repobuddy/test'
2
+ export * from './components/show_html.tsx'
2
3
  export * from './decorators/show_doc_source.tsx'
3
- export * from './decorators/when_running_in_test.tsx'
4
4
  export * from './parameters/define_actions_param.ts'
5
5
  export * from './parameters/define_backgrounds_param.ts'
6
6
  export * from './parameters/define_docs_param.ts'
@@ -9,3 +9,4 @@ export * from './parameters/define_parameters.ts'
9
9
  export * from './parameters/define_test_param.ts'
10
10
  export * from './parameters/define_viewport_param.ts'
11
11
  export * from './parameters/story_sort.ts'
12
+ export * from './testing/decorators/when_running_in_test.tsx'
@@ -157,6 +157,16 @@ export const integrationBadge: TagBadgeParameter = {
157
157
  }
158
158
  }
159
159
 
160
+ export const keyboardBadge: TagBadgeParameter = {
161
+ tags: 'keyboard',
162
+ badge: {
163
+ text: '⌨️',
164
+ bgColor: 'transparent',
165
+ borderColor: 'transparent',
166
+ tooltip: 'Keyboard Interaction'
167
+ }
168
+ }
169
+
160
170
  export const internalBadge: TagBadgeParameter = {
161
171
  tags: 'internal',
162
172
  badge: {
@@ -171,6 +181,7 @@ export const tagBadges: TagBadgeParameters = [
171
181
  editorBadge,
172
182
  unitBadge,
173
183
  integrationBadge,
184
+ keyboardBadge,
174
185
  newBadge,
175
186
  betaBadge,
176
187
  deprecatedBadge,