@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.
Files changed (256) hide show
  1. package/.idea/git_toolbox_blame.xml +6 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/vcs.xml +6 -0
  4. package/.idea/xyd-components.iml +12 -0
  5. package/CHANGELOG.md +16 -0
  6. package/TODO.md +1 -0
  7. package/content.ts +0 -2
  8. package/dist/CTABanner-BD4wweO5.js +2 -0
  9. package/dist/CTABanner-BD4wweO5.js.map +1 -0
  10. package/dist/CTABanner-DLG0_gv8.js +2 -0
  11. package/dist/CTABanner-DLG0_gv8.js.map +1 -0
  12. package/dist/CTABanner-DpPtA-FL.js +2 -0
  13. package/dist/CTABanner-DpPtA-FL.js.map +1 -0
  14. package/dist/CodeSample--qfqZ1hL.js +2 -0
  15. package/dist/CodeSample--qfqZ1hL.js.map +1 -0
  16. package/dist/CodeSample-CqFaFwwz.js +2 -0
  17. package/dist/CodeSample-CqFaFwwz.js.map +1 -0
  18. package/dist/CodeSample-GbqwRbcO.js +2 -0
  19. package/dist/CodeSample-GbqwRbcO.js.map +1 -0
  20. package/dist/HomeView-BZdY0g_7.js +2 -0
  21. package/dist/{HomeView-DHdqouwJ.js.map → HomeView-BZdY0g_7.js.map} +1 -1
  22. package/dist/HomeView-C_mEMzjV.js +2 -0
  23. package/dist/{HomeView-TDx2tcP_.js.map → HomeView-C_mEMzjV.js.map} +1 -1
  24. package/dist/HomeView-RATm-3zT.js +2 -0
  25. package/dist/HomeView-RATm-3zT.js.map +1 -0
  26. package/dist/Icon-BkXdTctK.js +2 -0
  27. package/dist/Icon-BkXdTctK.js.map +1 -0
  28. package/dist/Icon-BoKcRZAF.js +2 -0
  29. package/dist/Icon-BoKcRZAF.js.map +1 -0
  30. package/dist/Icon-CouPZRkJ.js +2 -0
  31. package/dist/Icon-CouPZRkJ.js.map +1 -0
  32. package/dist/Text-B-E3eaWW.js +2 -0
  33. package/dist/Text-B-E3eaWW.js.map +1 -0
  34. package/dist/Text-B5Ba_pci.js +2 -0
  35. package/dist/Text-B5Ba_pci.js.map +1 -0
  36. package/dist/Text-QH4jjPUM.js +2 -0
  37. package/dist/Text-QH4jjPUM.js.map +1 -0
  38. package/dist/Update-BlhP2VFR.js +2 -0
  39. package/dist/Update-BlhP2VFR.js.map +1 -0
  40. package/dist/Update-CMM38Snc.js +2 -0
  41. package/dist/Update-CMM38Snc.js.map +1 -0
  42. package/dist/Update-D5e_yqty.js +2 -0
  43. package/dist/Update-D5e_yqty.js.map +1 -0
  44. package/dist/VideoGuide-C5aW4OXW.js +2 -0
  45. package/dist/VideoGuide-C5aW4OXW.js.map +1 -0
  46. package/dist/VideoGuide-CoQXlHjQ.js +2 -0
  47. package/dist/VideoGuide-CoQXlHjQ.js.map +1 -0
  48. package/dist/VideoGuide-CwkedH8b.js +2 -0
  49. package/dist/VideoGuide-CwkedH8b.js.map +1 -0
  50. package/dist/_rollupPluginBabelHelpers-9wcO9jN6.js +4 -0
  51. package/dist/_rollupPluginBabelHelpers-9wcO9jN6.js.map +1 -0
  52. package/dist/_rollupPluginBabelHelpers-CiqSP2w-.js +4 -0
  53. package/dist/_rollupPluginBabelHelpers-CiqSP2w-.js.map +1 -0
  54. package/dist/_rollupPluginBabelHelpers-DmvUE1MU.js +4 -0
  55. package/dist/_rollupPluginBabelHelpers-DmvUE1MU.js.map +1 -0
  56. package/dist/brand.js +1 -1
  57. package/dist/brand.js.map +1 -1
  58. package/dist/coder/themes/cosmo-light.js.map +1 -1
  59. package/dist/coder.d.ts +32 -10
  60. package/dist/coder.js +1 -1
  61. package/dist/coder.js.map +1 -1
  62. package/dist/content.d.ts +264 -201
  63. package/dist/content.js +1 -1
  64. package/dist/content.js.map +1 -1
  65. package/dist/index.css +260 -210
  66. package/dist/layouts.d.ts +20 -21
  67. package/dist/layouts.js +1 -1
  68. package/dist/layouts.js.map +1 -1
  69. package/dist/pages.js +1 -1
  70. package/dist/pages.js.map +1 -1
  71. package/dist/system.d.ts +10 -0
  72. package/dist/system.js +2 -0
  73. package/dist/system.js.map +1 -0
  74. package/dist/tslib.es6-Bb9zBh0L.js +2 -0
  75. package/dist/{tslib.es6-BI9zka_a.js.map → tslib.es6-Bb9zBh0L.js.map} +1 -1
  76. package/dist/tslib.es6-Bd9lzVn6.js +2 -0
  77. package/dist/{tslib.es6-sxmRJynD.js.map → tslib.es6-Bd9lzVn6.js.map} +1 -1
  78. package/dist/tslib.es6-DwnOrHRg.js +2 -0
  79. package/dist/tslib.es6-DwnOrHRg.js.map +1 -0
  80. package/dist/views.js +1 -1
  81. package/dist/writer.d.ts +409 -77
  82. package/dist/writer.js +1 -1
  83. package/dist/writer.js.map +1 -1
  84. package/docs/.nojekyll +1 -0
  85. package/docs/assets/hierarchy.js +1 -0
  86. package/docs/assets/highlight.css +22 -0
  87. package/docs/assets/icons.js +18 -0
  88. package/docs/assets/icons.svg +1 -0
  89. package/docs/assets/main.js +60 -0
  90. package/docs/assets/navigation.js +1 -0
  91. package/docs/assets/search.js +1 -0
  92. package/docs/assets/style.css +1640 -0
  93. package/docs/functions/GuideCard.html +6 -0
  94. package/docs/hierarchy.html +1 -0
  95. package/docs/index.html +2 -0
  96. package/docs/interfaces/GuideCardProps.html +18 -0
  97. package/docs/modules.html +1 -0
  98. package/index.ts +0 -1
  99. package/package.json +10 -6
  100. package/project.json +677 -0
  101. package/rollup.config.js +30 -20
  102. package/src/brand/Button/Button.styles.tsx +0 -3
  103. package/src/brand/CTABanner/CTABanner.styles.tsx +2 -4
  104. package/src/brand/Footer/Footer.styles.tsx +0 -3
  105. package/src/coder/Code/Code.styles.tsx +132 -33
  106. package/src/coder/Code/Code.tsx +129 -38
  107. package/src/coder/Code/CodeLoader.tsx +3 -3
  108. package/src/coder/Code/annotations.tsx +28 -8
  109. package/src/coder/Code/highlight.ts +38 -0
  110. package/src/coder/Code/index.ts +2 -1
  111. package/src/coder/CodeCopy/CodeCopy.styles.tsx +13 -11
  112. package/src/coder/CodeCopy/CodeCopy.tsx +5 -3
  113. package/src/coder/CodeSample/CodeSample.tsx +83 -27
  114. package/src/coder/CodeTabs/CodeTabs.styles.tsx +111 -94
  115. package/src/coder/CodeTabs/CodeTabs.tsx +69 -51
  116. package/src/coder/CodeTheme/CodeTheme.tsx +89 -49
  117. package/src/coder/CodeTheme/index.ts +0 -1
  118. package/src/coder/CoderProvider.tsx +26 -0
  119. package/src/coder/index.ts +8 -4
  120. package/src/content/ContentDecoator.styles.tsx +113 -0
  121. package/src/content/ContentDecorator.tsx +17 -0
  122. package/src/content/GridDecorator.styles.tsx +67 -0
  123. package/src/content/GridDecorator.tsx +21 -0
  124. package/src/content/ReactContent.tsx +575 -0
  125. package/src/content/index.ts +10 -2
  126. package/src/icons/index.ts +0 -0
  127. package/src/kit/Loader/Loader.styles.tsx +53 -0
  128. package/src/kit/Loader/Loader.tsx +22 -0
  129. package/src/kit/index.ts +1 -0
  130. package/src/layouts/LayoutPrimary/LayoutPrimary.styles.tsx +270 -306
  131. package/src/layouts/LayoutPrimary/LayoutPrimary.tsx +171 -91
  132. package/src/layouts/LayoutPrimary/index.ts +0 -2
  133. package/src/layouts/index.ts +0 -7
  134. package/src/system/SearchButton/SearchButton.styles.tsx +86 -0
  135. package/src/system/SearchButton/SearchButton.tsx +116 -0
  136. package/src/system/SearchButton/index.ts +1 -0
  137. package/src/system/index.ts +1 -0
  138. package/src/writer/Anchor/Anchor.styles.tsx +11 -0
  139. package/src/{content → writer}/Anchor/Anchor.tsx +20 -22
  140. package/src/writer/Anchor/index.tsx +1 -0
  141. package/src/writer/Badge/Badge.styles.tsx +37 -27
  142. package/src/writer/Badge/Badge.tsx +34 -48
  143. package/src/writer/Banner/Banner.styles.tsx +91 -0
  144. package/src/writer/Banner/Banner.tsx +70 -0
  145. package/src/writer/Banner/index.ts +1 -0
  146. package/src/writer/Blockquote/Blockquote.styles.tsx +6 -4
  147. package/src/writer/Blockquote/Blockquote.tsx +5 -2
  148. package/src/writer/Breadcrumbs/Breadcrumbs.styles.ts +25 -25
  149. package/src/writer/Breadcrumbs/Breadcrumbs.tsx +18 -12
  150. package/src/writer/Button/Button.styles.tsx +137 -0
  151. package/src/writer/Button/Button.tsx +75 -0
  152. package/src/writer/Button/index.ts +2 -0
  153. package/src/writer/Callout/Callout.styles.tsx +35 -42
  154. package/src/writer/Callout/Callout.tsx +30 -15
  155. package/src/writer/Card/Card.styles.tsx +47 -0
  156. package/src/writer/Card/Card.tsx +69 -0
  157. package/src/writer/Card/index.ts +1 -0
  158. package/src/writer/Code/Code.styles.tsx +12 -11
  159. package/src/writer/Code/Code.tsx +6 -3
  160. package/src/writer/ColorSchemeButton/ColorSchemeButton.tsx +172 -0
  161. package/src/writer/ColorSchemeButton/index.ts +1 -0
  162. package/src/writer/Details/Details.styles.tsx +87 -98
  163. package/src/writer/Details/Details.tsx +65 -44
  164. package/src/writer/Example/index.tsx +5 -0
  165. package/src/writer/GuideCard/GuideCard.styles.tsx +100 -103
  166. package/src/writer/GuideCard/GuideCard.tsx +72 -37
  167. package/src/writer/Heading/Heading.styles.tsx +76 -60
  168. package/src/writer/Heading/Heading.tsx +92 -22
  169. package/src/writer/Hr/Hr.styles.tsx +3 -1
  170. package/src/writer/Hr/Hr.tsx +2 -5
  171. package/src/writer/Icon/Icon.tsx +48 -0
  172. package/src/writer/Icon/index.ts +1 -0
  173. package/src/writer/Image/Image.styles.tsx +9 -0
  174. package/src/writer/Image/Image.tsx +19 -0
  175. package/src/writer/Image/index.ts +1 -0
  176. package/src/writer/List/List.styles.tsx +47 -0
  177. package/src/writer/List/List.tsx +29 -0
  178. package/src/writer/List/index.ts +4 -0
  179. package/src/writer/NavLinks/NavLinks.styles.ts +26 -26
  180. package/src/writer/NavLinks/NavLinks.tsx +65 -18
  181. package/src/writer/Pre/Pre.styles.tsx +8 -6
  182. package/src/writer/Pre/Pre.tsx +3 -2
  183. package/src/writer/Steps/Steps.styles.tsx +27 -24
  184. package/src/writer/Steps/Steps.tsx +38 -8
  185. package/src/writer/Table/Table.styles.tsx +65 -34
  186. package/src/writer/Table/Table.tsx +121 -11
  187. package/src/writer/Table/index.ts +0 -11
  188. package/src/writer/Tabs/Tabs.styles.tsx +51 -55
  189. package/src/writer/Tabs/Tabs.tsx +30 -23
  190. package/src/writer/Text/Text.styles.tsx +66 -0
  191. package/src/writer/Text/Text.tsx +79 -0
  192. package/src/writer/Text/index.ts +3 -0
  193. package/src/writer/TocCard/TocCard.module.css +44 -0
  194. package/src/writer/TocCard/TocCard.tsx +42 -0
  195. package/src/writer/TocCard/index.ts +3 -0
  196. package/src/writer/UnderlineNav/Tabs.tsx +51 -0
  197. package/src/writer/UnderlineNav/TabsPrimary.styles.tsx +184 -0
  198. package/src/writer/UnderlineNav/TabsPrimary.tsx +209 -0
  199. package/src/writer/UnderlineNav/TabsSecondary.styles.tsx +77 -0
  200. package/src/writer/UnderlineNav/TabsSecondary.tsx +171 -0
  201. package/src/writer/UnderlineNav/UnderlineNav.styles.tsx +165 -31
  202. package/src/writer/UnderlineNav/UnderlineNav.tsx +257 -22
  203. package/src/writer/UnderlineNav/index.ts +2 -1
  204. package/src/writer/UnderlineNav/useValueChange.ts +60 -0
  205. package/src/writer/Update/Update.styles.tsx +33 -0
  206. package/src/writer/Update/Update.tsx +37 -0
  207. package/src/writer/Update/index.ts +1 -0
  208. package/src/writer/VideoGuide/VideoGuide.module.css +105 -0
  209. package/src/writer/VideoGuide/VideoGuide.tsx +75 -0
  210. package/src/writer/VideoGuide/index.ts +1 -0
  211. package/src/writer/index.ts +23 -1
  212. package/tsconfig.json +9 -3
  213. package/types.d.ts +50 -0
  214. package/writer.ts +1 -1
  215. package/dist/CTABanner-BLDHbq5h.js +0 -2
  216. package/dist/CTABanner-BLDHbq5h.js.map +0 -1
  217. package/dist/CTABanner-n3vc4xW5.js +0 -2
  218. package/dist/CTABanner-n3vc4xW5.js.map +0 -1
  219. package/dist/CodeSample-CVki5fdQ.js +0 -2
  220. package/dist/CodeSample-CVki5fdQ.js.map +0 -1
  221. package/dist/CodeSample-Dkob5gWa.js +0 -2
  222. package/dist/CodeSample-Dkob5gWa.js.map +0 -1
  223. package/dist/HomeView-DHdqouwJ.js +0 -2
  224. package/dist/HomeView-TDx2tcP_.js +0 -2
  225. package/dist/UnderlineNav-9lJPvnIp.js +0 -2
  226. package/dist/UnderlineNav-9lJPvnIp.js.map +0 -1
  227. package/dist/UnderlineNav-VqB7jDQD.js +0 -2
  228. package/dist/UnderlineNav-VqB7jDQD.js.map +0 -1
  229. package/dist/_rollupPluginBabelHelpers-C8nLsqZ7.js +0 -2
  230. package/dist/_rollupPluginBabelHelpers-C8nLsqZ7.js.map +0 -1
  231. package/dist/_rollupPluginBabelHelpers-CrdNG0jb.js +0 -2
  232. package/dist/_rollupPluginBabelHelpers-CrdNG0jb.js.map +0 -1
  233. package/dist/index-TkBHKzGT.js +0 -2
  234. package/dist/index-TkBHKzGT.js.map +0 -1
  235. package/dist/index-YH6Q3iH2.js +0 -2
  236. package/dist/index-YH6Q3iH2.js.map +0 -1
  237. package/dist/tslib.es6-BI9zka_a.js +0 -2
  238. package/dist/tslib.es6-sxmRJynD.js +0 -2
  239. package/src/content/Anchor/Anchor.styles.tsx +0 -5
  240. package/src/content/Anchor/index.tsx +0 -3
  241. package/src/content/Content/Content.styles.tsx +0 -9
  242. package/src/content/Content/Content.tsx +0 -13
  243. package/src/content/Content/index.tsx +0 -3
  244. package/src/content/Content.tsx +0 -179
  245. package/src/content/Subtitle/Subtitle.styles.ts +0 -8
  246. package/src/content/Subtitle/Subtitle.tsx +0 -12
  247. package/src/content/Subtitle/index.tsx +0 -3
  248. package/src/layouts/Layout.styles.tsx +0 -155
  249. package/src/layouts/Layout.tsx +0 -119
  250. package/src/ui/Loader/Loader.styles.tsx +0 -54
  251. package/src/ui/Loader/Loader.tsx +0 -26
  252. package/src/ui/index.ts +0 -1
  253. package/src/writer/Icon/index.tsx +0 -355
  254. package/src/writer/Table/TableV2.styles.tsx +0 -117
  255. package/src/writer/Table/TableV2.tsx +0 -83
  256. /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 "../../ui";
