@xyd-js/components 0.1.0-xyd.11 → 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/.idea/git_toolbox_blame.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/xyd-components.iml +12 -0
- package/CHANGELOG.md +16 -0
- package/TODO.md +1 -0
- package/content.ts +0 -2
- package/dist/CTABanner-BD4wweO5.js +2 -0
- package/dist/CTABanner-BD4wweO5.js.map +1 -0
- package/dist/CTABanner-DLG0_gv8.js +2 -0
- package/dist/CTABanner-DLG0_gv8.js.map +1 -0
- package/dist/CTABanner-DpPtA-FL.js +2 -0
- package/dist/CTABanner-DpPtA-FL.js.map +1 -0
- package/dist/CodeSample--qfqZ1hL.js +2 -0
- package/dist/CodeSample--qfqZ1hL.js.map +1 -0
- package/dist/CodeSample-CqFaFwwz.js +2 -0
- package/dist/CodeSample-CqFaFwwz.js.map +1 -0
- package/dist/CodeSample-GbqwRbcO.js +2 -0
- package/dist/CodeSample-GbqwRbcO.js.map +1 -0
- package/dist/HomeView-BZdY0g_7.js +2 -0
- package/dist/{HomeView-DHdqouwJ.js.map → HomeView-BZdY0g_7.js.map} +1 -1
- package/dist/HomeView-C_mEMzjV.js +2 -0
- package/dist/{HomeView-TDx2tcP_.js.map → HomeView-C_mEMzjV.js.map} +1 -1
- package/dist/HomeView-RATm-3zT.js +2 -0
- package/dist/HomeView-RATm-3zT.js.map +1 -0
- package/dist/Icon-BkXdTctK.js +2 -0
- package/dist/Icon-BkXdTctK.js.map +1 -0
- package/dist/Icon-BoKcRZAF.js +2 -0
- package/dist/Icon-BoKcRZAF.js.map +1 -0
- package/dist/Icon-CouPZRkJ.js +2 -0
- package/dist/Icon-CouPZRkJ.js.map +1 -0
- package/dist/Text-B-E3eaWW.js +2 -0
- package/dist/Text-B-E3eaWW.js.map +1 -0
- package/dist/Text-B5Ba_pci.js +2 -0
- package/dist/Text-B5Ba_pci.js.map +1 -0
- package/dist/Text-QH4jjPUM.js +2 -0
- package/dist/Text-QH4jjPUM.js.map +1 -0
- package/dist/Update-BlhP2VFR.js +2 -0
- package/dist/Update-BlhP2VFR.js.map +1 -0
- package/dist/Update-CMM38Snc.js +2 -0
- package/dist/Update-CMM38Snc.js.map +1 -0
- package/dist/Update-D5e_yqty.js +2 -0
- package/dist/Update-D5e_yqty.js.map +1 -0
- package/dist/VideoGuide-C5aW4OXW.js +2 -0
- package/dist/VideoGuide-C5aW4OXW.js.map +1 -0
- package/dist/VideoGuide-CoQXlHjQ.js +2 -0
- package/dist/VideoGuide-CoQXlHjQ.js.map +1 -0
- package/dist/VideoGuide-CwkedH8b.js +2 -0
- package/dist/VideoGuide-CwkedH8b.js.map +1 -0
- package/dist/_rollupPluginBabelHelpers-9wcO9jN6.js +4 -0
- package/dist/_rollupPluginBabelHelpers-9wcO9jN6.js.map +1 -0
- package/dist/_rollupPluginBabelHelpers-CiqSP2w-.js +4 -0
- package/dist/_rollupPluginBabelHelpers-CiqSP2w-.js.map +1 -0
- package/dist/_rollupPluginBabelHelpers-DmvUE1MU.js +4 -0
- package/dist/_rollupPluginBabelHelpers-DmvUE1MU.js.map +1 -0
- package/dist/brand.js +1 -1
- package/dist/brand.js.map +1 -1
- package/dist/coder/themes/cosmo-light.js.map +1 -1
- package/dist/coder.d.ts +32 -10
- package/dist/coder.js +1 -1
- package/dist/coder.js.map +1 -1
- package/dist/content.d.ts +264 -201
- package/dist/content.js +1 -1
- package/dist/content.js.map +1 -1
- package/dist/index.css +260 -210
- package/dist/layouts.d.ts +20 -21
- package/dist/layouts.js +1 -1
- package/dist/layouts.js.map +1 -1
- package/dist/pages.js +1 -1
- package/dist/pages.js.map +1 -1
- package/dist/system.d.ts +10 -0
- package/dist/system.js +2 -0
- package/dist/system.js.map +1 -0
- package/dist/tslib.es6-Bb9zBh0L.js +2 -0
- package/dist/{tslib.es6-BI9zka_a.js.map → tslib.es6-Bb9zBh0L.js.map} +1 -1
- package/dist/tslib.es6-Bd9lzVn6.js +2 -0
- package/dist/{tslib.es6-sxmRJynD.js.map → tslib.es6-Bd9lzVn6.js.map} +1 -1
- package/dist/tslib.es6-DwnOrHRg.js +2 -0
- package/dist/tslib.es6-DwnOrHRg.js.map +1 -0
- package/dist/views.js +1 -1
- package/dist/writer.d.ts +409 -77
- package/dist/writer.js +1 -1
- package/dist/writer.js.map +1 -1
- package/docs/.nojekyll +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +22 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1640 -0
- package/docs/functions/GuideCard.html +6 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +2 -0
- package/docs/interfaces/GuideCardProps.html +18 -0
- package/docs/modules.html +1 -0
- package/index.ts +0 -1
- package/package.json +10 -6
- package/project.json +677 -0
- package/rollup.config.js +30 -20
- package/src/brand/Button/Button.styles.tsx +0 -3
- package/src/brand/CTABanner/CTABanner.styles.tsx +2 -4
- package/src/brand/Footer/Footer.styles.tsx +0 -3
- package/src/coder/Code/Code.styles.tsx +132 -33
- package/src/coder/Code/Code.tsx +129 -38
- package/src/coder/Code/CodeLoader.tsx +3 -3
- package/src/coder/Code/annotations.tsx +28 -8
- package/src/coder/Code/highlight.ts +38 -0
- package/src/coder/Code/index.ts +2 -1
- package/src/coder/CodeCopy/CodeCopy.styles.tsx +13 -11
- package/src/coder/CodeCopy/CodeCopy.tsx +5 -3
- package/src/coder/CodeSample/CodeSample.tsx +83 -27
- package/src/coder/CodeTabs/CodeTabs.styles.tsx +111 -94
- package/src/coder/CodeTabs/CodeTabs.tsx +69 -51
- package/src/coder/CodeTheme/CodeTheme.tsx +89 -49
- package/src/coder/CodeTheme/index.ts +0 -1
- package/src/coder/CoderProvider.tsx +26 -0
- package/src/coder/index.ts +8 -4
- package/src/content/ContentDecoator.styles.tsx +113 -0
- package/src/content/ContentDecorator.tsx +17 -0
- package/src/content/GridDecorator.styles.tsx +67 -0
- package/src/content/GridDecorator.tsx +21 -0
- package/src/content/ReactContent.tsx +575 -0
- package/src/content/index.ts +10 -2
- package/src/icons/index.ts +0 -0
- package/src/kit/Loader/Loader.styles.tsx +53 -0
- package/src/kit/Loader/Loader.tsx +22 -0
- package/src/kit/index.ts +1 -0
- package/src/layouts/LayoutPrimary/LayoutPrimary.styles.tsx +270 -306
- package/src/layouts/LayoutPrimary/LayoutPrimary.tsx +171 -91
- package/src/layouts/LayoutPrimary/index.ts +0 -2
- package/src/layouts/index.ts +0 -7
- package/src/system/SearchButton/SearchButton.styles.tsx +86 -0
- package/src/system/SearchButton/SearchButton.tsx +116 -0
- package/src/system/SearchButton/index.ts +1 -0
- package/src/system/index.ts +1 -0
- package/src/writer/Anchor/Anchor.styles.tsx +11 -0
- package/src/{content → writer}/Anchor/Anchor.tsx +20 -22
- package/src/writer/Anchor/index.tsx +1 -0
- package/src/writer/Badge/Badge.styles.tsx +37 -27
- package/src/writer/Badge/Badge.tsx +34 -48
- package/src/writer/Banner/Banner.styles.tsx +91 -0
- package/src/writer/Banner/Banner.tsx +70 -0
- package/src/writer/Banner/index.ts +1 -0
- package/src/writer/Blockquote/Blockquote.styles.tsx +6 -4
- package/src/writer/Blockquote/Blockquote.tsx +5 -2
- package/src/writer/Breadcrumbs/Breadcrumbs.styles.ts +25 -25
- package/src/writer/Breadcrumbs/Breadcrumbs.tsx +18 -12
- package/src/writer/Button/Button.styles.tsx +137 -0
- package/src/writer/Button/Button.tsx +75 -0
- package/src/writer/Button/index.ts +2 -0
- package/src/writer/Callout/Callout.styles.tsx +35 -42
- package/src/writer/Callout/Callout.tsx +30 -15
- package/src/writer/Card/Card.styles.tsx +47 -0
- package/src/writer/Card/Card.tsx +69 -0
- package/src/writer/Card/index.ts +1 -0
- package/src/writer/Code/Code.styles.tsx +12 -11
- package/src/writer/Code/Code.tsx +6 -3
- package/src/writer/ColorSchemeButton/ColorSchemeButton.tsx +172 -0
- package/src/writer/ColorSchemeButton/index.ts +1 -0
- package/src/writer/Details/Details.styles.tsx +87 -98
- package/src/writer/Details/Details.tsx +65 -44
- package/src/writer/Example/index.tsx +5 -0
- package/src/writer/GuideCard/GuideCard.styles.tsx +100 -103
- package/src/writer/GuideCard/GuideCard.tsx +72 -37
- package/src/writer/Heading/Heading.styles.tsx +76 -60
- package/src/writer/Heading/Heading.tsx +92 -22
- package/src/writer/Hr/Hr.styles.tsx +3 -1
- package/src/writer/Hr/Hr.tsx +2 -5
- package/src/writer/Icon/Icon.tsx +48 -0
- package/src/writer/Icon/index.ts +1 -0
- package/src/writer/Image/Image.styles.tsx +9 -0
- package/src/writer/Image/Image.tsx +19 -0
- package/src/writer/Image/index.ts +1 -0
- package/src/writer/List/List.styles.tsx +47 -0
- package/src/writer/List/List.tsx +29 -0
- package/src/writer/List/index.ts +4 -0
- package/src/writer/NavLinks/NavLinks.styles.ts +26 -26
- package/src/writer/NavLinks/NavLinks.tsx +65 -18
- package/src/writer/Pre/Pre.styles.tsx +8 -6
- package/src/writer/Pre/Pre.tsx +3 -2
- package/src/writer/Steps/Steps.styles.tsx +27 -24
- package/src/writer/Steps/Steps.tsx +38 -8
- package/src/writer/Table/Table.styles.tsx +65 -34
- package/src/writer/Table/Table.tsx +121 -11
- package/src/writer/Table/index.ts +0 -11
- package/src/writer/Tabs/Tabs.styles.tsx +51 -55
- package/src/writer/Tabs/Tabs.tsx +30 -23
- package/src/writer/Text/Text.styles.tsx +66 -0
- package/src/writer/Text/Text.tsx +79 -0
- package/src/writer/Text/index.ts +3 -0
- package/src/writer/TocCard/TocCard.module.css +44 -0
- package/src/writer/TocCard/TocCard.tsx +42 -0
- package/src/writer/TocCard/index.ts +3 -0
- package/src/writer/UnderlineNav/Tabs.tsx +51 -0
- package/src/writer/UnderlineNav/TabsPrimary.styles.tsx +184 -0
- package/src/writer/UnderlineNav/TabsPrimary.tsx +209 -0
- package/src/writer/UnderlineNav/TabsSecondary.styles.tsx +77 -0
- package/src/writer/UnderlineNav/TabsSecondary.tsx +171 -0
- package/src/writer/UnderlineNav/UnderlineNav.styles.tsx +165 -31
- package/src/writer/UnderlineNav/UnderlineNav.tsx +257 -22
- package/src/writer/UnderlineNav/index.ts +2 -1
- package/src/writer/UnderlineNav/useValueChange.ts +60 -0
- package/src/writer/Update/Update.styles.tsx +33 -0
- package/src/writer/Update/Update.tsx +37 -0
- package/src/writer/Update/index.ts +1 -0
- package/src/writer/VideoGuide/VideoGuide.module.css +105 -0
- package/src/writer/VideoGuide/VideoGuide.tsx +75 -0
- package/src/writer/VideoGuide/index.ts +1 -0
- package/src/writer/index.ts +23 -1
- package/tsconfig.json +9 -3
- package/types.d.ts +50 -0
- package/writer.ts +1 -1
- package/dist/CTABanner-BLDHbq5h.js +0 -2
- package/dist/CTABanner-BLDHbq5h.js.map +0 -1
- package/dist/CTABanner-n3vc4xW5.js +0 -2
- package/dist/CTABanner-n3vc4xW5.js.map +0 -1
- package/dist/CodeSample-CVki5fdQ.js +0 -2
- package/dist/CodeSample-CVki5fdQ.js.map +0 -1
- package/dist/CodeSample-Dkob5gWa.js +0 -2
- package/dist/CodeSample-Dkob5gWa.js.map +0 -1
- package/dist/HomeView-DHdqouwJ.js +0 -2
- package/dist/HomeView-TDx2tcP_.js +0 -2
- package/dist/UnderlineNav-9lJPvnIp.js +0 -2
- package/dist/UnderlineNav-9lJPvnIp.js.map +0 -1
- package/dist/UnderlineNav-VqB7jDQD.js +0 -2
- package/dist/UnderlineNav-VqB7jDQD.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-C8nLsqZ7.js +0 -2
- package/dist/_rollupPluginBabelHelpers-C8nLsqZ7.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-CrdNG0jb.js +0 -2
- package/dist/_rollupPluginBabelHelpers-CrdNG0jb.js.map +0 -1
- package/dist/index-TkBHKzGT.js +0 -2
- package/dist/index-TkBHKzGT.js.map +0 -1
- package/dist/index-YH6Q3iH2.js +0 -2
- package/dist/index-YH6Q3iH2.js.map +0 -1
- package/dist/tslib.es6-BI9zka_a.js +0 -2
- package/dist/tslib.es6-sxmRJynD.js +0 -2
- package/src/content/Anchor/Anchor.styles.tsx +0 -5
- package/src/content/Anchor/index.tsx +0 -3
- package/src/content/Content/Content.styles.tsx +0 -9
- package/src/content/Content/Content.tsx +0 -13
- package/src/content/Content/index.tsx +0 -3
- package/src/content/Content.tsx +0 -179
- package/src/content/Subtitle/Subtitle.styles.ts +0 -8
- package/src/content/Subtitle/Subtitle.tsx +0 -12
- package/src/content/Subtitle/index.tsx +0 -3
- package/src/layouts/Layout.styles.tsx +0 -155
- package/src/layouts/Layout.tsx +0 -119
- package/src/ui/Loader/Loader.styles.tsx +0 -54
- package/src/ui/Loader/Loader.tsx +0 -26
- package/src/ui/index.ts +0 -1
- package/src/writer/Icon/index.tsx +0 -355
- package/src/writer/Table/TableV2.styles.tsx +0 -117
- package/src/writer/Table/TableV2.tsx +0 -83
- /package/src/{ui → kit}/TODO.md +0 -0
|
@@ -1,79 +1,119 @@
|
|
|
1
|
-
import React, { createContext, useState, use, useEffect } from "react";
|
|
1
|
+
import React, { createContext, useState, use, useEffect, Suspense } from "react";
|
|
2
2
|
import { Theme } from "@code-hike/lighter";
|
|
3
3
|
import { highlight } from "codehike/code";
|
|
4
4
|
import type { HighlightedCode } from "codehike/code";
|
|
5
5
|
|
|
6
6
|
import defaultTheme from "../themes/cosmo-light"
|
|
7
|
-
import { Loader } from "../../
|
|
7
|
+
import { Loader } from "../../kit";
|
|
8
8
|
|
|
9
9
|
export interface CodeThemeProps {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
codeblocks?: CodeThemeBlockProps[];
|
|
11
|
+
theme?: Theme
|
|
12
|
+
children: React.ReactNode;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface CodeThemeBlockProps {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
/** This is the raw code. May include annotation comments. */
|
|
17
|
+
value: string;
|
|
18
|
+
/** The programming language. */
|
|
19
|
+
lang: string;
|
|
20
|
+
/** Metadata string (the content after the language name in a markdown codeblock). */
|
|
21
|
+
meta: string;
|
|
22
|
+
|
|
23
|
+
/** The highlighted code. */
|
|
24
|
+
highlighted?: HighlightedCode
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
const CodeThemeProvider = createContext<{
|
|
25
|
-
|
|
28
|
+
highlighted: HighlightedCode[];
|
|
26
29
|
}>({
|
|
27
|
-
|
|
30
|
+
highlighted: [],
|
|
28
31
|
});
|
|
29
32
|
|
|
30
33
|
export function useCodeTheme() {
|
|
31
|
-
|
|
34
|
+
return use(CodeThemeProvider);
|
|
32
35
|
}
|
|
33
36
|
|
|
37
|
+
// TODO: lazy-loading - some codeblocks on server and another on client
|
|
38
|
+
// TODO: lazdy client loading only on specific codeblock
|
|
34
39
|
export function CodeTheme(props: CodeThemeProps) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<CodeThemeProvider
|
|
41
|
-
value={{
|
|
42
|
-
highlighted,
|
|
43
|
-
}}
|
|
44
|
-
>
|
|
45
|
-
{props.children}
|
|
46
|
-
</CodeThemeProvider>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
40
|
+
// Initialize with server-side highlighted codeblocks
|
|
41
|
+
const [highlighted, setHighlighted] = useState<HighlightedCode[] | undefined>(initializeHighlighted(props.codeblocks));
|
|
42
|
+
const [clientSideFetch, setClientSideFetch] = useState(true)
|
|
49
43
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
setHighlighted(initializeHighlighted(props.codeblocks))
|
|
46
|
+
}, [props.codeblocks])
|
|
53
47
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!props.codeblocks) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Check if we need to highlight any codeblocks
|
|
54
|
+
const needsHighlighting = props.codeblocks.some(
|
|
55
|
+
codeblock => !codeblock.highlighted || !codeblock.highlighted.tokens
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (needsHighlighting) {
|
|
59
|
+
clientSideHighlight();
|
|
60
|
+
}
|
|
61
|
+
}, [props.codeblocks]);
|
|
62
|
+
|
|
63
|
+
function initializeHighlighted(codeblocks: any) {
|
|
64
|
+
if (!codeblocks) return [];
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
return codeblocks.map(codeblock => {
|
|
67
|
+
if (codeblock.highlighted && codeblock.highlighted.tokens) {
|
|
68
|
+
return {
|
|
69
|
+
...codeblock.highlighted,
|
|
70
|
+
meta: codeblock.highlighted?.meta || codeblock.meta,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
63
73
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
return null
|
|
75
|
+
}).filter(Boolean) as HighlightedCode[]
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function clientSideHighlight() {
|
|
79
|
+
if (!props.codeblocks) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const allHighlighted = props.codeblocks.every(codeblock => codeblock.highlighted)
|
|
84
|
+
if (allHighlighted) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const newHighlighted = await fetchHighlight(props.codeblocks, props.theme || defaultTheme);
|
|
89
|
+
setHighlighted(newHighlighted)
|
|
90
|
+
|
|
91
|
+
setClientSideFetch(false)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const withTheme = <CodeThemeProvider
|
|
95
|
+
value={{
|
|
96
|
+
highlighted: highlighted || [],
|
|
97
|
+
}}
|
|
69
98
|
>
|
|
70
|
-
|
|
99
|
+
{props.children}
|
|
71
100
|
</CodeThemeProvider>
|
|
72
|
-
|
|
101
|
+
|
|
102
|
+
const allHighlighted = props.codeblocks?.every(codeblock => codeblock.highlighted)
|
|
103
|
+
if (allHighlighted) {
|
|
104
|
+
return withTheme
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (clientSideFetch) {
|
|
108
|
+
return <Loader />
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return withTheme
|
|
73
112
|
}
|
|
74
113
|
|
|
114
|
+
// TODO: own server with grammars (codehike)
|
|
75
115
|
async function fetchHighlight(codeblocks: CodeThemeBlockProps[], theme: Theme) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
116
|
+
return await Promise.all(
|
|
117
|
+
codeblocks?.map((codeblock) => highlight(codeblock, theme))
|
|
118
|
+
);
|
|
79
119
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
|
|
4
|
+
const CoderContext = createContext<{
|
|
5
|
+
lines?: boolean
|
|
6
|
+
scroll?: boolean
|
|
7
|
+
}>({
|
|
8
|
+
lines: undefined,
|
|
9
|
+
scroll: undefined,
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
interface CoderProviderProps {
|
|
14
|
+
children: React.ReactNode
|
|
15
|
+
|
|
16
|
+
lines?: boolean
|
|
17
|
+
|
|
18
|
+
scroll?: boolean
|
|
19
|
+
}
|
|
20
|
+
export function CoderProvider({ children, lines, scroll }: CoderProviderProps) {
|
|
21
|
+
return <CoderContext.Provider value={{ lines, scroll }}>{children}</CoderContext.Provider>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function useCoder() {
|
|
25
|
+
return useContext(CoderContext)
|
|
26
|
+
}
|
package/src/coder/index.ts
CHANGED
|
@@ -8,12 +8,13 @@ export {
|
|
|
8
8
|
Code,
|
|
9
9
|
CodeLoader,
|
|
10
10
|
|
|
11
|
+
highlightAsync,
|
|
11
12
|
highlight
|
|
12
13
|
} from "./Code"
|
|
13
14
|
//
|
|
14
15
|
|
|
15
|
-
export type {CodeSampleProps} from "./CodeSample";
|
|
16
|
-
export {CodeSample} from "./CodeSample";
|
|
16
|
+
export type { CodeSampleProps } from "./CodeSample";
|
|
17
|
+
export { CodeSample } from "./CodeSample";
|
|
17
18
|
//
|
|
18
19
|
|
|
19
20
|
export type {
|
|
@@ -24,10 +25,13 @@ export {
|
|
|
24
25
|
} from "./CodeTabs";
|
|
25
26
|
//
|
|
26
27
|
|
|
27
|
-
export type {CodeThemeProps, CodeThemeBlockProps} from "./CodeTheme";
|
|
28
|
+
export type { CodeThemeProps, CodeThemeBlockProps } from "./CodeTheme";
|
|
28
29
|
export {
|
|
29
30
|
CodeTheme,
|
|
30
|
-
CodeThemeCSR,
|
|
31
31
|
|
|
32
32
|
useCodeTheme
|
|
33
33
|
} from "./CodeTheme";
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
CoderProvider
|
|
37
|
+
} from "./CoderProvider";
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { css } from "@linaria/core";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
ContentDecoratorHost: css`
|
|
5
|
+
@layer components {
|
|
6
|
+
--space-small: 8px;
|
|
7
|
+
--space-medium: 16px;
|
|
8
|
+
--space-large: 20px;
|
|
9
|
+
--space-xlarge: 24px;
|
|
10
|
+
--space-xxlarge: 32px;
|
|
11
|
+
--space-2xlarge: 50px;
|
|
12
|
+
|
|
13
|
+
font-size: var(--xyd-font-size-medium);
|
|
14
|
+
line-height: var(--xyd-line-height-medium);
|
|
15
|
+
|
|
16
|
+
p:not(li p):not(ul p):not(xyd-callout p):not(xyd-codetabs p):not(xyd-guidecard p):not([data-button="true"] p) {
|
|
17
|
+
margin-top: var(--space-medium);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
details {
|
|
21
|
+
--xyd-callout-bgcolor: var(--white);
|
|
22
|
+
margin-top: var(--space-medium);
|
|
23
|
+
|
|
24
|
+
summary {
|
|
25
|
+
[part="summary-deep"], [part="summary-deep-label"] {
|
|
26
|
+
font-size: var(--xyd-font-size-small);
|
|
27
|
+
line-height: var(--xyd-line-height-small);
|
|
28
|
+
}
|
|
29
|
+
[part="summary-deep-label"] {
|
|
30
|
+
font-weight: bold;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&[data-kind="secondary"] {
|
|
35
|
+
code {
|
|
36
|
+
background: var(--xyd-details-bgcolor--secondary);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
hr {
|
|
42
|
+
margin: var(--space-xxlarge) 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
p {
|
|
46
|
+
display: block;
|
|
47
|
+
|
|
48
|
+
code {
|
|
49
|
+
font-size: var(--xyd-font-size-small);
|
|
50
|
+
line-height: var(--xyd-line-height-small);
|
|
51
|
+
margin: 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
h2,h3,h4,h5,h6 {
|
|
56
|
+
margin-top: var(--space-xxlarge);
|
|
57
|
+
&[data-kind="muted"] {
|
|
58
|
+
display: block;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
h2 {
|
|
62
|
+
margin-top: var(--space-2xlarge);
|
|
63
|
+
}
|
|
64
|
+
h2:first-of-type {
|
|
65
|
+
margin-top: var(--space-xxlarge);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
h4 {
|
|
69
|
+
&[data-kind="muted"] {
|
|
70
|
+
margin: 4px 0 16px;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
ul:not(xyd-underlinenav ul), ol:not(xyd-underlinenav ol) {
|
|
76
|
+
margin-top: var(--space-medium);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
xyd-codetabs, xyd-callout, xyd-guidecard, xyd-tabs {
|
|
80
|
+
margin: var(--space-large) 0;
|
|
81
|
+
}
|
|
82
|
+
xyd-guidecard [part="body"] {
|
|
83
|
+
color: var(--dark48);
|
|
84
|
+
font-size: var(--xyd-font-size-small);
|
|
85
|
+
line-height: var(--xyd-line-height-medium);
|
|
86
|
+
|
|
87
|
+
p {
|
|
88
|
+
color: var(--dark48);
|
|
89
|
+
font-size: var(--xyd-font-size-small);
|
|
90
|
+
line-height: var(--xyd-line-height-medium);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
xyd-guidecard-list xyd-guidecard {
|
|
94
|
+
margin-bottom: 0;
|
|
95
|
+
}
|
|
96
|
+
xyd-tabs [part="buttons"] {
|
|
97
|
+
font-size: var(--xyd-font-size-small);
|
|
98
|
+
line-height: var(--xyd-line-height-small);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
xyd-callout {
|
|
102
|
+
--xyd-font-size-medium: var(--xyd-font-size-small);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
xyd-codetabs {
|
|
106
|
+
xyd-code-pre {
|
|
107
|
+
font-size: var(--xyd-font-size-xsmall);
|
|
108
|
+
line-height: var(--xyd-line-height-xsmall);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
`
|
|
113
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import cn from "./ContentDecoator.styles";
|
|
4
|
+
|
|
5
|
+
interface ContentDecoratorProps {
|
|
6
|
+
children: React.ReactNode
|
|
7
|
+
metaComponent?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function ContentDecorator({ children, metaComponent }: ContentDecoratorProps) {
|
|
11
|
+
return <xyd-content-decorator
|
|
12
|
+
className={cn.ContentDecoratorHost}
|
|
13
|
+
meta-component={metaComponent || undefined}
|
|
14
|
+
>
|
|
15
|
+
{children}
|
|
16
|
+
</xyd-content-decorator>
|
|
17
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { css } from "@linaria/core";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
GridDecoratorHost: css`
|
|
5
|
+
@layer components {
|
|
6
|
+
display: grid;
|
|
7
|
+
gap: 1rem;
|
|
8
|
+
width: 100%;
|
|
9
|
+
|
|
10
|
+
/* First level ul - 1fr */
|
|
11
|
+
> ul {
|
|
12
|
+
display: grid;
|
|
13
|
+
grid-template-columns: 1fr;
|
|
14
|
+
gap: 1rem;
|
|
15
|
+
width: 100%;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Nested ul - 2fr */
|
|
19
|
+
ul ul {
|
|
20
|
+
display: grid;
|
|
21
|
+
grid-template-columns: repeat(2, 1fr);
|
|
22
|
+
gap: 1rem;
|
|
23
|
+
width: 100%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&[data-cols] {
|
|
27
|
+
--cols: var(--data-cols, 2);
|
|
28
|
+
ul ul {
|
|
29
|
+
grid-template-columns: repeat(var(--cols), 1fr);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&[data-cols="2"] { --data-cols: 2; }
|
|
34
|
+
&[data-cols="3"] { --data-cols: 3; }
|
|
35
|
+
&[data-cols="4"] { --data-cols: 4; }
|
|
36
|
+
&[data-cols="5"] { --data-cols: 5; }
|
|
37
|
+
&[data-cols="6"] { --data-cols: 6; }
|
|
38
|
+
|
|
39
|
+
@media (max-width: 768px) {
|
|
40
|
+
> ul {
|
|
41
|
+
gap: 0;
|
|
42
|
+
}
|
|
43
|
+
ul ul {
|
|
44
|
+
grid-template-columns: 1fr;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
ul, ol, li {
|
|
49
|
+
&::before {
|
|
50
|
+
content: none;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
ul, ol {
|
|
55
|
+
display: grid;
|
|
56
|
+
margin: 0;
|
|
57
|
+
padding: 0 !important;
|
|
58
|
+
list-style: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
li {
|
|
62
|
+
margin-left: 0 !important;
|
|
63
|
+
padding-left: 0 !important;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`
|
|
67
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import cn from "./GridDecorator.styles";
|
|
4
|
+
|
|
5
|
+
interface GridDecoratorProps {
|
|
6
|
+
cols?: 2 | 3 | 4 | 5 | 6
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A wrapper component that applies grid decoration styling to its children.
|
|
10
|
+
* This component uses a custom element `xyd-grid-decorator` to provide grid-based layout decoration.
|
|
11
|
+
*
|
|
12
|
+
* @category Component
|
|
13
|
+
*/
|
|
14
|
+
export function GridDecorator({ children, cols }: GridDecoratorProps) {
|
|
15
|
+
return <xyd-grid-decorator
|
|
16
|
+
className={cn.GridDecoratorHost}
|
|
17
|
+
data-cols={cols}
|
|
18
|
+
>
|
|
19
|
+
{children}
|
|
20
|
+
</xyd-grid-decorator>
|
|
21
|
+
}
|