@xyd-js/atlas 0.1.0-xyd.12 → 0.1.0-xyd.13
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/index.css +2 -27
- package/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/dist/{CodeSample-Cp42Adjc-C5AHaCBx.js → CodeSample-B9VUhTKF-DJ2leksk.js} +2 -2
- package/dist/{CodeSample-Cp42Adjc-C5AHaCBx.js.map → CodeSample-B9VUhTKF-DJ2leksk.js.map} +1 -1
- package/dist/{CodeSample-DxPp80ID-C5AHaCBx.js → CodeSample-BSXeFy0x-DJ2leksk.js} +2 -2
- package/dist/{CodeSample-DxPp80ID-C5AHaCBx.js.map → CodeSample-BSXeFy0x-DJ2leksk.js.map} +1 -1
- package/dist/CodeSample-BwP208sQ-DJ2leksk.js +2 -0
- package/dist/CodeSample-BwP208sQ-DJ2leksk.js.map +1 -0
- package/dist/CodeSample-CUemtj_W-DJ2leksk.js +2 -0
- package/dist/CodeSample-CUemtj_W-DJ2leksk.js.map +1 -0
- package/dist/CodeSample-D0iKih-A-DJ2leksk.js +2 -0
- package/dist/CodeSample-D0iKih-A-DJ2leksk.js.map +1 -0
- package/dist/CodeSample-D33vTa6M-DJ2leksk.js +2 -0
- package/dist/CodeSample-D33vTa6M-DJ2leksk.js.map +1 -0
- package/dist/CodeSample-DUSx2KBt-DJ2leksk.js +2 -0
- package/dist/CodeSample-DUSx2KBt-DJ2leksk.js.map +1 -0
- package/dist/CodeSample-P4yxkHPW-DJ2leksk.js +2 -0
- package/dist/CodeSample-P4yxkHPW-DJ2leksk.js.map +1 -0
- package/dist/atlas-index.js +1 -1
- package/dist/atlas-index.js.map +1 -1
- package/dist/index.css +58 -58
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/rollup.config.js +2 -2
- package/src/components/ApiRef/ApiRefItem/ApiRefItem.styles.tsx +56 -67
- package/src/components/ApiRef/ApiRefItem/ApiRefItem.tsx +20 -27
- package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.styles.tsx +124 -139
- package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.tsx +27 -37
- package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.styles.tsx +18 -23
- package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.tsx +3 -6
- package/src/components/Atlas/Atlas.styles.tsx +3 -5
- package/src/components/Atlas/Atlas.tsx +2 -5
- package/src/components/Atlas/AtlasLazy/AtlasLazy.styles.tsx +7 -8
- package/src/components/Atlas/AtlasLazy/AtlasLazy.tsx +2 -4
- package/src/components/Code/CodeCopy/CodeCopy.styles.tsx +17 -0
- package/src/components/Code/CodeCopy/CodeCopy.tsx +2 -4
- package/src/components/Code/CodeSample/CodeSample.styles.tsx +129 -132
- package/src/components/Code/CodeSample/CodeSample.tsx +12 -18
- package/src/components/Code/CodeSampleButtons/CodeSampleButtons.styles.tsx +56 -134
- package/src/components/Code/CodeSampleButtons/CodeSampleButtons.tsx +13 -20
- package/src/components/Code/CodeCopy/CodeCopy.style.tsx +0 -19
- package/src/utils/linaria.ts +0 -20
|
@@ -13,13 +13,7 @@ import {
|
|
|
13
13
|
} from "@/components/Code";
|
|
14
14
|
import {theme as defaultTheme} from "@/components/Code/default-theme" // TODO: support multiple themes
|
|
15
15
|
import {withLocalStored} from "@/components/Code/CodeSample/withLocalStored";
|
|
16
|
-
import
|
|
17
|
-
$sample,
|
|
18
|
-
$languages,
|
|
19
|
-
$code,
|
|
20
|
-
$mark,
|
|
21
|
-
$lineNumber
|
|
22
|
-
} from "./CodeSample.styles";
|
|
16
|
+
import * as cn from "./CodeSample.styles";
|
|
23
17
|
import {CodeLoader} from "@xyd-js/components/coder";
|
|
24
18
|
|
|
25
19
|
// TODO: try to use codehiki in build time / ASYNC !!! - we need rr server-components
|
|
@@ -67,23 +61,23 @@ export function CodeSample(props: CodeSampleProps) {
|
|
|
67
61
|
|
|
68
62
|
return (
|
|
69
63
|
<$$LocalStoredTab
|
|
70
|
-
className={
|
|
64
|
+
className={cn.CodeSampleHost}
|
|
71
65
|
style={highlighted[0]?.style}
|
|
72
66
|
localStorageKey={`preferredLanguage[${name}]`}
|
|
73
67
|
defaultValue={highlighted[0]?.meta}
|
|
74
68
|
>
|
|
75
|
-
<div className={
|
|
69
|
+
<div className={cn.CodeSampleLanguagesHost}>
|
|
76
70
|
<$Description description={props.description}/>
|
|
77
71
|
|
|
78
|
-
<TabsPrimitive.List className={
|
|
72
|
+
<TabsPrimitive.List className={cn.CodeSampleLanguagesList}>
|
|
79
73
|
{props.codeblocks?.map(({meta}, i) => (
|
|
80
|
-
<TabsPrimitive.Trigger value={meta!} key={i} className={
|
|
74
|
+
<TabsPrimitive.Trigger value={meta!} key={i} className={cn.CodeSampleLanguagesButton}>
|
|
81
75
|
{meta}
|
|
82
76
|
</TabsPrimitive.Trigger>
|
|
83
77
|
))}
|
|
84
78
|
</TabsPrimitive.List>
|
|
85
79
|
|
|
86
|
-
<div className={
|
|
80
|
+
<div className={cn.CodeSampleLanguagesCopy}>
|
|
87
81
|
{props.codeblocks?.map((codeblock, i) => (
|
|
88
82
|
<TabsPrimitive.Content value={codeblock.meta!} asChild key={i}>
|
|
89
83
|
<CodeCopy text={codeblock.value}/>
|
|
@@ -95,7 +89,7 @@ export function CodeSample(props: CodeSampleProps) {
|
|
|
95
89
|
{highlighted?.map((codeblock, i) => (
|
|
96
90
|
<TabsPrimitive.Content value={codeblock.meta} key={i}>
|
|
97
91
|
<Pre
|
|
98
|
-
className={
|
|
92
|
+
className={cn.CodeSampleCodeHost}
|
|
99
93
|
style={codeblock?.style || codeblock?.style}
|
|
100
94
|
code={codeblock}
|
|
101
95
|
handlers={[mark, lineNumber]}
|
|
@@ -107,8 +101,8 @@ export function CodeSample(props: CodeSampleProps) {
|
|
|
107
101
|
}
|
|
108
102
|
|
|
109
103
|
function $Description(props: { description: string }) {
|
|
110
|
-
return <div className={
|
|
111
|
-
<div className={
|
|
104
|
+
return <div className={cn.CodeSampleLanguagesDescription}>
|
|
105
|
+
<div className={cn.CodeSampleLanguagesDescriptionItem}>
|
|
112
106
|
{props.description}
|
|
113
107
|
</div>
|
|
114
108
|
</div>
|
|
@@ -118,10 +112,10 @@ const mark: AnnotationHandler = {
|
|
|
118
112
|
name: "Mark",
|
|
119
113
|
Line: ({annotation, ...props}) => {
|
|
120
114
|
return (
|
|
121
|
-
<div className={`${
|
|
115
|
+
<div className={`${cn.CodeSampleMarkHost} ${annotation && cn.CodeSampleMarkAnnotated}`}>
|
|
122
116
|
<InnerLine
|
|
123
117
|
merge={props}
|
|
124
|
-
className={
|
|
118
|
+
className={cn.CodeSampleMarkLine}
|
|
125
119
|
/>
|
|
126
120
|
</div>
|
|
127
121
|
)
|
|
@@ -137,7 +131,7 @@ const lineNumber: AnnotationHandler = {
|
|
|
137
131
|
<>
|
|
138
132
|
<span
|
|
139
133
|
style={{minWidth: `${width}ch`}}
|
|
140
|
-
className={
|
|
134
|
+
className={cn.CodeSampleLineNumberHost}
|
|
141
135
|
>
|
|
142
136
|
{props.lineNumber}
|
|
143
137
|
</span>
|
|
@@ -1,137 +1,59 @@
|
|
|
1
1
|
import {css} from "@linaria/core";
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
|
|
53
|
-
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
54
|
-
transition-duration: 300ms;
|
|
55
|
-
|
|
56
|
-
color: var(--XydAtlas-Component-Code-SampleButtons__color);
|
|
57
|
-
|
|
58
|
-
&:hover {
|
|
59
|
-
color: var(--XydAtlas-Component-Code-SampleButtons__color--active);
|
|
60
|
-
}
|
|
61
|
-
`,
|
|
62
|
-
$$active: css`
|
|
3
|
+
export const CodeSampleButtonsHost = css`
|
|
4
|
+
position: relative;
|
|
5
|
+
max-width: 100%;
|
|
6
|
+
`;
|
|
7
|
+
|
|
8
|
+
export const CodeSampleButtonsContainer = css`
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
border-radius: 8px;
|
|
12
|
+
background-color: var(--XydAtlas-Component-Code-SampleButtons__color-containerBackground);
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export const CodeSampleButtonsArrowHost = css`
|
|
16
|
+
padding: 8px;
|
|
17
|
+
background-color: #ffffff;
|
|
18
|
+
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export const CodeSampleButtonsArrowIcon = css`
|
|
22
|
+
width: 16px;
|
|
23
|
+
height: 16px;
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export const CodeSampleButtonsScrollerHost = css`
|
|
27
|
+
overflow-x: auto;
|
|
28
|
+
flex-grow: 1;
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
export const CodeSampleButtonsScrollerContainer = css`
|
|
32
|
+
display: inline-flex;
|
|
33
|
+
gap: 4px;
|
|
34
|
+
padding: 4px;
|
|
35
|
+
margin-left: 4px;
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
export const CodeSampleButtonsButtonHost = css`
|
|
39
|
+
padding: 0.5rem 1rem;
|
|
40
|
+
border-radius: 0.375rem;
|
|
41
|
+
font-size: 0.875rem;
|
|
42
|
+
line-height: 1.25rem;
|
|
43
|
+
font-weight: 500;
|
|
44
|
+
white-space: nowrap;
|
|
45
|
+
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
|
|
46
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
47
|
+
transition-duration: 300ms;
|
|
48
|
+
color: var(--XydAtlas-Component-Code-SampleButtons__color);
|
|
49
|
+
|
|
50
|
+
&:hover {
|
|
63
51
|
color: var(--XydAtlas-Component-Code-SampleButtons__color--active);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export const $sample = {
|
|
73
|
-
host: css`
|
|
74
|
-
position: relative;
|
|
75
|
-
max-width: 100%;
|
|
76
|
-
`,
|
|
77
|
-
container: css`
|
|
78
|
-
display: flex;
|
|
79
|
-
align-items: center;
|
|
80
|
-
border-radius: 8px;
|
|
81
|
-
background-color: #F3F4F6;
|
|
82
|
-
`
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export const $arrow = {
|
|
86
|
-
host: css`
|
|
87
|
-
padding: 8px;
|
|
88
|
-
background-color: #ffffff;
|
|
89
|
-
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
90
|
-
`,
|
|
91
|
-
icon: css`
|
|
92
|
-
width: 16px;
|
|
93
|
-
height: 16px;
|
|
94
|
-
`
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export const $scroller = {
|
|
98
|
-
host: css`
|
|
99
|
-
overflow-x: auto;
|
|
100
|
-
flex-grow: 1;
|
|
101
|
-
`,
|
|
102
|
-
container: css`
|
|
103
|
-
display: inline-flex;
|
|
104
|
-
gap: 4px;
|
|
105
|
-
|
|
106
|
-
padding: 4px;
|
|
107
|
-
margin-left: 4px;
|
|
108
|
-
`
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export const $button = {
|
|
112
|
-
host: css`
|
|
113
|
-
padding: 0.5rem 1rem;
|
|
114
|
-
|
|
115
|
-
border-radius: 0.375rem;
|
|
116
|
-
font-size: 0.875rem;
|
|
117
|
-
line-height: 1.25rem;
|
|
118
|
-
font-weight: 500;
|
|
119
|
-
white-space: nowrap;
|
|
120
|
-
|
|
121
|
-
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
|
|
122
|
-
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
123
|
-
transition-duration: 300ms;
|
|
124
|
-
|
|
125
|
-
color: #6B7280;
|
|
126
|
-
|
|
127
|
-
&:hover {
|
|
128
|
-
color: #111827;
|
|
129
|
-
}
|
|
130
|
-
`,
|
|
131
|
-
$$active: css`
|
|
132
|
-
color: #111827;
|
|
133
|
-
background-color: #ffffff;
|
|
134
|
-
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
135
|
-
`
|
|
136
|
-
}
|
|
137
|
-
*/
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
export const CodeSampleButtonsButtonActive = css`
|
|
56
|
+
color: var(--XydAtlas-Component-Code-SampleButtons__color--active);
|
|
57
|
+
background-color: var(--XydAtlas-Component-Code-SampleButtons__color-background--active);
|
|
58
|
+
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
59
|
+
`;
|
|
@@ -5,18 +5,11 @@ import {Example} from "@xyd-js/uniform";
|
|
|
5
5
|
|
|
6
6
|
import {MDXReference, mdxValue} from "@/utils/mdx";
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
$sample,
|
|
10
|
-
$arrow,
|
|
11
|
-
$scroller,
|
|
12
|
-
$button
|
|
13
|
-
} from "./CodeSampleButtons.styles";
|
|
8
|
+
import * as cn from "./CodeSampleButtons.styles";
|
|
14
9
|
|
|
15
10
|
export interface CodeExampleButtonsProps {
|
|
16
11
|
examples: MDXReference<Example[]>
|
|
17
|
-
|
|
18
12
|
activeExample: MDXReference<Example> | null
|
|
19
|
-
|
|
20
13
|
onClick: (example: MDXReference<Example>) => void
|
|
21
14
|
}
|
|
22
15
|
|
|
@@ -47,40 +40,40 @@ export function CodeExampleButtons({examples, activeExample, onClick}: CodeExamp
|
|
|
47
40
|
}
|
|
48
41
|
|
|
49
42
|
return (
|
|
50
|
-
<div className={
|
|
51
|
-
<div className={
|
|
43
|
+
<div className={cn.CodeSampleButtonsHost}>
|
|
44
|
+
<div className={cn.CodeSampleButtonsContainer}>
|
|
52
45
|
{showLeftArrow && (
|
|
53
46
|
<button
|
|
54
47
|
onClick={() => scroll('left')}
|
|
55
|
-
className={
|
|
48
|
+
className={cn.CodeSampleButtonsArrowHost}
|
|
56
49
|
>
|
|
57
|
-
<ChevronLeft className={
|
|
50
|
+
<ChevronLeft className={cn.CodeSampleButtonsArrowIcon}/>
|
|
58
51
|
</button>
|
|
59
52
|
)}
|
|
60
53
|
<div
|
|
61
54
|
ref={scrollContainerRef}
|
|
62
55
|
onScroll={handleScroll}
|
|
63
|
-
className={
|
|
56
|
+
className={cn.CodeSampleButtonsScrollerHost}
|
|
64
57
|
>
|
|
65
|
-
<div className={
|
|
58
|
+
<div className={cn.CodeSampleButtonsScrollerContainer}>
|
|
66
59
|
{examples?.map((example) => (
|
|
67
|
-
|
|
60
|
+
<SampleButton
|
|
68
61
|
key={example.codeblock.title}
|
|
69
62
|
onClick={() => onClick(example)}
|
|
70
63
|
example={example}
|
|
71
64
|
activeExample={activeExample}
|
|
72
65
|
>
|
|
73
66
|
{mdxValue(example.codeblock.title || null)}
|
|
74
|
-
|
|
67
|
+
</SampleButton>
|
|
75
68
|
))}
|
|
76
69
|
</div>
|
|
77
70
|
</div>
|
|
78
71
|
{showRightArrow && (
|
|
79
72
|
<button
|
|
80
73
|
onClick={() => scroll('right')}
|
|
81
|
-
className={
|
|
74
|
+
className={cn.CodeSampleButtonsArrowHost}
|
|
82
75
|
>
|
|
83
|
-
<ChevronRight className={
|
|
76
|
+
<ChevronRight className={cn.CodeSampleButtonsArrowIcon}/>
|
|
84
77
|
</button>
|
|
85
78
|
)}
|
|
86
79
|
</div>
|
|
@@ -88,7 +81,7 @@ export function CodeExampleButtons({examples, activeExample, onClick}: CodeExamp
|
|
|
88
81
|
)
|
|
89
82
|
}
|
|
90
83
|
|
|
91
|
-
function
|
|
84
|
+
function SampleButton({onClick, children, activeExample, example}: {
|
|
92
85
|
onClick: () => void,
|
|
93
86
|
children: React.ReactNode,
|
|
94
87
|
example: MDXReference<Example>,
|
|
@@ -99,7 +92,7 @@ function $SampleButton({onClick, children, activeExample, example}: {
|
|
|
99
92
|
|
|
100
93
|
return <button
|
|
101
94
|
onClick={onClick}
|
|
102
|
-
className={`${
|
|
95
|
+
className={`${cn.CodeSampleButtonsButtonHost} ${markExampleAsActive && cn.CodeSampleButtonsButtonActive}`}
|
|
103
96
|
>
|
|
104
97
|
{children}
|
|
105
98
|
</button>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {css} from "@linaria/core";
|
|
2
|
-
|
|
3
|
-
export const $copy = {
|
|
4
|
-
host: css`
|
|
5
|
-
display: flex;
|
|
6
|
-
align-items: center;
|
|
7
|
-
justify-content: center;
|
|
8
|
-
|
|
9
|
-
padding: 8px;
|
|
10
|
-
|
|
11
|
-
border-radius: 6px;
|
|
12
|
-
|
|
13
|
-
cursor: pointer;
|
|
14
|
-
|
|
15
|
-
&:hover {
|
|
16
|
-
background: var(--XydAtlas-Component-Code-Copy__color-background--active);
|
|
17
|
-
}
|
|
18
|
-
`
|
|
19
|
-
}
|
package/src/utils/linaria.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {generateClassName} from '@linaria/utils';
|
|
2
|
-
|
|
3
|
-
export function createCustomClassName(moduleName: string) {
|
|
4
|
-
return (componentPath: string, styleName: string, hash: string) => {
|
|
5
|
-
// Convert component path to PascalCase
|
|
6
|
-
const componentParts = componentPath.split('/');
|
|
7
|
-
const componentName = componentParts
|
|
8
|
-
.map(part => part.charAt(0).toUpperCase() + part.slice(1))
|
|
9
|
-
.join('-');
|
|
10
|
-
|
|
11
|
-
// Convert style name to camelCase
|
|
12
|
-
const styleNameFormatted = styleName
|
|
13
|
-
.replace(/^[A-Z]/, c => c.toLowerCase())
|
|
14
|
-
.replace(/([A-Z])/g, c => `-${c.toLowerCase()}`);
|
|
15
|
-
|
|
16
|
-
// Construct the class name following the pattern:
|
|
17
|
-
// Module-Component-ComponentName__styleName_hash
|
|
18
|
-
return `${moduleName}-Component-${componentName}__${styleNameFormatted}_${hash}`;
|
|
19
|
-
};
|
|
20
|
-
}
|