@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.
Files changed (145) hide show
  1. package/.storybook/main.ts +172 -4
  2. package/.storybook/preview.ts +1 -2
  3. package/.storybook/styles.css +0 -5
  4. package/CHANGELOG.md +527 -0
  5. package/LICENSE +21 -0
  6. package/package.json +14 -10
  7. package/src/__fixtures__/atlas-index/package-index.mdx +194 -0
  8. package/src/__fixtures__/atlas-index/wip1.mdx +131 -0
  9. package/src/__fixtures__/atlas-index.mdx +53 -0
  10. package/src/__fixtures__/example-source-uniform.ts +41 -0
  11. package/src/{content → __fixtures__}/hello-world.mdx +1 -1
  12. package/src/components/DemoDocs.tsx +237 -0
  13. package/src/components/logo.tsx +37 -0
  14. package/src/decorators/DocsTemplate.tsx +23 -0
  15. package/src/docs/atlas/Atlas.stories.tsx +30 -26
  16. package/src/docs/components/coder/CodeSample.stories.tsx +6 -3
  17. package/src/docs/components/writer/Badge.stories.tsx +15 -40
  18. package/src/docs/components/writer/GuideCard.stories.tsx +2 -3
  19. package/src/docs/components/writer/Table.stories.tsx +23 -27
  20. package/src/docs/components/writer/Tabs.stories.tsx +55 -0
  21. package/src/docs/components/writer/TocCard.stories.tsx +30 -0
  22. package/src/docs/components/writer/UnderlineNav.stories.tsx +114 -0
  23. package/src/docs/components/writer/Update.stories.tsx +91 -0
  24. package/src/docs/components/writer/VideoGuide.stories.tsx +17 -0
  25. package/src/docs/themes/TODO.md +1 -0
  26. package/src/docs/themes/themes-designsystem.stories.tsx +3 -2
  27. package/src/docs/themes/themes.stories.tsx +33 -26
  28. package/src/docs/ui/Sidebar.stories.tsx +8 -2
  29. package/storybook-static/assets/Atlas.stories-DsQbLsBO.js +153 -0
  30. package/storybook-static/assets/Badge.stories-BB25VaXB.js +6 -0
  31. package/storybook-static/assets/Breadcrumbs.stories-8dY-0FZ6.js +21 -0
  32. package/storybook-static/assets/{Button.stories-BXyfQD_l.js → Button.stories-Ct9tcWxH.js} +1 -1
  33. package/storybook-static/assets/CTABanner-SOi-EjNb-1gNhmGHe.js +4 -0
  34. package/storybook-static/assets/{CTABanner.stories-CboCyNul.js → CTABanner.stories-B5jWAOv9.js} +1 -1
  35. package/storybook-static/assets/Callout.stories-DYh3dp1V.js +16 -0
  36. package/storybook-static/assets/CodeSample.stories-DdqAV6pE.js +22 -0
  37. package/storybook-static/assets/{CodeSample.stories-npLtCIKw.js → CodeSample.stories-R6WeHzql.js} +1 -1
  38. package/storybook-static/assets/Color-YHDXOIA2-BLLMp-rk.js +1 -0
  39. package/storybook-static/assets/DocsRenderer-CFRXHY34-iREIpqZs.js +575 -0
  40. package/storybook-static/assets/{GuideCard.stories-D_PCT7Jx.js → GuideCard.stories-DlOupG-0.js} +2 -2
  41. package/storybook-static/assets/Heading.stories-CTPUxGQU.js +40 -0
  42. package/storybook-static/assets/Icons-CaV53C2x.js +1 -0
  43. package/storybook-static/assets/Nav.stories-DOdsEXEe.js +13 -0
  44. package/storybook-static/assets/NavLinks.stories-ChboVW3X.js +19 -0
  45. package/storybook-static/assets/Pre.stories-BiOV0Oe6.js +11 -0
  46. package/storybook-static/assets/Sidebar.stories-DkscgzB6.js +9 -0
  47. package/storybook-static/assets/Steps.stories-DdgI2muz.js +16 -0
  48. package/storybook-static/assets/SubNav.stories-gbx99ZSe.js +19 -0
  49. package/storybook-static/assets/Table.stories-_JY94lJp.js +38 -0
  50. package/storybook-static/assets/Tabs.stories-C91xYkjj.js +42 -0
  51. package/storybook-static/assets/TocCard.stories-3Hrq8ntN.js +7 -0
  52. package/storybook-static/assets/UnderlineNav.stories-D44nShoc.js +96 -0
  53. package/storybook-static/assets/Update-DvGnbDKn-BxY7KlqE.js +33 -0
  54. package/storybook-static/assets/Update.stories-DXMAnZ21.js +56 -0
  55. package/storybook-static/assets/VideoGuide.stories-w76_6bQA.js +3 -0
  56. package/storybook-static/assets/__vite-browser-external-FmFgRqLi.js +1 -0
  57. package/storybook-static/assets/_rollupPluginBabelHelpers-DK3gn7J7-CY8sTQTJ.js +4 -0
  58. package/storybook-static/assets/{browser.esm-CjKZlQaR.js → browser.esm-BBxEv_2n.js} +1 -1
  59. package/storybook-static/assets/chunk-NL6KNZEE-BC1iDMSp.js +3 -0
  60. package/storybook-static/assets/content-Cgm3P2iF.js +8 -0
  61. package/storybook-static/assets/entry-preview-XrF1hMc_.js +2 -0
  62. package/storybook-static/assets/{entry-preview-docs-B1zb5AAd.js → entry-preview-docs-CxQPtM_Y.js} +1 -1
  63. package/storybook-static/assets/iframe-B8sZbN7f.js +211 -0
  64. package/storybook-static/assets/{index-Ci6h_Amb.js → index-Bd6o6BX5.js} +2 -2
  65. package/storybook-static/assets/index-BsiG4v0x.js +3 -0
  66. package/storybook-static/assets/index-CXQShRbs.js +8 -0
  67. package/storybook-static/assets/index-CXwkSlW-.js +1 -0
  68. package/storybook-static/assets/index-CzKwSnp0.js +9 -0
  69. package/storybook-static/assets/index-D_kTjGoR.js +9 -0
  70. package/storybook-static/assets/index-DgnBCu_c.js +1 -0
  71. package/storybook-static/assets/{index-BxVt_j7t.js → index-H0MBf5rE.js} +1 -1
  72. package/storybook-static/assets/jsx-runtime-D_zvdyIk.js +9 -0
  73. package/storybook-static/assets/layouts-Bfh4ZDPm.js +1 -0
  74. package/storybook-static/assets/preview-CoBvlzsX.css +1 -0
  75. package/storybook-static/assets/preview-CxgX81oj.js +2 -0
  76. package/storybook-static/assets/{preview-ik5anPOD.js → preview-N1j9pG9L.js} +1 -1
  77. package/storybook-static/assets/react-18-Tf4JhPOR.js +25 -0
  78. package/storybook-static/assets/test-utils-BaXAOqRT.js +9 -0
  79. package/storybook-static/assets/themes-designsystem.stories-Do8f936h.js +11 -0
  80. package/storybook-static/assets/themes.stories-By9PFakX.js +41 -0
  81. package/storybook-static/assets/writer-ia0ggDZA.js +1 -0
  82. package/storybook-static/iframe.html +1 -1
  83. package/storybook-static/index.html +1 -1
  84. package/storybook-static/index.json +1 -1
  85. package/storybook-static/project.json +1 -1
  86. package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js +15 -15
  87. package/storybook-static/sb-addons/docs-12/manager-bundle.js +34 -34
  88. package/storybook-static/sb-addons/essentials-actions-4/manager-bundle.js +1 -1
  89. package/storybook-static/sb-addons/essentials-backgrounds-5/manager-bundle.js +8 -8
  90. package/storybook-static/sb-addons/essentials-controls-3/manager-bundle.js +8 -8
  91. package/storybook-static/sb-addons/essentials-measure-8/manager-bundle.js +1 -1
  92. package/storybook-static/sb-addons/essentials-outline-9/manager-bundle.js +1 -1
  93. package/storybook-static/sb-addons/essentials-toolbars-7/manager-bundle.js +1 -1
  94. package/storybook-static/sb-addons/essentials-viewport-6/manager-bundle.js +1 -1
  95. package/storybook-static/sb-addons/interactions-11/manager-bundle.js +1 -1
  96. package/storybook-static/sb-addons/links-2/manager-bundle.js +1 -1
  97. package/storybook-static/sb-addons/onboarding-1/manager-bundle.js +5 -5
  98. package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +1 -1
  99. package/storybook-static/sb-manager/globals-module-info.js +1 -0
  100. package/storybook-static/sb-manager/globals-runtime.js +10372 -9836
  101. package/storybook-static/sb-manager/runtime.js +119 -119
  102. package/tsconfig.json +33 -11
  103. package/vite.config.ts +1 -1
  104. package/storybook-static/assets/Atlas.stories-C5gRCegi.js +0 -255
  105. package/storybook-static/assets/Badge.stories-XOQv4P0k.js +0 -31
  106. package/storybook-static/assets/Breadcrumbs.stories-DBonCt0B.js +0 -21
  107. package/storybook-static/assets/CTABanner-Dxjlb-Oo-D4ZzKv-X.js +0 -4
  108. package/storybook-static/assets/Callout.stories-1M6sBDsc.js +0 -16
  109. package/storybook-static/assets/CodeSample.stories-ygE0LGuD.js +0 -22
  110. package/storybook-static/assets/Color-YHDXOIA2-DKdobiDN.js +0 -1
  111. package/storybook-static/assets/DocsRenderer-CFRXHY34-Bal2bsPI.js +0 -575
  112. package/storybook-static/assets/Heading.stories-IvodKnYL.js +0 -40
  113. package/storybook-static/assets/Nav.stories-DpHSEq4D.js +0 -13
  114. package/storybook-static/assets/NavLinks.stories--GLnE3VD.js +0 -19
  115. package/storybook-static/assets/Pre.stories-D5iLAJJ5.js +0 -11
  116. package/storybook-static/assets/Sidebar.stories-Ck4U5ocr.js +0 -9
  117. package/storybook-static/assets/Steps.stories-DJGuK21z.js +0 -16
  118. package/storybook-static/assets/SubNav.stories-C6zqzDri.js +0 -19
  119. package/storybook-static/assets/Table.stories-zUHxRyRv.js +0 -43
  120. package/storybook-static/assets/UnderlineNav-yn8_whBd-Bbi7p2g-.js +0 -41
  121. package/storybook-static/assets/_rollupPluginBabelHelpers-Dh5BmVB--DyHbsKhl.js +0 -4
  122. package/storybook-static/assets/chevron-right-B9VhLASW.js +0 -31
  123. package/storybook-static/assets/chunk-K6AXKMTT-BnQROexa.js +0 -12
  124. package/storybook-static/assets/content-BSQS1YU1.js +0 -8
  125. package/storybook-static/assets/entry-preview-BTiD55pK.js +0 -2
  126. package/storybook-static/assets/iframe-VEPF5FFi.js +0 -211
  127. package/storybook-static/assets/index-0nua7n0t.js +0 -1
  128. package/storybook-static/assets/index-B7gF9TUu.js +0 -9
  129. package/storybook-static/assets/index-C2_NlWRN.js +0 -8
  130. package/storybook-static/assets/index-D1ZprCIH.js +0 -9
  131. package/storybook-static/assets/index-UoN3NoLW.js +0 -17
  132. package/storybook-static/assets/jsx-runtime-BjG_zV1W.js +0 -9
  133. package/storybook-static/assets/layouts-DvpaRV78.js +0 -32
  134. package/storybook-static/assets/preview-BK56XEt8.js +0 -2
  135. package/storybook-static/assets/preview-EtXI0_34.css +0 -1
  136. package/storybook-static/assets/react-18-BsB9_d4u.js +0 -25
  137. package/storybook-static/assets/test-utils-CHVDXiZU.js +0 -9
  138. package/storybook-static/assets/themes-designsystem.stories-D43FSrQO.js +0 -11
  139. package/storybook-static/assets/themes.stories-CNT0emaP.js +0 -41
  140. package/storybook-static/assets/writer-BNuXwA0f.js +0 -4
  141. package/tsconfig.app.json +0 -24
  142. package/tsconfig.node.json +0 -13
  143. /package/src/{content → __fixtures__}/Icons.tsx +0 -0
  144. /package/src/{content → __fixtures__}/code-sample.mdx +0 -0
  145. /package/storybook-static/assets/{preview-BOIWi3FM.js → preview-BNQ06L9w.js} +0 -0
@@ -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 {join, dirname} from "path";
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
- remarkInjectMeta
45
- ],
209
+ remarkDirective,
210
+ mdCodeGroup,
211
+ remarkDirectiveWithMarkdown,
212
+ // mdComponentDirective
213
+ ]
46
214
  },
47
215
  },
48
216
  },
@@ -1,7 +1,6 @@
1
1
  import type {Preview} from "@storybook/react";
2
2
 
3
- import "@xyd-js/atlas/index.css"
4
- import "@xyd-js/fable-wiki/theme.css"
3
+ import "@xyd-js/theme-poetry/index.css" // TODO: in the future configurable themes via UI?
5
4
 
6
5
  import './styles.css'
7
6
 
@@ -1,5 +0,0 @@
1
- :root {
2
- --headingEffect-color-tertiary: rgba(23, 119, 184, 0.5);
3
- --headingEffect-color-secondary: rgb(121, 85, 241);
4
- --headingEffect-color-primary: rgb(255, 105, 180);
5
- }