@xyd-js/storybook 0.0.1-xyd.4 → 0.0.1-xyd.51
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/.storybook/main.ts +172 -4
- package/.storybook/preview.ts +1 -2
- package/.storybook/styles.css +0 -5
- package/CHANGELOG.md +527 -0
- package/LICENSE +21 -0
- package/package.json +14 -10
- package/src/__fixtures__/atlas-index/package-index.mdx +194 -0
- package/src/__fixtures__/atlas-index/wip1.mdx +131 -0
- package/src/__fixtures__/atlas-index.mdx +53 -0
- package/src/__fixtures__/example-source-uniform.ts +41 -0
- package/src/{content → __fixtures__}/hello-world.mdx +1 -1
- package/src/components/DemoDocs.tsx +237 -0
- package/src/components/logo.tsx +37 -0
- package/src/decorators/DocsTemplate.tsx +23 -0
- package/src/docs/atlas/Atlas.stories.tsx +30 -26
- package/src/docs/components/coder/CodeSample.stories.tsx +6 -3
- package/src/docs/components/writer/Badge.stories.tsx +15 -40
- package/src/docs/components/writer/GuideCard.stories.tsx +2 -3
- package/src/docs/components/writer/Table.stories.tsx +23 -27
- package/src/docs/components/writer/Tabs.stories.tsx +55 -0
- package/src/docs/components/writer/TocCard.stories.tsx +30 -0
- package/src/docs/components/writer/UnderlineNav.stories.tsx +114 -0
- package/src/docs/components/writer/Update.stories.tsx +91 -0
- package/src/docs/components/writer/VideoGuide.stories.tsx +17 -0
- package/src/docs/themes/TODO.md +1 -0
- package/src/docs/themes/themes-designsystem.stories.tsx +3 -2
- package/src/docs/themes/themes.stories.tsx +33 -26
- package/src/docs/ui/Sidebar.stories.tsx +8 -2
- package/storybook-static/assets/Atlas.stories-DsQbLsBO.js +153 -0
- package/storybook-static/assets/Badge.stories-BB25VaXB.js +6 -0
- package/storybook-static/assets/Breadcrumbs.stories-8dY-0FZ6.js +21 -0
- package/storybook-static/assets/{Button.stories-BXyfQD_l.js → Button.stories-Ct9tcWxH.js} +1 -1
- package/storybook-static/assets/CTABanner-SOi-EjNb-1gNhmGHe.js +4 -0
- package/storybook-static/assets/{CTABanner.stories-CboCyNul.js → CTABanner.stories-B5jWAOv9.js} +1 -1
- package/storybook-static/assets/Callout.stories-DYh3dp1V.js +16 -0
- package/storybook-static/assets/CodeSample.stories-DdqAV6pE.js +22 -0
- package/storybook-static/assets/{CodeSample.stories-npLtCIKw.js → CodeSample.stories-R6WeHzql.js} +1 -1
- package/storybook-static/assets/Color-YHDXOIA2-BLLMp-rk.js +1 -0
- package/storybook-static/assets/DocsRenderer-CFRXHY34-iREIpqZs.js +575 -0
- package/storybook-static/assets/{GuideCard.stories-D_PCT7Jx.js → GuideCard.stories-DlOupG-0.js} +2 -2
- package/storybook-static/assets/Heading.stories-CTPUxGQU.js +40 -0
- package/storybook-static/assets/Icons-CaV53C2x.js +1 -0
- package/storybook-static/assets/Nav.stories-DOdsEXEe.js +13 -0
- package/storybook-static/assets/NavLinks.stories-ChboVW3X.js +19 -0
- package/storybook-static/assets/Pre.stories-BiOV0Oe6.js +11 -0
- package/storybook-static/assets/Sidebar.stories-DkscgzB6.js +9 -0
- package/storybook-static/assets/Steps.stories-DdgI2muz.js +16 -0
- package/storybook-static/assets/SubNav.stories-gbx99ZSe.js +19 -0
- package/storybook-static/assets/Table.stories-_JY94lJp.js +38 -0
- package/storybook-static/assets/Tabs.stories-C91xYkjj.js +42 -0
- package/storybook-static/assets/TocCard.stories-3Hrq8ntN.js +7 -0
- package/storybook-static/assets/UnderlineNav.stories-D44nShoc.js +96 -0
- package/storybook-static/assets/Update-DvGnbDKn-BxY7KlqE.js +33 -0
- package/storybook-static/assets/Update.stories-DXMAnZ21.js +56 -0
- package/storybook-static/assets/VideoGuide.stories-w76_6bQA.js +3 -0
- package/storybook-static/assets/__vite-browser-external-FmFgRqLi.js +1 -0
- package/storybook-static/assets/_rollupPluginBabelHelpers-DK3gn7J7-CY8sTQTJ.js +4 -0
- package/storybook-static/assets/{browser.esm-CjKZlQaR.js → browser.esm-BBxEv_2n.js} +1 -1
- package/storybook-static/assets/chunk-NL6KNZEE-BC1iDMSp.js +3 -0
- package/storybook-static/assets/content-Cgm3P2iF.js +8 -0
- package/storybook-static/assets/entry-preview-XrF1hMc_.js +2 -0
- package/storybook-static/assets/{entry-preview-docs-B1zb5AAd.js → entry-preview-docs-CxQPtM_Y.js} +1 -1
- package/storybook-static/assets/iframe-B8sZbN7f.js +211 -0
- package/storybook-static/assets/{index-Ci6h_Amb.js → index-Bd6o6BX5.js} +2 -2
- package/storybook-static/assets/index-BsiG4v0x.js +3 -0
- package/storybook-static/assets/index-CXQShRbs.js +8 -0
- package/storybook-static/assets/index-CXwkSlW-.js +1 -0
- package/storybook-static/assets/index-CzKwSnp0.js +9 -0
- package/storybook-static/assets/index-D_kTjGoR.js +9 -0
- package/storybook-static/assets/index-DgnBCu_c.js +1 -0
- package/storybook-static/assets/{index-BxVt_j7t.js → index-H0MBf5rE.js} +1 -1
- package/storybook-static/assets/jsx-runtime-D_zvdyIk.js +9 -0
- package/storybook-static/assets/layouts-Bfh4ZDPm.js +1 -0
- package/storybook-static/assets/preview-CoBvlzsX.css +1 -0
- package/storybook-static/assets/preview-CxgX81oj.js +2 -0
- package/storybook-static/assets/{preview-ik5anPOD.js → preview-N1j9pG9L.js} +1 -1
- package/storybook-static/assets/react-18-Tf4JhPOR.js +25 -0
- package/storybook-static/assets/test-utils-BaXAOqRT.js +9 -0
- package/storybook-static/assets/themes-designsystem.stories-Do8f936h.js +11 -0
- package/storybook-static/assets/themes.stories-By9PFakX.js +41 -0
- package/storybook-static/assets/writer-ia0ggDZA.js +1 -0
- package/storybook-static/iframe.html +1 -1
- package/storybook-static/index.html +1 -1
- package/storybook-static/index.json +1 -1
- package/storybook-static/project.json +1 -1
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js +15 -15
- package/storybook-static/sb-addons/docs-12/manager-bundle.js +34 -34
- package/storybook-static/sb-addons/essentials-actions-4/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-backgrounds-5/manager-bundle.js +8 -8
- package/storybook-static/sb-addons/essentials-controls-3/manager-bundle.js +8 -8
- package/storybook-static/sb-addons/essentials-measure-8/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-outline-9/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-toolbars-7/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-viewport-6/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/interactions-11/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/links-2/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/onboarding-1/manager-bundle.js +5 -5
- package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +1 -1
- package/storybook-static/sb-manager/globals-module-info.js +1 -0
- package/storybook-static/sb-manager/globals-runtime.js +10372 -9836
- package/storybook-static/sb-manager/runtime.js +119 -119
- package/tsconfig.json +33 -11
- package/vite.config.ts +1 -1
- package/storybook-static/assets/Atlas.stories-C5gRCegi.js +0 -255
- package/storybook-static/assets/Badge.stories-XOQv4P0k.js +0 -31
- package/storybook-static/assets/Breadcrumbs.stories-DBonCt0B.js +0 -21
- package/storybook-static/assets/CTABanner-Dxjlb-Oo-D4ZzKv-X.js +0 -4
- package/storybook-static/assets/Callout.stories-1M6sBDsc.js +0 -16
- package/storybook-static/assets/CodeSample.stories-ygE0LGuD.js +0 -22
- package/storybook-static/assets/Color-YHDXOIA2-DKdobiDN.js +0 -1
- package/storybook-static/assets/DocsRenderer-CFRXHY34-Bal2bsPI.js +0 -575
- package/storybook-static/assets/Heading.stories-IvodKnYL.js +0 -40
- package/storybook-static/assets/Nav.stories-DpHSEq4D.js +0 -13
- package/storybook-static/assets/NavLinks.stories--GLnE3VD.js +0 -19
- package/storybook-static/assets/Pre.stories-D5iLAJJ5.js +0 -11
- package/storybook-static/assets/Sidebar.stories-Ck4U5ocr.js +0 -9
- package/storybook-static/assets/Steps.stories-DJGuK21z.js +0 -16
- package/storybook-static/assets/SubNav.stories-C6zqzDri.js +0 -19
- package/storybook-static/assets/Table.stories-zUHxRyRv.js +0 -43
- package/storybook-static/assets/UnderlineNav-yn8_whBd-Bbi7p2g-.js +0 -41
- package/storybook-static/assets/_rollupPluginBabelHelpers-Dh5BmVB--DyHbsKhl.js +0 -4
- package/storybook-static/assets/chevron-right-B9VhLASW.js +0 -31
- package/storybook-static/assets/chunk-K6AXKMTT-BnQROexa.js +0 -12
- package/storybook-static/assets/content-BSQS1YU1.js +0 -8
- package/storybook-static/assets/entry-preview-BTiD55pK.js +0 -2
- package/storybook-static/assets/iframe-VEPF5FFi.js +0 -211
- package/storybook-static/assets/index-0nua7n0t.js +0 -1
- package/storybook-static/assets/index-B7gF9TUu.js +0 -9
- package/storybook-static/assets/index-C2_NlWRN.js +0 -8
- package/storybook-static/assets/index-D1ZprCIH.js +0 -9
- package/storybook-static/assets/index-UoN3NoLW.js +0 -17
- package/storybook-static/assets/jsx-runtime-BjG_zV1W.js +0 -9
- package/storybook-static/assets/layouts-DvpaRV78.js +0 -32
- package/storybook-static/assets/preview-BK56XEt8.js +0 -2
- package/storybook-static/assets/preview-EtXI0_34.css +0 -1
- package/storybook-static/assets/react-18-BsB9_d4u.js +0 -25
- package/storybook-static/assets/test-utils-CHVDXiZU.js +0 -9
- package/storybook-static/assets/themes-designsystem.stories-D43FSrQO.js +0 -11
- package/storybook-static/assets/themes.stories-CNT0emaP.js +0 -41
- package/storybook-static/assets/writer-BNuXwA0f.js +0 -4
- package/tsconfig.app.json +0 -24
- package/tsconfig.node.json +0 -13
- /package/src/{content → __fixtures__}/Icons.tsx +0 -0
- /package/src/{content → __fixtures__}/code-sample.mdx +0 -0
- /package/storybook-static/assets/{preview-BOIWi3FM.js → preview-BNQ06L9w.js} +0 -0
package/.storybook/main.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import {join, dirname} from "path";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
1
4
|
import type {StorybookConfig} from "@storybook/react-vite";
|
|
2
5
|
import remarkGfm from 'remark-gfm';
|
|
6
|
+
import remarkDirective from 'remark-directive';
|
|
3
7
|
import {visit} from 'unist-util-visit';
|
|
4
|
-
|
|
5
|
-
import
|
|
8
|
+
import {unified} from 'unified';
|
|
9
|
+
import remarkParse from 'remark-parse';
|
|
10
|
+
import remarkMdx from 'remark-mdx';
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* This function is used to resolve the absolute path of a package.
|
|
@@ -26,6 +31,166 @@ function remarkInjectMeta() { // TODO: move to @xyd-js/content
|
|
|
26
31
|
};
|
|
27
32
|
}
|
|
28
33
|
|
|
34
|
+
export function mdCodeGroup() {
|
|
35
|
+
return (tree: any) => {
|
|
36
|
+
visit(tree, 'containerDirective', (node) => {
|
|
37
|
+
if (node.name !== 'code-group') return;
|
|
38
|
+
|
|
39
|
+
const description = node.attributes?.title || '';
|
|
40
|
+
const codeblocks = [];
|
|
41
|
+
|
|
42
|
+
for (const child of node.children) {
|
|
43
|
+
if (child.type === 'code') {
|
|
44
|
+
const meta = child.meta || '';
|
|
45
|
+
const value = child.value || '';
|
|
46
|
+
const lang = child.lang || '';
|
|
47
|
+
|
|
48
|
+
codeblocks.push({value, lang, meta});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Add metadata to the node
|
|
53
|
+
node.data = {
|
|
54
|
+
hName: 'DirectiveCodeSample',
|
|
55
|
+
hProperties: {
|
|
56
|
+
description,
|
|
57
|
+
codeblocks: JSON.stringify(codeblocks),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
node.children = [];
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function toPascalCase(str) {
|
|
67
|
+
return str
|
|
68
|
+
.replace(/([a-z])([A-Z])/g, "$1 $2") // Add space before capital letters
|
|
69
|
+
.replace(/[^a-zA-Z0-9]/g, " ") // Replace special characters with space
|
|
70
|
+
.split(" ") // Split by space
|
|
71
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) // Capitalize first letter
|
|
72
|
+
.join("");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
const supportedDirectives = {
|
|
77
|
+
Details: true,
|
|
78
|
+
details: true,
|
|
79
|
+
Table: true
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const tableComponents: { [key: string]: boolean } = {
|
|
83
|
+
Table: true
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const parseMarkdown = (content: string) => {
|
|
87
|
+
const ast = unified()
|
|
88
|
+
.use(remarkParse)
|
|
89
|
+
.use(remarkMdx)
|
|
90
|
+
.parse(content);
|
|
91
|
+
return ast.children;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export function remarkDirectiveWithMarkdown() {
|
|
95
|
+
return (tree) => {
|
|
96
|
+
visit(tree, 'containerDirective', (node) => {
|
|
97
|
+
if (!supportedDirectives[node.name]) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const isTable = tableComponents[node.name];
|
|
102
|
+
const attributes = [];
|
|
103
|
+
|
|
104
|
+
// TODO: MORE GENERIC CUZ IT HAS IMPL DETAILS OF TABLE
|
|
105
|
+
if (isTable) {
|
|
106
|
+
// TODO: support tsx tables like: [<>`Promise<Reference[]>`</>] ?
|
|
107
|
+
const tableData = JSON.parse(node.children[0].value);
|
|
108
|
+
const [header, ...rows] = tableData;
|
|
109
|
+
|
|
110
|
+
const jsxNode = {
|
|
111
|
+
type: 'mdxJsxFlowElement',
|
|
112
|
+
name: 'Table',
|
|
113
|
+
attributes: [],
|
|
114
|
+
children: [
|
|
115
|
+
{
|
|
116
|
+
type: 'mdxJsxFlowElement',
|
|
117
|
+
name: 'Table.Head',
|
|
118
|
+
attributes: [],
|
|
119
|
+
children: [
|
|
120
|
+
{
|
|
121
|
+
type: 'mdxJsxFlowElement',
|
|
122
|
+
name: 'Table.Tr',
|
|
123
|
+
attributes: [],
|
|
124
|
+
children: header.map((cell: string) => ({
|
|
125
|
+
type: 'mdxJsxFlowElement',
|
|
126
|
+
name: 'Table.Th',
|
|
127
|
+
attributes: [],
|
|
128
|
+
children: parseMarkdown(cell)
|
|
129
|
+
}))
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
...rows.map((row: string[]) => ({
|
|
134
|
+
type: 'mdxJsxFlowElement',
|
|
135
|
+
name: 'Table.Tr',
|
|
136
|
+
attributes: [],
|
|
137
|
+
children: row.map((cell: string) => ({
|
|
138
|
+
type: 'mdxJsxFlowElement',
|
|
139
|
+
name: 'Table.Td',
|
|
140
|
+
attributes: [],
|
|
141
|
+
children: parseMarkdown(cell)
|
|
142
|
+
}))
|
|
143
|
+
}))
|
|
144
|
+
]
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
Object.assign(node, jsxNode);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (node.attributes) {
|
|
152
|
+
const jsxProps = []
|
|
153
|
+
|
|
154
|
+
for (let [key, value] of Object.entries(node.attributes)) {
|
|
155
|
+
if (typeof value === "string" && !value.startsWith("<")) {
|
|
156
|
+
attributes.push({
|
|
157
|
+
type: 'mdxJsxAttribute',
|
|
158
|
+
name: key,
|
|
159
|
+
value: value
|
|
160
|
+
});
|
|
161
|
+
} else {
|
|
162
|
+
jsxProps.push(`${key}={${value}}`)
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const mdxString = `<Fragment ${jsxProps.join(" ")}></Fragment>`
|
|
168
|
+
|
|
169
|
+
const ast = unified()
|
|
170
|
+
.use(remarkParse)
|
|
171
|
+
.use(remarkMdx)
|
|
172
|
+
.parse(mdxString);
|
|
173
|
+
|
|
174
|
+
if (ast && ast.children[0] && ast.children[0].attributes) {
|
|
175
|
+
for (const attr of ast.children[0].attributes) {
|
|
176
|
+
// TODO: support markdown also e.g Hello `World` - currently it mus be: Hello <code>World</code>
|
|
177
|
+
attributes.push(attr);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const jsxNode = {
|
|
183
|
+
type: 'mdxJsxFlowElement',
|
|
184
|
+
name: toPascalCase(node.name),
|
|
185
|
+
attributes: attributes,
|
|
186
|
+
children: node.children
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
Object.assign(node, jsxNode);
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
29
194
|
const config: StorybookConfig = {
|
|
30
195
|
stories: ["../src/docs/**/*.mdx", "../src/docs/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
|
|
31
196
|
addons: [
|
|
@@ -41,8 +206,11 @@ const config: StorybookConfig = {
|
|
|
41
206
|
mdxCompileOptions: {
|
|
42
207
|
remarkPlugins: [
|
|
43
208
|
remarkGfm,
|
|
44
|
-
|
|
45
|
-
|
|
209
|
+
remarkDirective,
|
|
210
|
+
mdCodeGroup,
|
|
211
|
+
remarkDirectiveWithMarkdown,
|
|
212
|
+
// mdComponentDirective
|
|
213
|
+
]
|
|
46
214
|
},
|
|
47
215
|
},
|
|
48
216
|
},
|
package/.storybook/preview.ts
CHANGED