@xyd-js/components 0.1.0-xyd.2 → 0.1.0-xyd.4
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/CHANGELOG.md +19 -0
- package/dist/{CTABanner-DVtDluuG.js → CTABanner-BX0sOkvP.js} +1 -1
- package/dist/{CTABanner-DVtDluuG.js.map → CTABanner-BX0sOkvP.js.map} +1 -1
- package/dist/CTABanner-Bgr79Lqe.js +2 -0
- package/dist/CTABanner-Bgr79Lqe.js.map +1 -0
- package/dist/CodeSample-BpsiUFZH.js +2 -0
- package/dist/CodeSample-BpsiUFZH.js.map +1 -0
- package/dist/CodeSample-OEtiPDdW.js +2 -0
- package/dist/CodeSample-OEtiPDdW.js.map +1 -0
- package/dist/{HomeView-JIjSATBR.js → HomeView-BaQ94VA7.js} +1 -1
- package/dist/{HomeView-JIjSATBR.js.map → HomeView-BaQ94VA7.js.map} +1 -1
- package/dist/HomeView-Byqn8qbO.js +2 -0
- package/dist/HomeView-Byqn8qbO.js.map +1 -0
- package/dist/{UnderlineNav-Ck16YRuC.js → UnderlineNav-C4GtpoH_.js} +2 -2
- package/dist/{UnderlineNav-Ck16YRuC.js.map → UnderlineNav-C4GtpoH_.js.map} +1 -1
- package/dist/UnderlineNav-CTBRVoit.js +2 -0
- package/dist/UnderlineNav-CTBRVoit.js.map +1 -0
- package/dist/_rollupPluginBabelHelpers-DzVepvvn.js +2 -0
- package/dist/_rollupPluginBabelHelpers-DzVepvvn.js.map +1 -0
- package/dist/_rollupPluginBabelHelpers-NA6nV2VK.js +2 -0
- package/dist/_rollupPluginBabelHelpers-NA6nV2VK.js.map +1 -0
- package/dist/brand.d.ts +2 -1
- package/dist/brand.js +1 -1
- package/dist/coder/themes/cosmo-light.d.ts +5 -0
- package/dist/coder/themes/cosmo-light.js +2 -0
- package/dist/coder/themes/cosmo-light.js.map +1 -0
- package/dist/coder.d.ts +50 -3
- package/dist/coder.js +1 -1
- package/dist/coder.js.map +1 -1
- package/dist/content.d.ts +46 -6
- package/dist/content.js +1 -1
- package/dist/content.js.map +1 -1
- package/dist/index-B_8erDHC.js +2 -0
- package/dist/index-B_8erDHC.js.map +1 -0
- package/dist/index-DBY3gRcL.js +2 -0
- package/dist/index-DBY3gRcL.js.map +1 -0
- package/dist/index.css +50 -48
- package/dist/index.d.ts +1 -1
- package/dist/layouts.d.ts +2 -1
- package/dist/layouts.js +1 -1
- package/dist/layouts.js.map +1 -1
- package/dist/pages.d.ts +2 -1
- package/dist/pages.js +1 -1
- package/dist/pages.js.map +1 -1
- package/dist/{tslib.es6-DNxqyfMY.js → tslib.es6-COc5mhWS.js} +1 -1
- package/dist/tslib.es6-COc5mhWS.js.map +1 -0
- package/dist/tslib.es6-D-wQFpKV.js +2 -0
- package/dist/tslib.es6-D-wQFpKV.js.map +1 -0
- package/dist/views.d.ts +2 -1
- package/dist/views.js +1 -1
- package/dist/writer.d.ts +14 -2
- package/dist/writer.js +1 -1
- package/dist/writer.js.map +1 -1
- package/package.json +5 -2
- package/rollup.config.js +24 -3
- package/src/coder/Code/Code.styles.tsx +50 -0
- package/src/coder/Code/Code.tsx +79 -0
- package/src/coder/Code/annotations.tsx +31 -0
- package/src/coder/Code/highlight.ts +170 -0
- package/src/coder/Code/index.ts +12 -0
- package/src/coder/CodeSample/CodeSample.tsx +30 -133
- package/src/coder/CodeSample/index.ts +0 -1
- package/src/coder/CodeSample/withLocalStored.tsx +1 -1
- package/src/coder/{CodeSample/CodeSample.styles.tsx → CodeTabs/CodeTabs.styles.tsx} +0 -48
- package/src/coder/CodeTabs/CodeTabs.tsx +82 -0
- package/src/coder/CodeTabs/index.ts +6 -0
- package/src/coder/CodeTheme/CodeTheme.tsx +78 -0
- package/src/coder/CodeTheme/index.ts +8 -0
- package/src/coder/index.ts +31 -1
- package/src/coder/{CodeSample/default-theme.ts → themes/cosmo-light.ts} +3 -2
- package/src/content/Content/Content.tsx +1 -0
- package/src/content/Content.tsx +35 -1
- package/src/pages/index.ts +1 -0
- package/src/views/index.ts +1 -0
- package/src/writer/Badge/Badge.styles.tsx +4 -0
- package/src/writer/Badge/Badge.tsx +3 -1
- package/src/writer/Icon/index.tsx +230 -0
- package/dist/CodeSample-CB5kEkeK.js +0 -2
- package/dist/CodeSample-CB5kEkeK.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-DFryr8Hb.js +0 -2
- package/dist/_rollupPluginBabelHelpers-DFryr8Hb.js.map +0 -1
- package/dist/index-CCn_Wv4c.js +0 -2
- package/dist/index-CCn_Wv4c.js.map +0 -1
- package/dist/tslib.es6-DNxqyfMY.js.map +0 -1
|
@@ -1,150 +1,47 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
InnerLine,
|
|
6
|
-
Pre,
|
|
7
|
-
highlight,
|
|
8
|
-
HighlightedCode,
|
|
9
|
-
} from "codehike/code"
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {Theme} from "@code-hike/lighter";
|
|
3
|
+
|
|
4
|
+
import type {CodeThemeBlockProps} from "../CodeTheme";
|
|
10
5
|
|
|
11
6
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {withLocalStored} from "./withLocalStored";
|
|
7
|
+
Code,
|
|
8
|
+
annotations,
|
|
9
|
+
} from "../Code"
|
|
16
10
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
}
|
|
11
|
+
withCodeTabs
|
|
12
|
+
} from "../CodeTabs";
|
|
13
|
+
import {useCodeTheme} from "../CodeTheme";
|
|
35
14
|
|
|
36
15
|
export interface CodeSampleProps {
|
|
37
16
|
name: string;
|
|
38
17
|
description: string;
|
|
39
|
-
codeblocks:
|
|
18
|
+
codeblocks: CodeThemeBlockProps[];
|
|
40
19
|
size?: "full"
|
|
20
|
+
theme?: Theme
|
|
41
21
|
}
|
|
42
22
|
|
|
43
23
|
export function CodeSample(props: CodeSampleProps) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
async function fetchHighlight() {
|
|
48
|
-
const result = await Promise.all(
|
|
49
|
-
props.codeblocks?.map((codeblock) => highlight(codeblock, defaultTheme))
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
setHighlighted(result);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
fetchHighlight();
|
|
56
|
-
}, [props.codeblocks]);
|
|
57
|
-
|
|
58
|
-
if (highlighted.length === 0) {
|
|
59
|
-
return <div>Loading</div>;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (!highlighted) {
|
|
63
|
-
return <div>Loading</div>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<TabsPrimitive.Root
|
|
68
|
-
className={$sample.host}
|
|
69
|
-
style={highlighted[0]?.style}
|
|
70
|
-
defaultValue={highlighted[0]?.meta}
|
|
71
|
-
// localStorageKey={`preferredLanguage[${name}]`}
|
|
72
|
-
>
|
|
73
|
-
<div className={$languages.host}>
|
|
74
|
-
<$Description description={props.description}/>
|
|
75
|
-
|
|
76
|
-
<TabsPrimitive.List className={$languages.list}>
|
|
77
|
-
{props.codeblocks?.map(({meta}, i) => (
|
|
78
|
-
<TabsPrimitive.Trigger value={meta!} key={i} className={$languages.button}>
|
|
79
|
-
{meta}
|
|
80
|
-
</TabsPrimitive.Trigger>
|
|
81
|
-
))}
|
|
82
|
-
</TabsPrimitive.List>
|
|
83
|
-
|
|
84
|
-
<div className={$languages.copy}>
|
|
85
|
-
{props.codeblocks?.map((codeblock, i) => (
|
|
86
|
-
<TabsPrimitive.Content value={codeblock.meta!} asChild key={i}>
|
|
87
|
-
<CodeCopy text={codeblock.value}/>
|
|
88
|
-
</TabsPrimitive.Content>
|
|
89
|
-
))}
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
|
|
93
|
-
{highlighted?.map((codeblock, i) => (
|
|
94
|
-
<TabsPrimitive.Content value={codeblock.meta} key={i}>
|
|
95
|
-
<Pre
|
|
96
|
-
className={`
|
|
97
|
-
${$code.host}
|
|
98
|
-
${props?.size === "full" && $code.host$$full}
|
|
99
|
-
`}
|
|
100
|
-
style={codeblock?.style || codeblock?.style}
|
|
101
|
-
code={codeblock}
|
|
102
|
-
handlers={[mark, lineNumber]}
|
|
103
|
-
/>
|
|
104
|
-
</TabsPrimitive.Content>
|
|
105
|
-
))}
|
|
106
|
-
</TabsPrimitive.Root>
|
|
107
|
-
)
|
|
24
|
+
return <Code codeblocks={props.codeblocks} theme={props.theme}>
|
|
25
|
+
<$ThemedCodeSample {...props}/>
|
|
26
|
+
</Code>
|
|
108
27
|
}
|
|
109
28
|
|
|
110
|
-
function $
|
|
111
|
-
|
|
112
|
-
<div className={$languages.description$item}>
|
|
113
|
-
{props.description}
|
|
114
|
-
</div>
|
|
115
|
-
</div>
|
|
116
|
-
}
|
|
29
|
+
function $ThemedCodeSample(props: CodeSampleProps) {
|
|
30
|
+
const {highlighted} = useCodeTheme()
|
|
117
31
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
<InnerLine
|
|
124
|
-
merge={props}
|
|
125
|
-
className={$mark.line}
|
|
126
|
-
/>
|
|
127
|
-
</div>
|
|
128
|
-
)
|
|
129
|
-
},
|
|
32
|
+
return <$CodeSampleTabs
|
|
33
|
+
description={props.description}
|
|
34
|
+
highlighted={highlighted}
|
|
35
|
+
size={props.size}
|
|
36
|
+
/>
|
|
130
37
|
}
|
|
131
38
|
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
style={{minWidth: `${width}ch`}}
|
|
141
|
-
className={$lineNumber.host}
|
|
142
|
-
>
|
|
143
|
-
{props.lineNumber}
|
|
144
|
-
</span>
|
|
145
|
-
<InnerLine merge={props}/>
|
|
146
|
-
</>
|
|
147
|
-
)
|
|
148
|
-
},
|
|
149
|
-
}
|
|
39
|
+
const $CodeSampleTabs = withCodeTabs((props) => <Code.Pre
|
|
40
|
+
{...props}
|
|
41
|
+
handlers={[
|
|
42
|
+
annotations.mark,
|
|
43
|
+
annotations.bg,
|
|
44
|
+
annotations.lineNumbers
|
|
45
|
+
]}
|
|
46
|
+
/>)
|
|
150
47
|
|
|
@@ -7,7 +7,7 @@ export interface CodeTabsProps {
|
|
|
7
7
|
children: React.ReactNode
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
// TODO:
|
|
10
|
+
// TODO: move to CodeTabs?
|
|
11
11
|
export function withLocalStored(Component: any) {
|
|
12
12
|
return function LocalStored(props: CodeTabsProps) {
|
|
13
13
|
const [value, setValue] = useState(
|
|
@@ -87,51 +87,3 @@ export const $languages = {
|
|
|
87
87
|
`
|
|
88
88
|
}
|
|
89
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 rgb(236, 236, 241);
|
|
99
|
-
border-bottom-left-radius: 10px;
|
|
100
|
-
border-bottom-right-radius: 10px;
|
|
101
|
-
|
|
102
|
-
font-size: 12px;
|
|
103
|
-
line-height: 20px;
|
|
104
|
-
white-space: pre-wrap;
|
|
105
|
-
word-break: break-all;
|
|
106
|
-
|
|
107
|
-
overflow-y: scroll;
|
|
108
|
-
`,
|
|
109
|
-
host$$full: css`
|
|
110
|
-
max-height: 100%;
|
|
111
|
-
`
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export const $mark = {
|
|
115
|
-
host: css`
|
|
116
|
-
display: flex;
|
|
117
|
-
border-left-width: 4px;
|
|
118
|
-
border-color: transparent;
|
|
119
|
-
margin: 4px 0;
|
|
120
|
-
`,
|
|
121
|
-
line: css`
|
|
122
|
-
flex: 1 1 0%;
|
|
123
|
-
`,
|
|
124
|
-
$$annotated: css`
|
|
125
|
-
border-color: #60A5FA;
|
|
126
|
-
background-color: #EEF2FF;
|
|
127
|
-
`
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export const $lineNumber = {
|
|
131
|
-
host: css`
|
|
132
|
-
margin: 0 4px;
|
|
133
|
-
//text-align: right;
|
|
134
|
-
user-select: none;
|
|
135
|
-
opacity: 0.5;
|
|
136
|
-
`
|
|
137
|
-
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, {} from "react";
|
|
2
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
3
|
+
import {
|
|
4
|
+
HighlightedCode,
|
|
5
|
+
} from "codehike/code"
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
CodeCopy,
|
|
9
|
+
} from "../CodeCopy";
|
|
10
|
+
import {
|
|
11
|
+
$sample,
|
|
12
|
+
$languages,
|
|
13
|
+
} from "./CodeTabs.styles.tsx"; // TODO: style by highlighted?
|
|
14
|
+
|
|
15
|
+
export interface CodeTabsProps {
|
|
16
|
+
description: string;
|
|
17
|
+
highlighted: HighlightedCode[]
|
|
18
|
+
size?: "full"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function withCodeTabs(PreComponent) {
|
|
22
|
+
return function CodeTabs(props: CodeTabsProps) {
|
|
23
|
+
return (
|
|
24
|
+
<TabsPrimitive.Root
|
|
25
|
+
className={$sample.host}
|
|
26
|
+
style={props.highlighted[0]?.style}
|
|
27
|
+
defaultValue={props.highlighted[0]?.meta}
|
|
28
|
+
>
|
|
29
|
+
<$LanguageTabSwitcher
|
|
30
|
+
description={props.description}
|
|
31
|
+
highlighted={props.highlighted}
|
|
32
|
+
/>
|
|
33
|
+
|
|
34
|
+
{props.highlighted?.map((codeblock, i) => (
|
|
35
|
+
<TabsPrimitive.Content value={codeblock.meta} key={i}>
|
|
36
|
+
<PreComponent
|
|
37
|
+
style={codeblock?.style || codeblock?.style}
|
|
38
|
+
codeblock={codeblock}
|
|
39
|
+
/>
|
|
40
|
+
</TabsPrimitive.Content>
|
|
41
|
+
))}
|
|
42
|
+
</TabsPrimitive.Root>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface LanguageTabSwitcherProps {
|
|
48
|
+
description: string;
|
|
49
|
+
highlighted: HighlightedCode[]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function $LanguageTabSwitcher(props: LanguageTabSwitcherProps) {
|
|
53
|
+
return <div className={$languages.host}>
|
|
54
|
+
<$Description description={props.description}/>
|
|
55
|
+
|
|
56
|
+
<TabsPrimitive.List className={$languages.list}>
|
|
57
|
+
{props.highlighted?.map(({meta}, i) => (
|
|
58
|
+
<TabsPrimitive.Trigger value={meta!} key={i} className={$languages.button}>
|
|
59
|
+
{meta}
|
|
60
|
+
</TabsPrimitive.Trigger>
|
|
61
|
+
))}
|
|
62
|
+
</TabsPrimitive.List>
|
|
63
|
+
|
|
64
|
+
<div className={$languages.copy}>
|
|
65
|
+
{props.highlighted?.map((codeblock, i) => (
|
|
66
|
+
<TabsPrimitive.Content value={codeblock.meta!} asChild key={i}>
|
|
67
|
+
<CodeCopy text={codeblock.value}/>
|
|
68
|
+
</TabsPrimitive.Content>
|
|
69
|
+
))}
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function $Description(props: { description: string }) {
|
|
75
|
+
return <div className={$languages.description}>
|
|
76
|
+
<div className={$languages.description$item}>
|
|
77
|
+
{props.description}
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React, { createContext, useState, use, useEffect } from "react";
|
|
2
|
+
import { Theme } from "@code-hike/lighter";
|
|
3
|
+
import { highlight } from "codehike/code";
|
|
4
|
+
import type { HighlightedCode } from "codehike/code";
|
|
5
|
+
|
|
6
|
+
import defaultTheme from "../themes/cosmo-light"
|
|
7
|
+
|
|
8
|
+
export interface CodeThemeProps {
|
|
9
|
+
codeblocks: CodeThemeBlockProps[];
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
theme?: Theme;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CodeThemeBlockProps {
|
|
15
|
+
/** This is the raw code. May include annotation comments. */
|
|
16
|
+
value: string;
|
|
17
|
+
/** The programming language. */
|
|
18
|
+
lang: string;
|
|
19
|
+
/** Metadata string (the content after the language name in a markdown codeblock). */
|
|
20
|
+
meta: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const CodeThemeProvider = createContext<{
|
|
24
|
+
highlighted: HighlightedCode[];
|
|
25
|
+
}>({
|
|
26
|
+
highlighted: [],
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export function useCodeTheme() {
|
|
30
|
+
return use(CodeThemeProvider);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function CodeTheme(props: CodeThemeProps) {
|
|
34
|
+
const highlighted = use(
|
|
35
|
+
fetchHighlight(props.codeblocks, props.theme || defaultTheme)
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<CodeThemeProvider
|
|
40
|
+
value={{
|
|
41
|
+
highlighted,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
{props.children}
|
|
45
|
+
</CodeThemeProvider>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// `CodeThemeSync` ?
|
|
50
|
+
export function CodeThemeCSR(props: CodeThemeProps) {
|
|
51
|
+
const [highlighted, setHighlighted] = useState<HighlightedCode[]>([]);
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
fetchHighlight(props.codeblocks, props.theme || defaultTheme).then(
|
|
55
|
+
setHighlighted
|
|
56
|
+
);
|
|
57
|
+
}, [props.codeblocks, props.theme]);
|
|
58
|
+
|
|
59
|
+
if (!highlighted) {
|
|
60
|
+
return <div>loading${`...`}</div>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<CodeThemeProvider
|
|
65
|
+
value={{
|
|
66
|
+
highlighted,
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
{props.children}
|
|
70
|
+
</CodeThemeProvider>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function fetchHighlight(codeblocks: CodeThemeBlockProps[], theme: Theme) {
|
|
75
|
+
return await Promise.all(
|
|
76
|
+
codeblocks?.map((codeblock) => highlight(codeblock, theme))
|
|
77
|
+
);
|
|
78
|
+
}
|
package/src/coder/index.ts
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
export {
|
|
2
|
+
annotations
|
|
3
|
+
} from "./Code"
|
|
4
|
+
export type {
|
|
5
|
+
CodeProps
|
|
6
|
+
} from "./Code"
|
|
7
|
+
export {
|
|
8
|
+
Code
|
|
9
|
+
} from "./Code"
|
|
10
|
+
export {
|
|
11
|
+
highlight
|
|
12
|
+
} from "./Code"
|
|
13
|
+
//
|
|
14
|
+
|
|
15
|
+
export type {CodeSampleProps} from "./CodeSample";
|
|
1
16
|
export {CodeSample} from "./CodeSample";
|
|
17
|
+
//
|
|
18
|
+
|
|
19
|
+
export type {
|
|
20
|
+
CodeTabsProps
|
|
21
|
+
} from "./CodeTabs";
|
|
22
|
+
export {
|
|
23
|
+
withCodeTabs
|
|
24
|
+
} from "./CodeTabs";
|
|
25
|
+
//
|
|
26
|
+
|
|
27
|
+
export type {CodeThemeProps, CodeThemeBlockProps} from "./CodeTheme";
|
|
28
|
+
export {
|
|
29
|
+
CodeTheme,
|
|
30
|
+
CodeThemeCSR,
|
|
2
31
|
|
|
3
|
-
|
|
32
|
+
useCodeTheme
|
|
33
|
+
} from "./CodeTheme";
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import {Theme} from "@code-hike/lighter";
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export default {
|
|
6
|
+
name: "cosmo-light",
|
|
6
7
|
type: "light",
|
|
7
8
|
colors: {
|
|
8
9
|
"list.focusForeground": "#FFFFFF",
|
|
@@ -263,4 +264,4 @@ export const theme: Theme = {
|
|
|
263
264
|
},
|
|
264
265
|
},
|
|
265
266
|
],
|
|
266
|
-
}
|
|
267
|
+
} as Theme
|
package/src/content/Content.tsx
CHANGED
|
@@ -18,6 +18,17 @@ import {
|
|
|
18
18
|
IconFunnels,
|
|
19
19
|
IconMetrics,
|
|
20
20
|
IconSessionReplay,
|
|
21
|
+
IconAlert,
|
|
22
|
+
IconBrowser,
|
|
23
|
+
IconREST,
|
|
24
|
+
IconGraphQL,
|
|
25
|
+
IconWebhooks,
|
|
26
|
+
IconJSBrowser,
|
|
27
|
+
IconJSNode,
|
|
28
|
+
IconStorybook,
|
|
29
|
+
IconReactRouter,
|
|
30
|
+
IconNextJS,
|
|
31
|
+
IconAppTemplate
|
|
21
32
|
} from '../writer'
|
|
22
33
|
import {CodeSample} from "../coder";
|
|
23
34
|
|
|
@@ -27,7 +38,7 @@ import {Anchor} from "./Anchor";
|
|
|
27
38
|
|
|
28
39
|
const EXTERNAL_HREF_REGEX = /https?:\/\//
|
|
29
40
|
|
|
30
|
-
const Link = ({href = '', className, ...props}) => (
|
|
41
|
+
const Link = ({href = '', className = "", ...props}) => (
|
|
31
42
|
<Anchor
|
|
32
43
|
href={href}
|
|
33
44
|
newWindow={EXTERNAL_HREF_REGEX.test(href)}
|
|
@@ -43,6 +54,7 @@ export default function content() {
|
|
|
43
54
|
...helperContent(),
|
|
44
55
|
...iconContent(),
|
|
45
56
|
...coderContent(),
|
|
57
|
+
...directiveContent(),
|
|
46
58
|
}
|
|
47
59
|
}
|
|
48
60
|
|
|
@@ -113,6 +125,17 @@ export function writerContent() {
|
|
|
113
125
|
}
|
|
114
126
|
}
|
|
115
127
|
|
|
128
|
+
export function directiveContent() {
|
|
129
|
+
return {
|
|
130
|
+
DirectiveCodeSample: (props) => {
|
|
131
|
+
return <CodeSample
|
|
132
|
+
{...props}
|
|
133
|
+
codeblocks={JSON.parse(props.codeblocks)}
|
|
134
|
+
/>
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
116
139
|
export function helperContent() {
|
|
117
140
|
return {
|
|
118
141
|
Content: ContentComponent,
|
|
@@ -127,6 +150,17 @@ export function iconContent() {
|
|
|
127
150
|
IconFunnels,
|
|
128
151
|
IconCode,
|
|
129
152
|
IconCustomEvent,
|
|
153
|
+
IconAlert,
|
|
154
|
+
IconBrowser,
|
|
155
|
+
IconREST,
|
|
156
|
+
IconGraphQL,
|
|
157
|
+
IconWebhooks,
|
|
158
|
+
IconJSBrowser,
|
|
159
|
+
IconJSNode,
|
|
160
|
+
IconStorybook,
|
|
161
|
+
IconReactRouter,
|
|
162
|
+
IconNextJS,
|
|
163
|
+
IconAppTemplate,
|
|
130
164
|
}
|
|
131
165
|
}
|
|
132
166
|
|
package/src/pages/index.ts
CHANGED
package/src/views/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface BadgeProps {
|
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
|
|
8
8
|
size?: "sm"
|
|
9
|
-
kind?: "warning"
|
|
9
|
+
kind?: "warning" | "info"
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function Badge({
|
|
@@ -20,6 +20,8 @@ export function Badge({
|
|
|
20
20
|
${size === "sm" && $badge.host$$sm}
|
|
21
21
|
|
|
22
22
|
${kind === "warning" && $badge.host$$warning}
|
|
23
|
+
|
|
24
|
+
${kind === "info" && $badge.host$$info}
|
|
23
25
|
`}>
|
|
24
26
|
<span className={$badge.item}>
|
|
25
27
|
{children}
|