7
+ import { Loader } from "../../kit";
8
8
 
9
9
  export interface CodeThemeProps {
10
- codeblocks: CodeThemeBlockProps[];
11
- children: React.ReactNode;
12
- theme?: Theme;
10
+ codeblocks?: CodeThemeBlockProps[];
11
+ theme?: Theme
12
+ children: React.ReactNode;
13
13
  }
14
14
 
15
15
  export interface CodeThemeBlockProps {
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;
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
- highlighted: HighlightedCode[];
28
+ highlighted: HighlightedCode[];
26
29
  }>({
27
- highlighted: [],
30
+ highlighted: [],
28
31
  });
29
32
 
30
33
  export function useCodeTheme() {
31
- return use(CodeThemeProvider);
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
- const highlighted = use(
36
- fetchHighlight(props.codeblocks, props.theme || defaultTheme)
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
- // `CodeThemeSync` ?
51
- export function CodeThemeCSR(props: CodeThemeProps) {
52
- const [highlighted, setHighlighted] = useState<HighlightedCode[]>([]);
44
+ useEffect(() => {
45
+ setHighlighted(initializeHighlighted(props.codeblocks))
46
+ }, [props.codeblocks])
53
47
 
54
- useEffect(() => {
55
- fetchHighlight(props.codeblocks, props.theme || defaultTheme).then(
56
- setHighlighted
57
- );
58
- }, [props.codeblocks, props.theme]);
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
- if (!highlighted) {
61
- return <Loader />;
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
- return (
65
- <CodeThemeProvider
66
- value={{
67
- highlighted,
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
- {props.children}
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
- return await Promise.all(
77
- codeblocks?.map((codeblock) => highlight(codeblock, theme))
78
- );
116
+ return await Promise.all(
117
+ codeblocks?.map((codeblock) => highlight(codeblock, theme))
118
+ );
79
119
  }
@@ -2,7 +2,6 @@ export type {CodeThemeProps, CodeThemeBlockProps} from "./CodeTheme";
2
2
 
3
3
  export {
4
4
  CodeTheme,
5
- CodeThemeCSR,
6
5
 
7
6
  useCodeTheme
8
7
  } from "./CodeTheme";
@@ -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
+ }
@@ -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
+ }