@xyd-js/atlas 0.1.0-build.173

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 (68) hide show
  1. package/.babelrc +6 -0
  2. package/.storybook/index.css +6 -0
  3. package/.storybook/main.ts +19 -0
  4. package/.storybook/preview.ts +17 -0
  5. package/.storybook/public/fonts/fustat-ext-500.woff2 +0 -0
  6. package/.storybook/public/fonts/fustat-ext-600.woff2 +0 -0
  7. package/.storybook/public/fonts/fustat-ext-700.woff2 +0 -0
  8. package/.storybook/public/fonts/fustat-regular.woff2 +0 -0
  9. package/CHANGELOG.md +1984 -0
  10. package/LICENSE +21 -0
  11. package/README.md +3 -0
  12. package/declarations.d.ts +4 -0
  13. package/dist/VideoGuide-C0K9fFar-Dk2lkn4r.js +4 -0
  14. package/dist/VideoGuide-C0K9fFar-Dk2lkn4r.js.map +1 -0
  15. package/dist/VideoGuide-CJYkuLst-Dk2lkn4r.js +4 -0
  16. package/dist/VideoGuide-CJYkuLst-Dk2lkn4r.js.map +1 -0
  17. package/dist/index.css +48 -0
  18. package/dist/index.d.ts +38 -0
  19. package/dist/index.js +2 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/styles.css +104 -0
  22. package/dist/tokens.css +60 -0
  23. package/dist/xydPlugin.d.ts +5 -0
  24. package/dist/xydPlugin.js +2 -0
  25. package/dist/xydPlugin.js.map +1 -0
  26. package/index.ts +2 -0
  27. package/package.json +68 -0
  28. package/packages/xyd-plugin/SidebarItem.tsx +27 -0
  29. package/packages/xyd-plugin/index.ts +20 -0
  30. package/postcss.config.cjs +5 -0
  31. package/rollup.config.js +120 -0
  32. package/src/components/ApiRef/ApiRefItem/ApiRefItem.styles.tsx +110 -0
  33. package/src/components/ApiRef/ApiRefItem/ApiRefItem.tsx +557 -0
  34. package/src/components/ApiRef/ApiRefItem/index.ts +7 -0
  35. package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.styles.tsx +202 -0
  36. package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.tsx +665 -0
  37. package/src/components/ApiRef/ApiRefProperties/index.ts +7 -0
  38. package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.styles.tsx +28 -0
  39. package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.tsx +69 -0
  40. package/src/components/ApiRef/ApiRefSamples/index.ts +7 -0
  41. package/src/components/ApiRef/index.ts +5 -0
  42. package/src/components/Atlas/Atlas.styles.tsx +5 -0
  43. package/src/components/Atlas/Atlas.tsx +43 -0
  44. package/src/components/Atlas/AtlasContext.tsx +47 -0
  45. package/src/components/Atlas/AtlasDecorator.styles.ts +22 -0
  46. package/src/components/Atlas/AtlasDecorator.tsx +15 -0
  47. package/src/components/Atlas/AtlasLazy/AtlasLazy.styles.tsx +9 -0
  48. package/src/components/Atlas/AtlasLazy/AtlasLazy.tsx +42 -0
  49. package/src/components/Atlas/AtlasLazy/hooks.ts +29 -0
  50. package/src/components/Atlas/AtlasLazy/index.ts +7 -0
  51. package/src/components/Atlas/AtlasPrimary.tsx +21 -0
  52. package/src/components/Atlas/AtlasSecondary.tsx +148 -0
  53. package/src/components/Atlas/index.ts +7 -0
  54. package/src/components/Atlas/types.ts +11 -0
  55. package/src/components/Code/CodeSampleButtons/CodeSampleButtons.styles.tsx +58 -0
  56. package/src/components/Code/CodeSampleButtons/CodeSampleButtons.tsx +97 -0
  57. package/src/components/Code/CodeSampleButtons/index.ts +7 -0
  58. package/src/components/Code/index.ts +2 -0
  59. package/src/components/Icon/index.tsx +386 -0
  60. package/src/docs/AtlasExample/AtlasExample.stories.tsx +47 -0
  61. package/src/docs/AtlasExample/todo-app.uniform.json +625 -0
  62. package/src/docs/AtlasExample/uniform-to-references.ts +101 -0
  63. package/src/styles/styles.css +104 -0
  64. package/src/styles/tokens.css +60 -0
  65. package/src/utils/mdx.ts +2 -0
  66. package/tsconfig.json +51 -0
  67. package/types.d.ts +22 -0
  68. package/vite.config.ts +25 -0
