@xyd-js/atlas 0.1.0-xyd.8 → 0.1.0-xyd.99

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 (56) hide show
  1. package/.storybook/index.css +1 -27
  2. package/.storybook/preview.ts +1 -2
  3. package/CHANGELOG.md +1057 -0
  4. package/LICENSE +21 -0
  5. package/dist/Update-0XruJHjj-COLbZvRj.js +4 -0
  6. package/dist/Update-0XruJHjj-COLbZvRj.js.map +1 -0
  7. package/dist/Update-DKOAw8p9-COLbZvRj.js +4 -0
  8. package/dist/Update-DKOAw8p9-COLbZvRj.js.map +1 -0
  9. package/dist/index.css +43 -54
  10. package/dist/index.d.ts +30 -11
  11. package/dist/index.js +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/styles.css +89 -0
  14. package/dist/tokens.css +60 -0
  15. package/dist/xydPlugin.d.ts +5 -0
  16. package/dist/xydPlugin.js +2 -0
  17. package/dist/xydPlugin.js.map +1 -0
  18. package/index.ts +1 -1
  19. package/package.json +20 -21
  20. package/packages/xyd-plugin/SidebarItem.tsx +27 -0
  21. package/packages/xyd-plugin/index.ts +20 -0
  22. package/rollup.config.js +56 -12
  23. package/src/components/ApiRef/ApiRefItem/ApiRefItem.styles.tsx +95 -63
  24. package/src/components/ApiRef/ApiRefItem/ApiRefItem.tsx +507 -55
  25. package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.styles.tsx +186 -143
  26. package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.tsx +584 -76
  27. package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.styles.tsx +19 -23
  28. package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.tsx +39 -24
  29. package/src/components/Atlas/Atlas.styles.tsx +3 -5
  30. package/src/components/Atlas/Atlas.tsx +34 -21
  31. package/src/components/Atlas/AtlasContext.tsx +47 -0
  32. package/src/components/Atlas/AtlasDecorator.styles.ts +22 -0
  33. package/src/components/Atlas/AtlasDecorator.tsx +15 -0
  34. package/src/components/Atlas/AtlasLazy/AtlasLazy.styles.tsx +7 -8
  35. package/src/components/Atlas/AtlasLazy/AtlasLazy.tsx +4 -6
  36. package/src/components/Atlas/AtlasPrimary.tsx +21 -0
  37. package/src/components/Atlas/AtlasSecondary.tsx +148 -0
  38. package/src/components/Atlas/index.ts +6 -2
  39. package/src/components/Atlas/types.ts +11 -0
  40. package/src/components/Code/CodeSampleButtons/CodeSampleButtons.styles.tsx +56 -141
  41. package/src/components/Code/CodeSampleButtons/CodeSampleButtons.tsx +19 -28
  42. package/src/components/Code/index.ts +0 -4
  43. package/src/components/Icon/index.tsx +384 -0
  44. package/src/styles/styles.css +89 -0
  45. package/src/styles/tokens.css +60 -0
  46. package/src/utils/mdx.ts +0 -29
  47. package/tsconfig.json +9 -2
  48. package/types.d.ts +22 -0
  49. package/src/components/Code/CodeCopy/CodeCopy.style.tsx +0 -21
  50. package/src/components/Code/CodeCopy/CodeCopy.tsx +0 -32
  51. package/src/components/Code/CodeCopy/index.ts +0 -7
  52. package/src/components/Code/CodeSample/CodeSample.styles.tsx +0 -134
  53. package/src/components/Code/CodeSample/CodeSample.tsx +0 -149
  54. package/src/components/Code/CodeSample/index.ts +0 -8
  55. package/src/components/Code/CodeSample/withLocalStored.tsx +0 -52
  56. package/src/components/Code/default-theme.ts +0 -266
