@repobuddy/storybook 0.13.0 → 0.14.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.
- package/esm/components/show_html.d.ts +16 -0
- package/esm/components/show_html.js +28 -0
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/package.json +3 -2
- package/readme.md +14 -12
- package/src/components/show_html.tsx +36 -0
- package/src/index.ts +2 -1
- /package/esm/{decorators → testing/decorators}/when_running_in_test.d.ts +0 -0
- /package/esm/{decorators → testing/decorators}/when_running_in_test.js +0 -0
- /package/esm/{decorators → testing/decorators}/when_running_in_text.ctx.d.ts +0 -0
- /package/esm/{decorators → testing/decorators}/when_running_in_text.ctx.js +0 -0
- /package/src/{decorators → testing/decorators}/when_running_in_test.tsx +0 -0
- /package/src/{decorators → testing/decorators}/when_running_in_text.ctx.ts +0 -0
|
@@ -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";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repobuddy/storybook",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.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
|
-
- ✏️
|
|
68
|
-
- 🆕 New components/features
|
|
69
|
-
- 🅱️ Beta status
|
|
70
|
-
- 🪦 Deprecated notices
|
|
71
|
-
- ⚠️ Outdated warnings
|
|
72
|
-
- 🚨 Dangerous
|
|
73
|
-
- 📋 To-do items
|
|
74
|
-
- 📝 Code-only stories
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
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
|
-
|
|
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'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|