@@ -0,0 +1,101 @@
1
+ // TODO: move to utils or somewhere else
2
+ import React from "react";
3
+ import {parse} from "codehike";
4
+ import {visit} from "unist-util-visit";
5
+ import {recmaCodeHike, remarkCodeHike} from "codehike/mdx";
6
+ import {compile as mdxCompile} from "@mdx-js/mdx";
7
+
8
+ import {Reference} from "@xyd-js/uniform";
9
+ import {
10
+ compile as compileMarkdown,
11
+ referenceAST
12
+ } from "@xyd-js/uniform/markdown";
13
+
14
+ import {MDXReference} from "@/utils/mdx";
15
+ import todoAppUniform from "./todo-app.uniform.json";
16
+
17
+ // since unist does not support heading level > 6, we need to normalize them
18
+ function normalizeCustomHeadings() {
19
+ return (tree: any) => {
20
+ visit(tree, 'paragraph', (node, index, parent) => {
21
+ const match = node.children[0] && node.children[0].value.match(/^(#+)\s+(.*)/);
22
+ if (match) {
23
+ const level = match[1].length;
24
+ const text = match[2];
25
+ if (level > 6) {
26
+ // Create a new heading node with depth 6
27
+ const headingNode = {
28
+ type: 'heading',
29
+ depth: level,
30
+ children: [{type: 'text', value: text}]
31
+ };
32
+ // Replace the paragraph node with the new heading node
33
+ //@ts-ignore
34
+ parent.children[index] = headingNode;
35
+ }
36
+ }
37
+ });
38
+ };
39
+ }
40
+
41
+ const codeHikeOptions = {
42
+ lineNumbers: true,
43
+ showCopyButton: true,
44
+ autoImport: true,
45
+ components: {code: "Code"},
46
+ // syntaxHighlighting: { // TODO: !!! FROM SETTINGS !!! wait for rr7 rsc ??
47
+ // theme: "github-dark",
48
+ // },
49
+ };
50
+
51
+ async function compile(content: string): Promise<string> {
52
+ const compiled = await mdxCompile(content, {
53
+ remarkPlugins: [normalizeCustomHeadings, [remarkCodeHike, codeHikeOptions]],
54
+ recmaPlugins: [
55
+ [recmaCodeHike, codeHikeOptions]
56
+ ],
57
+ outputFormat: 'function-body',
58
+ development: false,
59
+ });
60
+
61
+ return String(compiled)
62
+ }
63
+
64
+ // TODO: move below to content?
65
+ function getMDXComponent(code: string) {
66
+ const mdxExport = getMDXExport(code)
67
+ return mdxExport.default
68
+ }
69
+
70
+ function getMDXExport(code: string) {
71
+ const scope = {
72
+ Fragment: React.Fragment,
73
+ jsxs: React.createElement,
74
+ jsx: React.createElement,
75
+ jsxDEV: React.createElement,
76
+ }
77
+ const fn = new Function(...Object.keys(scope), code)
78
+ return fn(scope)
79
+ }
80
+
81
+ export async function uniformToReferences(): Promise<MDXReference<Reference[]> | []> {
82
+ let content: string = ""
83
+
84
+ for (const ref of todoAppUniform as Reference[]) {
85
+ const ast = referenceAST(ref)
86
+ const md = compileMarkdown(ast)
87
+
88
+ content += md + "\n"
89
+ }
90
+
91
+ const compiled = await compile(content)
92
+ const contentCode = getMDXComponent(compiled)
93
+
94
+ const parsedContent = contentCode ? parse(contentCode) : null
95
+
96
+ if (parsedContent) {
97
+ return parsedContent.references
98
+ }
99
+
100
+ return []
101
+ }
@@ -0,0 +1,104 @@
1
+ @layer overrides {
2
+ :root {
3
+ --oas-method-get-color: #15803d;
4
+ --oas-method-get-bg: rgba(74, 222, 128, .2);
5
+ --oas-method-get-color--active: var(--white);
6
+ --oas-method-get-bg--active: #2ab673;
7
+
8
+ --oas-method-post-color: #1D4ED8;
9
+ --oas-method-post-bg: rgba(96, 165, 250, .2);
10
+ --oas-method-post-color--active: var(--white);
11
+ --oas-method-post-bg--active: #3064e3;
12
+
13
+ --oas-method-put-color: #C28C30;
14
+ --oas-method-put-bg: rgba(250, 204, 21, .2);
15
+ --oas-method-put-color--active: var(--white);
16
+ --oas-method-put-bg--active: #C28C30;
17
+
18
+ --oas-method-delete-color: #B91C1C;
19
+ --oas-method-delete-bg: rgba(248, 114, 114, 0.2);
20
+ --oas-method-delete-color--active: var(--white);
21
+ --oas-method-delete-bg--active: #cb3a32;
22
+
23
+ --oas-method-patch-color: #c2410c;
24
+ --oas-method-patch-bg: rgba(251, 146, 60, .2);
25
+ --oas-method-patch-color--active: var(--white);
26
+ --oas-method-patch-bg--active: #DA622B;
27
+ }
28
+
29
+ /* HTTP Method Colors */
30
+ [data-atlas-oas-method="GET"] {
31
+ /* --method-color: var(--oas-method-get-color); */
32
+ /* --method-bg: var(--oas-method-get-bg); */
33
+
34
+ --method-color: var(--oas-method-get-color);
35
+ --method-bg: unset;
36
+
37
+ /* &[data-active="true"] {
38
+ --method-bg: var(--oas-method-get-bg--active);
39
+ --method-color: var(--oas-method-get-color--active);
40
+ } */
41
+ }
42
+
43
+ [data-atlas-oas-method="POST"] {
44
+ /* --method-color: var(--oas-method-post-color); */
45
+ /* --method-bg: var(--oas-method-post-bg); */
46
+
47
+ --method-color: var(--oas-method-post-color);
48
+ --method-bg: unset;
49
+
50
+ /* &[data-active="true"] {
51
+ --method-bg: var(--oas-method-post-bg--active);
52
+ --method-color: var(--oas-method-post-color--active);
53
+ } */
54
+ }
55
+
56
+ [data-atlas-oas-method="PUT"] {
57
+ /* --method-color: var(--oas-method-put-color); */
58
+ /* --method-bg: var(--oas-method-put-bg); */
59
+
60
+ --method-color: var(--oas-method-put-color);
61
+ --method-bg: unset;
62
+
63
+ /* &[data-active="true"] {
64
+ --method-bg: var(--oas-method-put-bg--active);
65
+ --method-color: var(--oas-method-put-color--active);
66
+ } */
67
+ }
68
+
69
+ [data-atlas-oas-method="DELETE"] {
70
+ /* --method-color: var(--oas-method-delete-color); */
71
+ /* --method-bg: var(--oas-method-delete-bg); */
72
+
73
+ --method-color: var(--oas-method-delete-color);
74
+ --method-bg: unset;
75
+
76
+ /* &[data-active="true"] {
77
+ --method-bg: var(--oas-method-delete-bg--active);
78
+ --method-color: var(--oas-method-delete-color--active);
79
+ } */
80
+ }
81
+
82
+ [data-atlas-oas-method="PATCH"] {
83
+ /* --method-color: var(--oas-method-patch-color); */
84
+ /* --method-bg: var(--oas-method-patch-bg); */
85
+
86
+ --method-color: var(--oas-method-patch-color);
87
+ --method-bg: unset;
88
+
89
+ /* &[data-active="true"] {
90
+ --method-bg: var(--oas-method-patch-bg--active);
91
+ --method-color: var(--oas-method-patch-color--active);
92
+ } */
93
+ }
94
+
95
+ [data-atlas-oas-method] {
96
+ color: var(--method-color);
97
+ }
98
+
99
+ [data-atlas-oas-method] xyd-badge {
100
+ background-color: var(--method-bg);
101
+ color: var(--method-color);
102
+ font-weight: var(--xyd-font-weight-bold);
103
+ }
104
+ }
@@ -0,0 +1,60 @@
1
+ :root {
2
+ /* Ref tokens - Base values */
3
+ --XydAtlas-Ref-Palette-White: #FFFFFF;
4
+
5
+ --XydAtlas-Ref-Palette-Primary-60: #7051d4;
6
+ --XydAtlas-Ref-Palette-Primary-70: #6045b9;
7
+ --XydAtlas-Ref-Palette-Primary-80: #4f399e;
8
+
9
+ --XydAtlas-Ref-Palette-Neutral-10: #F8F9FA;
10
+ --XydAtlas-Ref-Palette-Neutral-20: #F1F3F5;
11
+ --XydAtlas-Ref-Palette-Neutral-30: #E9ECEF;
12
+ --XydAtlas-Ref-Palette-Neutral-40: #DEE2E6;
13
+ --XydAtlas-Ref-Palette-Neutral-70: #6C757D;
14
+ --XydAtlas-Ref-Palette-Neutral-80: #495057;
15
+ --XydAtlas-Ref-Palette-Neutral-100: #212529;
16
+
17
+ /* System tokens - Semantic values */
18
+ --XydAtlas-Sys-Color-Primary: var(--XydAtlas-Ref-Palette-Primary-60);
19
+ --XydAtlas-Sys-Color-Primary--hover: var(--XydAtlas-Ref-Palette-Primary-70);
20
+ --XydAtlas-Sys-Color-Primary--active: var(--XydAtlas-Ref-Palette-Primary-80);
21
+
22
+ --XydAtlas-Sys-Color-Surface: var(--XydAtlas-Ref-Palette-Neutral-10);
23
+ --XydAtlas-Sys-Color-Surface--hover: var(--XydAtlas-Ref-Palette-Neutral-20);
24
+ --XydAtlas-Sys-Color-Surface--active: var(--XydAtlas-Ref-Palette-Neutral-30);
25
+
26
+ --XydAtlas-Sys-Color-Text-Primary: var(--XydAtlas-Ref-Palette-Neutral-100);
27
+ --XydAtlas-Sys-Color-Text-Secondary: var(--XydAtlas-Ref-Palette-Neutral-80);
28
+ --XydAtlas-Sys-Color-Text-Tertiary: var(--XydAtlas-Ref-Palette-Neutral-70);
29
+
30
+ --XydAtlas-Sys-Color-Border: var(--XydAtlas-Ref-Palette-Neutral-30);
31
+ --XydAtlas-Sys-Color-Border--hover: var(--XydAtlas-Ref-Palette-Neutral-40);
32
+ --XydAtlas-Sys-Color-Border--active: var(--XydAtlas-Ref-Palette-Primary-60);
33
+
34
+ /* Component tokens - Specific component values */
35
+ /* ApiRef Properties */
36
+ --XydAtlas-Component-ApiRef-Properties__color-description: var(--XydAtlas-Sys-Color-Text-Secondary);
37
+ --XydAtlas-Component-ApiRef-Properties__color-propName: var(--XydAtlas-Sys-Color-Text-Primary);
38
+ --XydAtlas-Component-ApiRef-Properties__color-propType: var(--XydAtlas-Sys-Color-Text-Tertiary);
39
+ --XydAtlas-Component-ApiRef-Properties__color--active: var(--XydAtlas-Sys-Color-Primary);
40
+ --XydAtlas-Component-ApiRef-Properties__color-border: var(--XydAtlas-Sys-Color-Border);
41
+
42
+ /* ApiRef Item */
43
+ --XydAtlas-Component-ApiRef-Item__color-border: var(--XydAtlas-Sys-Color-Border);
44
+ --XydAtlas-Component-ApiRef-Item__color-navbar: var(--XydAtlas-Sys-Color-Text-Secondary);
45
+ --XydAtlas-Component-ApiRef-Item__background-navbar: var(--XydAtlas-Ref-Palette-Neutral-10);
46
+
47
+ /* Code Sample */
48
+ --XydAtlas-Component-Code-Sample__color-border: var(--XydAtlas-Sys-Color-Border);
49
+ --XydAtlas-Component-Code-Sample__color: var(--XydAtlas-Sys-Color-Text-Secondary);
50
+ --XydAtlas-Component-Code-Sample__color--active: var(--XydAtlas-Sys-Color-Primary);
51
+ --XydAtlas-Component-Code-Sample__color-background: var(--XydAtlas-Sys-Color-Surface--hover);
52
+ --XydAtlas-Component-Code-Sample__color-markBorder--active: var(--XydAtlas-Sys-Color-Primary);
53
+ --XydAtlas-Component-Code-Sample__color-markBackground--active: var(--XydAtlas-Sys-Color-Surface--hover);
54
+
55
+ /* Code Sample Buttons */
56
+ --XydAtlas-Component-Code-SampleButtons__color-containerBackground: var(--XydAtlas-Sys-Color-Surface);
57
+ --XydAtlas-Component-Code-SampleButtons__color-background--active: var(--XydAtlas-Ref-Palette-White);
58
+ --XydAtlas-Component-Code-SampleButtons__color: var(--XydAtlas-Sys-Color-Text-Primary);
59
+ --XydAtlas-Component-Code-SampleButtons__color--active: var(--XydAtlas-Sys-Color-Text-Primary);
60
+ }
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+
package/tsconfig.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "paths": {
5
+ "@/atlas/*": [
6
+ "src/atlas/*"
7
+ ],
8
+ "@/components/*": [
9
+ "src/components/*"
10
+ ],
11
+ "@/utils/*": [
12
+ "src/utils/*"
13
+ ]
14
+ },
15
+ "typeRoots": [
16
+ "./types.d.ts"
17
+ ],
18
+ "module": "esnext",
19
+ "esModuleInterop": true,
20
+ "moduleResolution": "bundler",
21
+ "target": "ES6",
22
+ "lib": [
23
+ "dom",
24
+ "dom.iterable",
25
+ "esnext"
26
+ ],
27
+ "allowJs": true,
28
+ "skipLibCheck": true,
29
+ "strict": false,
30
+ "noEmit": true,
31
+ "incremental": false,
32
+ "resolveJsonModule": true,
33
+ "isolatedModules": true,
34
+ "jsx": "preserve",
35
+ "strictNullChecks": true
36
+ },
37
+ "include": [
38
+ "src/**/*.ts",
39
+ "src/**/*.tsx",
40
+ "src/**/*.json",
41
+ "packages/**/*.ts",
42
+ "packages/**/*.tsx",
43
+ "packages/**/*.json",
44
+ ".storybook/**/*.ts",
45
+ ".storybook/**/*.tsx",
46
+ "types.d.ts"
47
+ ],
48
+ "exclude": [
49
+ "node_modules"
50
+ ]
51
+ }
package/types.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import * as React from 'react'
2
+
3
+ declare global {
4
+ namespace React {
5
+ namespace JSX {
6
+ interface IntrinsicElements {
7
+ 'atlas-decorator': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
8
+
9
+ 'atlas-apiref-item': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
10
+ 'atlas-apiref-item-showcase': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
11
+ 'atlas-apiref-samples': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
12
+ 'atlas-apiref-definitions': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
13
+ 'atlas-apiref-properties': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
14
+ 'atlas-apiref-variant': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
15
+ 'atlas-apiref-propname': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
16
+ 'atlas-apiref-proptype': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
17
+ 'atlas-apiref-propmeta': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
18
+ 'atlas-apiref-meta-info': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
19
+ }
20
+ }
21
+ }
22
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,25 @@
1
+ import {resolve} from 'path';
2
+
3
+ import {defineConfig} from 'vite';
4
+ import react from '@vitejs/plugin-react';
5
+ import wyw from '@wyw-in-js/vite';
6
+
7
+ // https://vitejs.dev/config/
8
+
9
+ // eslint-disable-next-line import/no-default-export
10
+ export default defineConfig({
11
+ plugins: [
12
+ wyw({
13
+ include: ['**/*.{ts,tsx}'],
14
+ babelOptions: {
15
+ presets: ['@babel/preset-typescript', '@babel/preset-react'],
16
+ },
17
+ }),
18
+ react(),
19
+ ],
20
+ resolve: {
21
+ alias: {
22
+ '@': resolve(__dirname, 'src'),
23
+ },
24
+ },
25
+ });