@@ -1,7 +0,0 @@
1
- export {
2
- CodeCopy
3
- } from "./CodeCopy"
4
-
5
- export type {
6
- CodeCopyProps
7
- } from "./CodeCopy"
@@ -1,134 +0,0 @@
1
- import {css} from "@linaria/core";
2
-
3
- export const $sample = {
4
- host: css`
5
- flex: 1 1 0;
6
- overflow: hidden;
7
- min-width: 0;
8
- max-width: 512px;
9
-
10
- border: 1px solid var(--atlas-comp-code-sample-border-color);
11
- border-radius: 16px;
12
- `,
13
- }
14
-
15
- export const $languages = {
16
- host: css`
17
- display: flex;
18
- flex: 1 1 0%;
19
- padding: 8px 0px;
20
-
21
- background: linear-gradient(45deg, rgb(247, 247, 248) 0%, rgb(247, 247, 248) 100%) !important;
22
-
23
- border-top-right-radius: 10px;
24
- border-top-left-radius: 10px;
25
- border-bottom: 0px;
26
-
27
- min-width: 0;
28
- `,
29
- list: css`
30
- display: flex;
31
- flex-grow: 1;
32
- justify-content: end;
33
- gap: 8px;
34
- padding: 0 10px;
35
- `,
36
- button: css`
37
- all: unset;
38
-
39
- cursor: pointer;
40
-
41
- display: flex;
42
- align-items: center;
43
- justify-content: center;
44
-
45
- border-radius: 6px;
46
- padding: 6px;
47
-
48
- font-size: 14px;
49
- color: var(--atlas-comp-code-sample-color);
50
-
51
- &[data-state="active"] {
52
- color: var(--atlas-comp-code-sample-color--active);
53
- border-bottom: 1px solid var(--atlas-comp-code-sample-color--active);
54
- border-bottom-left-radius: 0px;
55
- border-bottom-right-radius: 0px;
56
- }
57
-
58
- &:hover {
59
- transition: ease-in 0.1s;
60
- background: var(--atlas-comp-code-sample-background);
61
- }
62
- `,
63
- description: css`
64
- display: flex;
65
- align-items: center;
66
- gap: 4px;
67
-
68
- font-size: 14px;
69
- color: var(--atlas-comp-code-sample-color);
70
-
71
- margin-left: 4px;
72
- margin-right: 4px;
73
- `,
74
- description$item: css`
75
- display: flex;
76
- padding-left: 16px;
77
- padding-right: 16px;
78
- flex: 1 1 0%;
79
- gap: 16px;
80
- border-radius: 4px;
81
- `,
82
- copy: css`
83
- display: flex;
84
- padding-left: 8px;
85
- padding-right: 8px;
86
- align-items: center;
87
- `
88
- }
89
-
90
- export const $code = {
91
- host: css`
92
- max-height: 400px;
93
- background: linear-gradient(45deg, rgb(247, 247, 248) 0%, rgb(247, 247, 248) 100%) !important;
94
-
95
- margin: 0;
96
- padding: 8px 16px;
97
-
98
- border-top: 1px solid var(--atlas-comp-code-sample-border-color);
99
- border-bottom-left-radius: 10px;
100
- border-bottom-right-radius: 10px;
101
-
102
- font-size: 14px;
103
- line-height: 20px;
104
- white-space: pre-wrap;
105
- word-break: break-all;
106
-
107
- overflow-y: scroll;
108
- `
109
- }
110
-
111
- export const $mark = {
112
- host: css`
113
- display: flex;
114
- border-left-width: 4px;
115
- border-color: transparent;
116
- margin: 4px 0;
117
- `,
118
- line: css`
119
- flex: 1 1 0%;
120
- `,
121
- $$annotated: css`
122
- border-color: var(--atlas-comp-code-sample-mark-border--active);
123
- background-color: var(--atlas-comp-code-sample-mark-background--active);
124
- `
125
- }
126
-
127
- export const $lineNumber = {
128
- host: css`
129
- margin: 0 4px;
130
- //text-align: right;
131
- user-select: none;
132
- opacity: 0.5;
133
- `
134
- }
@@ -1,149 +0,0 @@
1
- import React, {useEffect, useState} from "react";
2
- import * as TabsPrimitive from "@radix-ui/react-tabs"; // TODO: remove and use separation
3
- import {
4
- AnnotationHandler,
5
- InnerLine,
6
- Pre,
7
- highlight,
8
- HighlightedCode,
9
- } from "codehike/code"
10
-
11
- import {
12
- CodeCopy,
13
- } from "@/components/Code";
14
- import {theme as defaultTheme} from "@/components/Code/default-theme" // TODO: support multiple themes
15
- import {withLocalStored} from "@/components/Code/CodeSample/withLocalStored";
16
- import {
17
- $sample,
18
- $languages,
19
- $code,
20
- $mark,
21
- $lineNumber
22
- } from "./CodeSample.styles";
23
-
24
- // TODO: try to use codehiki in build time / ASYNC !!! - we need rr server-components
25
- // TODO: separate highlight
26
-
27
- export interface MDXCodeSampleBlock {
28
- /** This is the raw code. May include annotation comments. */
29
- value: string;
30
- /** The programming language. */
31
- lang: string;
32
- /** Metadata string (the content after the language name in a markdown codeblock). */
33
- meta: string;
34
- }
35
-
36
- export interface CodeSampleProps {
37
- name: string;
38
- description: string;
39
- codeblocks: MDXCodeSampleBlock[];
40
- }
41
-
42
- const $$LocalStoredTab = withLocalStored(TabsPrimitive.Root);
43
-
44
- export function CodeSample(props: CodeSampleProps) {
45
- const [highlighted, setHighlighted] = useState<HighlightedCode[]>([]);
46
-
47
- useEffect(() => {
48
- async function fetchHighlight() {
49
- const result = await Promise.all(
50
- props.codeblocks?.map((codeblock) => highlight(codeblock, defaultTheme))
51
- );
52
-
53
- setHighlighted(result);
54
- }
55
-
56
- fetchHighlight();
57
- }, [props.codeblocks]);
58
-
59
- if (highlighted.length === 0) {
60
- return <div>Loading</div>;
61
- }
62
-
63
- if (!highlighted) {
64
- return <div>Loading</div>;
65
- }
66
-
67
-
68
- return (
69
- <$$LocalStoredTab
70
- className={$sample.host}
71
- style={highlighted[0]?.style}
72
- localStorageKey={`preferredLanguage[${name}]`}
73
- defaultValue={highlighted[0]?.meta}
74
- >
75
- <div className={$languages.host}>
76
- <$Description description={props.description}/>
77
-
78
- <TabsPrimitive.List className={$languages.list}>
79
- {props.codeblocks?.map(({meta}, i) => (
80
- <TabsPrimitive.Trigger value={meta!} key={i} className={$languages.button}>
81
- {meta}
82
- </TabsPrimitive.Trigger>
83
- ))}
84
- </TabsPrimitive.List>
85
-
86
- <div className={$languages.copy}>
87
- {props.codeblocks?.map((codeblock, i) => (
88
- <TabsPrimitive.Content value={codeblock.meta!} asChild key={i}>
89
- <CodeCopy text={codeblock.value}/>
90
- </TabsPrimitive.Content>
91
- ))}
92
- </div>
93
- </div>
94
-
95
- {highlighted?.map((codeblock, i) => (
96
- <TabsPrimitive.Content value={codeblock.meta} key={i}>
97
- <Pre
98
- className={$code.host}
99
- style={codeblock?.style || codeblock?.style}
100
- code={codeblock}
101
- handlers={[mark, lineNumber]}
102
- />
103
- </TabsPrimitive.Content>
104
- ))}
105
- </$$LocalStoredTab>
106
- )
107
- }
108
-
109
- function $Description(props: { description: string }) {
110
- return <div className={$languages.description}>
111
- <div className={$languages.description$item}>
112
- {props.description}
113
- </div>
114
- </div>
115
- }
116
-
117
- const mark: AnnotationHandler = {
118
- name: "Mark",
119
- Line: ({annotation, ...props}) => {
120
- return (
121
- <div className={`${$mark.host} ${annotation && $mark.$$annotated}`}>
122
- <InnerLine
123
- merge={props}
124
- className={$mark.line}
125
- />
126
- </div>
127
- )
128
- },
129
- }
130
-
131
- const lineNumber: AnnotationHandler = {
132
- name: "LineNumber",
133
- Line: ({annotation, ...props}) => {
134
- const width = props.totalLines.toString().length + 1
135
-
136
- return (
137
- <>
138
- <span
139
- style={{minWidth: `${width}ch`}}
140
- className={$lineNumber.host}
141
- >
142
- {props.lineNumber}
143
- </span>
144
- <InnerLine merge={props}/>
145
- </>
146
- )
147
- },
148
- }
149
-
@@ -1,8 +0,0 @@
1
- export {
2
- CodeSample,
3
- } from './CodeSample';
4
-
5
- export type {
6
- CodeSampleProps,
7
- MDXCodeSampleBlock,
8
- } from "./CodeSample";
@@ -1,52 +0,0 @@
1
- import React, {useState, useEffect} from "react"
2
-
3
- export interface CodeTabsProps {
4
- localStorageKey: string
5
- defaultValue: string
6
- className: string
7
- style: any
8
-
9
- children: React.ReactNode
10
- }
11
-
12
- // TODO: interface
13
- export function withLocalStored(Component: any) {
14
- return function LocalStored(props: CodeTabsProps) {
15
- const [value, setValue] = useState(
16
- typeof localStorage !== "undefined"
17
- ? localStorage?.getItem(props.localStorageKey) || props.defaultValue
18
- : props.defaultValue,
19
- )
20
-
21
- useEffect(() => {
22
- const handler = (e: StorageEvent) => {
23
- if (e.key === props.localStorageKey) {
24
- setValue(e.newValue || props.defaultValue)
25
- }
26
- }
27
- window.addEventListener("storage", handler)
28
- return () => {
29
- window.removeEventListener("storage", handler)
30
- }
31
- }, [props.localStorageKey])
32
-
33
- function onValueChange(value: string) {
34
- localStorage.setItem(props.localStorageKey, value)
35
- window.dispatchEvent(
36
- new StorageEvent("storage", {
37
- key: props.localStorageKey,
38
- newValue: value,
39
- }),
40
- )
41
- }
42
-
43
- return (
44
- <Component
45
- onValueChange={onValueChange}
46
- value={value}
47
- >
48
- {props.children}
49
- </Component>
50
- )
51
- }
52
- }
@@ -1,266 +0,0 @@
1
- // from: https://marketplace.visualstudio.com/items?itemName=smockle.xcode-default-theme
2
-
3
- import {Theme} from "@code-hike/lighter";
4
-
5
- export const theme: Theme = {
6
- type: "light",
7
- colors: {
8
- "list.focusForeground": "#FFFFFF",
9
- "scrollbar.shadow": "#ffffff00",
10
- "tab.activeBorder": "#ffffff",
11
- "widget.shadow": "#ffffff00",
12
- "activityBar.border": "#D9D7D5",
13
- "editorGroup.border": "#D9D7D5",
14
- "editorGroupHeader.tabsBorder": "#D9D7D5",
15
- "editorWidget.border": "#D9D7D5",
16
- "editorWidget.resizeBorder": "#D9D7D5",
17
- "input.border": "#D9D7D5",
18
- "notificationCenter.border": "#D9D7D5",
19
- "notifications.border": "#D9D7D5",
20
- "panel.border": "#D9D7D5",
21
- "sideBar.border": "#D9D7D5",
22
- "statusBar.border": "#D9D7D5",
23
- "tab.border": "#D9D7D5",
24
- "activityBar.background": "#ECECEC",
25
- "statusBar.background": "#ECECEC",
26
- "statusBar.noFolderBackground": "#ECECEC",
27
- "statusBar.debuggingBackground": "#ECECEC",
28
- "editorGroupHeader.tabsBackground": "#F5F5F5",
29
- "editorWidget.background": "#F5F5F5",
30
- "sideBar.background": "#F5F5F5",
31
- "sideBarSectionHeader.background": "#F5F5F5",
32
- "tab.inactiveBackground": "#F5F5F5",
33
- "activityBarBadge.background": "#282828",
34
- "activityBar.foreground": "#282828",
35
- "statusBar.foreground": "#565456",
36
- "input.placeholderForeground": "#C7C6C5",
37
- "editorLineNumber.foreground": "#A6A6A6",
38
- "editorLineNumber.activeForeground": "#282828",
39
- foreground: "#282828",
40
- "panelTitle.activeForeground": "#282828",
41
- "sideBarTitle.foreground": "#282828",
42
- "sideBarSectionHeader.foreground": "#282828",
43
- "panelTitle.inactiveForeground": "#242424",
44
- "tab.inactiveForeground": "#242424",
45
- "list.highlightForeground": "#242424",
46
- "editor.lineHighlightBackground": "#EEF5FE",
47
- focusBorder: "#82ADF3",
48
- "button.background": "#3C93FD",
49
- "list.activeSelectionBackground": "#3C93FD",
50
- "list.focusBackground": "#3C93FD",
51
- "selection.background": "#B3D7FF",
52
- "list.inactiveSelectionBackground": "#CECECE",
53
- "terminal.ansiBlack": "#000000",
54
- "terminal.ansiBrightBlack": "#000000",
55
- "terminal.ansiRed": "#C41A16",
56
- "terminal.ansiBrightRed": "#C41A16",
57
- "terminal.ansiGreen": "#007400",
58
- "terminal.ansiBrightGreen": "#007400",
59
- "terminal.ansiYellow": "#643820",
60
- "terminal.ansiBrightYellow": "#643820",
61
- "terminal.ansiBlue": "#272AD8",
62
- "terminal.ansiBrightBlue": "#272AD8",
63
- "terminal.ansiMagenta": "#AA0D91",
64
- "terminal.ansiBrightMagenta": "#AA0D91",
65
- "terminal.ansiCyan": "#3F6E74",
66
- "terminal.ansiBrightCyan": "#3F6E74",
67
- },
68
- tokenColors: [
69
- {
70
- scope: "new.expr entity.name",
71
- settings: {
72
- foreground: "#713DA9",
73
- },
74
- },
75
- {
76
- name: "Comments",
77
- scope: ["comment", "comment storage.type"],
78
- settings: {
79
- foreground: "#536579",
80
- fontStyle: "italic",
81
- },
82
- },
83
- {
84
- name: "CSS",
85
- scope: [
86
- "entity.other.attribute-name.pseudo-class.css",
87
- "entity.other.attribute-name.pseudo-class.scss",
88
- "entity.other.attribute-name.pseudo-element.css",
89
- "entity.other.attribute-name.pseudo-element.scss",
90
- "support.function.calc.css",
91
- "support.function.calc.scss",
92
- "support.type.property-name.css",
93
- "support.type.property-name.scss",
94
- "support.type.vendored.property-name.css",
95
- "support.type.vendored.property-name.scss",
96
- "meta.property-value.css support.constant",
97
- "meta.property-value.scss support.constant",
98
- "meta.property-value.css support.constant.property-value",
99
- "meta.property-value.scss support.constant.property-value",
100
- "support.function.transform.css",
101
- "support.function.transform.scss",
102
- ],
103
- settings: {
104
- foreground: "#AA0D91",
105
- },
106
- },
107
- {
108
- name: "Decorator",
109
- scope: [
110
- "meta.decorator",
111
- "meta.decorator punctuation.decorator",
112
- "meta.decorator variable.other.readwrite",
113
- "meta.decorator meta.function-call entity.name.function",
114
- ],
115
- settings: {
116
- foreground: "#643820",
117
- },
118
- },
119
- {
120
- name: "Doctype",
121
- scope: ["meta.tag.sgml.html"],
122
- settings: {
123
- foreground: "#A6A6A6",
124
- },
125
- },
126
- {
127
- name: "Functions",
128
- scope: ["entity.name.function", "support.function"],
129
- settings: {
130
- foreground: "#7051d4",
131
- },
132
- },
133
- {
134
- name: "Keys",
135
- scope: [
136
- "meta.property-list meta.property-name",
137
- "support.type.property-name",
138
- "support.type.map.key",
139
- "entity.name.tag.yaml",
140
- ],
141
- settings: {
142
- foreground: "#7051d4",
143
- },
144
- },
145
- {
146
- name: "Keywords",
147
- scope: [
148
- "keyword.control",
149
- "keyword.declaration",
150
- "keyword.expressions-and-types",
151
- "keyword.operator.new",
152
- "keyword.reserved",
153
- "keyword.statement",
154
- "storage.type",
155
- "storage.modifier",
156
- "constant.language",
157
- "variable.language.super",
158
- "variable.language.this",
159
- "text.html entity.name.tag",
160
- "meta.tag entity.name.tag",
161
- "meta.tag support.class",
162
- "string.regexp keyword.other",
163
- ],
164
- settings: {
165
- foreground: "#AD3DA4",
166
- fontStyle: "bold",
167
- },
168
- },
169
- {
170
- name: "Operators",
171
- scope: [
172
- "storage.type.function.arrow",
173
- "meta.template.expression punctuation",
174
- "punctuation.separator.key-value",
175
- "meta.object-literal.key meta.brace.square",
176
- "meta.template.expression keyword.operator",
177
- "keyword.operator.or.regexp",
178
- "keyword.operator.quantifier",
179
- "punctuation.definition.group.regexp",
180
- "punctuation.definition.character-class",
181
- ],
182
- settings: {
183
- foreground: "#000000",
184
- },
185
- },
186
- {
187
- scope: [
188
- "meta.tag entity.other.attribute-name",
189
- "constant.character.escape.backslash",
190
- ],
191
- settings: {
192
- foreground: "#816927",
193
- },
194
- },
195
- {
196
- name: "Numbers",
197
- scope: ["constant.numeric", "keyword.other.unit", "constant.other.color"],
198
- settings: {
199
- foreground: "#272AD8",
200
- },
201
- },
202
- {
203
- name: "Strings",
204
- scope: [
205
- "string",
206
- "variable.parameter.url.scss",
207
- "markup.heading.markdown",
208
- "beginning.punctuation.definition.list.markdown",
209
- "meta.template.expression meta.embedded punctuation.definition.string.begin",
210
- "meta.template.expression meta.embedded punctuation.definition.string.end",
211
- ],
212
- settings: {
213
- foreground: "#D12F1B",
214
- },
215
- },
216
- {
217
- name: "Types",
218
- scope: [
219
- "meta.type",
220
- "meta.return.type",
221
- "entity.name.type",
222
- "support.type.primitive",
223
- ],
224
- settings: {
225
- foreground: "#713DA9",
226
- },
227
- },
228
- {
229
- scope: [
230
- "meta.objectliteral variable.other.object",
231
- "entity.name.type.module",
232
- "entity.other.inherited-class",
233
- "variable.scss",
234
- "variable.other.bracket.shell",
235
- "entity.name.function.scss",
236
- ],
237
- settings: {
238
- foreground: "#3F6E74",
239
- },
240
- },
241
- {
242
- scope: [
243
- "keyword.control.at-rule",
244
- "meta.import variable.other.readwrite",
245
- "meta.definition.variable variable.other.readwrite",
246
- "meta.definition.variable variable.other.constant",
247
- "meta.template.expression variable.other.readwrite",
248
- "meta.template.expression variable.other.constant",
249
- "support.constant.property-value",
250
- ],
251
- settings: {
252
- foreground: "#000000",
253
- },
254
- },
255
- {
256
- scope: [
257
- "variable.other.property",
258
- "variable.other.object.property",
259
- "support.variable.property",
260
- ],
261
- settings: {
262
- foreground: "#713DA9",
263
- },
264
- },
265
- ],
266
- }