@xyd-js/components 0.1.0-xyd.7 → 0.1.0-xyd.94

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 (251) 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 +718 -0
  6. package/LICENSE +21 -0
  7. package/TODO.md +1 -0
  8. package/content.ts +0 -2
  9. package/dist/CTABanner-Bc77pnms.js +2 -0
  10. package/dist/CTABanner-Bc77pnms.js.map +1 -0
  11. package/dist/CTABanner-DzO62aGj.js +2 -0
  12. package/dist/CTABanner-DzO62aGj.js.map +1 -0
  13. package/dist/CodeSample-BWPDgd2G.js +2 -0
  14. package/dist/CodeSample-BWPDgd2G.js.map +1 -0
  15. package/dist/CodeSample-DLnR-knP.js +2 -0
  16. package/dist/CodeSample-DLnR-knP.js.map +1 -0
  17. package/dist/HomeView-C8QlNdKh.js +2 -0
  18. package/dist/HomeView-C8QlNdKh.js.map +1 -0
  19. package/dist/HomeView-ZAP5saNy.js +2 -0
  20. package/dist/HomeView-ZAP5saNy.js.map +1 -0
  21. package/dist/Icon-BESh23UN.js +2 -0
  22. package/dist/Icon-BESh23UN.js.map +1 -0
  23. package/dist/Icon-xNucOqd2.js +2 -0
  24. package/dist/Icon-xNucOqd2.js.map +1 -0
  25. package/dist/Text-CfN9RkYA.js +2 -0
  26. package/dist/Text-CfN9RkYA.js.map +1 -0
  27. package/dist/Text-DKycD2zu.js +2 -0
  28. package/dist/Text-DKycD2zu.js.map +1 -0
  29. package/dist/Update-0XruJHjj.js +2 -0
  30. package/dist/Update-0XruJHjj.js.map +1 -0
  31. package/dist/Update-DKOAw8p9.js +2 -0
  32. package/dist/Update-DKOAw8p9.js.map +1 -0
  33. package/dist/VideoGuide-BUyomFVz.js +2 -0
  34. package/dist/VideoGuide-BUyomFVz.js.map +1 -0
  35. package/dist/VideoGuide-B_iUKKv7.js +2 -0
  36. package/dist/VideoGuide-B_iUKKv7.js.map +1 -0
  37. package/dist/_rollupPluginBabelHelpers-CxSUtGup.js +4 -0
  38. package/dist/_rollupPluginBabelHelpers-CxSUtGup.js.map +1 -0
  39. package/dist/_rollupPluginBabelHelpers-DZ-ucadG.js +4 -0
  40. package/dist/_rollupPluginBabelHelpers-DZ-ucadG.js.map +1 -0
  41. package/dist/brand.d.ts +9 -9
  42. package/dist/brand.js +1 -1
  43. package/dist/brand.js.map +1 -1
  44. package/dist/coder/themes/cosmo-light.js.map +1 -1
  45. package/dist/coder.d.ts +29 -9
  46. package/dist/coder.js +1 -1
  47. package/dist/coder.js.map +1 -1
  48. package/dist/content.d.ts +268 -204
  49. package/dist/content.js +1 -1
  50. package/dist/content.js.map +1 -1
  51. package/dist/index.css +267 -216
  52. package/dist/layouts.d.ts +20 -21
  53. package/dist/layouts.js +1 -1
  54. package/dist/layouts.js.map +1 -1
  55. package/dist/pages.js +1 -1
  56. package/dist/pages.js.map +1 -1
  57. package/dist/system.d.ts +10 -0
  58. package/dist/system.js +2 -0
  59. package/dist/system.js.map +1 -0
  60. package/dist/tslib.es6-DyL9kPq9.js +2 -0
  61. package/dist/{tslib.es6-DDIOdJiV.js.map → tslib.es6-DyL9kPq9.js.map} +1 -1
  62. package/dist/tslib.es6-Hqk-Mdr9.js +2 -0
  63. package/dist/{tslib.es6-DUrRPhZd.js.map → tslib.es6-Hqk-Mdr9.js.map} +1 -1
  64. package/dist/views.js +1 -1
  65. package/dist/writer.d.ts +411 -78
  66. package/dist/writer.js +1 -1
  67. package/dist/writer.js.map +1 -1
  68. package/docs/.nojekyll +1 -0
  69. package/docs/assets/hierarchy.js +1 -0
  70. package/docs/assets/highlight.css +22 -0
  71. package/docs/assets/icons.js +18 -0
  72. package/docs/assets/icons.svg +1 -0
  73. package/docs/assets/main.js +60 -0
  74. package/docs/assets/navigation.js +1 -0
  75. package/docs/assets/search.js +1 -0
  76. package/docs/assets/style.css +1640 -0
  77. package/docs/functions/GuideCard.html +6 -0
  78. package/docs/hierarchy.html +1 -0
  79. package/docs/index.html +2 -0
  80. package/docs/interfaces/GuideCardProps.html +18 -0
  81. package/docs/modules.html +1 -0
  82. package/index.ts +0 -1
  83. package/package.json +13 -18
  84. package/project.json +677 -0
  85. package/rollup.config.js +32 -3
  86. package/src/brand/Button/Button.styles.tsx +28 -0
  87. package/src/brand/Button/Button.tsx +3 -35
  88. package/src/brand/CTABanner/CTABanner.styles.tsx +80 -0
  89. package/src/brand/CTABanner/CTABanner.tsx +34 -112
  90. package/src/brand/Footer/Footer.styles.tsx +18 -0
  91. package/src/brand/Footer/Footer.tsx +4 -24
  92. package/src/brand/TODO.md +1 -0
  93. package/src/coder/Code/Code.styles.tsx +134 -35
  94. package/src/coder/Code/Code.tsx +131 -40
  95. package/src/coder/Code/CodeLoader.tsx +4 -4
  96. package/src/coder/Code/annotations.tsx +28 -8
  97. package/src/coder/Code/highlight.ts +38 -0
  98. package/src/coder/Code/index.ts +2 -1
  99. package/src/coder/CodeCopy/{CodeCopy.style.tsx → CodeCopy.styles.tsx} +6 -6
  100. package/src/coder/CodeCopy/CodeCopy.tsx +6 -6
  101. package/src/coder/CodeSample/CodeSample.tsx +83 -27
  102. package/src/coder/CodeTabs/CodeTabs.styles.tsx +99 -78
  103. package/src/coder/CodeTabs/CodeTabs.tsx +71 -56
  104. package/src/coder/CodeTheme/CodeTheme.tsx +89 -49
  105. package/src/coder/CodeTheme/index.ts +0 -1
  106. package/src/coder/CoderProvider.tsx +26 -0
  107. package/src/coder/index.ts +8 -4
  108. package/src/content/ContentDecoator.styles.tsx +113 -0
  109. package/src/content/ContentDecorator.tsx +17 -0
  110. package/src/content/GridDecorator.styles.tsx +67 -0
  111. package/src/content/GridDecorator.tsx +21 -0
  112. package/src/content/ReactContent.tsx +575 -0
  113. package/src/content/index.ts +10 -2
  114. package/src/icons/index.ts +0 -0
  115. package/src/kit/Loader/Loader.styles.tsx +53 -0
  116. package/src/kit/Loader/Loader.tsx +22 -0
  117. package/src/kit/TODO.md +2 -0
  118. package/src/kit/index.ts +1 -0
  119. package/src/layouts/LayoutPrimary/LayoutPrimary.styles.tsx +263 -278
  120. package/src/layouts/LayoutPrimary/LayoutPrimary.tsx +173 -96
  121. package/src/layouts/LayoutPrimary/index.ts +0 -2
  122. package/src/layouts/index.ts +0 -7
  123. package/src/pages/HomePage/HomePage.styles.tsx +16 -0
  124. package/src/pages/HomePage/HomePage.tsx +7 -21
  125. package/src/pages/TODO.md +1 -0
  126. package/src/system/SearchButton/SearchButton.styles.tsx +86 -0
  127. package/src/system/SearchButton/SearchButton.tsx +116 -0
  128. package/src/system/SearchButton/index.ts +1 -0
  129. package/src/system/index.ts +1 -0
  130. package/src/utils/useStyle.ts +19 -0
  131. package/src/views/HomeView/HomeView.styles.tsx +37 -0
  132. package/src/views/HomeView/HomeView.tsx +5 -45
  133. package/src/views/TODO.md +1 -0
  134. package/src/writer/Anchor/Anchor.styles.tsx +11 -0
  135. package/src/writer/Anchor/Anchor.tsx +51 -0
  136. package/src/writer/Anchor/index.tsx +1 -0
  137. package/src/writer/Badge/Badge.styles.tsx +39 -28
  138. package/src/writer/Badge/Badge.tsx +37 -20
  139. package/src/writer/Banner/Banner.styles.tsx +91 -0
  140. package/src/writer/Banner/Banner.tsx +70 -0
  141. package/src/writer/Banner/index.ts +1 -0
  142. package/src/writer/Blockquote/Blockquote.styles.tsx +4 -4
  143. package/src/writer/Blockquote/Blockquote.tsx +6 -3
  144. package/src/writer/Breadcrumbs/Breadcrumbs.styles.ts +22 -21
  145. package/src/writer/Breadcrumbs/Breadcrumbs.tsx +19 -13
  146. package/src/writer/Button/Button.styles.tsx +137 -0
  147. package/src/writer/Button/Button.tsx +75 -0
  148. package/src/writer/Button/index.ts +2 -0
  149. package/src/writer/Callout/Callout.styles.tsx +29 -40
  150. package/src/writer/Callout/Callout.tsx +31 -16
  151. package/src/writer/Card/Card.styles.tsx +47 -0
  152. package/src/writer/Card/Card.tsx +69 -0
  153. package/src/writer/Card/index.ts +1 -0
  154. package/src/writer/Code/Code.styles.tsx +10 -11
  155. package/src/writer/Code/Code.tsx +7 -4
  156. package/src/writer/ColorSchemeButton/ColorSchemeButton.tsx +172 -0
  157. package/src/writer/ColorSchemeButton/index.ts +1 -0
  158. package/src/writer/Details/Details.styles.tsx +84 -84
  159. package/src/writer/Details/Details.tsx +71 -51
  160. package/src/writer/Example/index.tsx +5 -0
  161. package/src/writer/GuideCard/GuideCard.styles.tsx +108 -107
  162. package/src/writer/GuideCard/GuideCard.tsx +72 -37
  163. package/src/writer/Heading/Heading.styles.tsx +69 -49
  164. package/src/writer/Heading/Heading.tsx +92 -22
  165. package/src/writer/Hr/Hr.styles.tsx +5 -5
  166. package/src/writer/Hr/Hr.tsx +3 -6
  167. package/src/writer/Icon/Icon.tsx +48 -0
  168. package/src/writer/Icon/index.ts +1 -0
  169. package/src/writer/Image/Image.styles.tsx +9 -0
  170. package/src/writer/Image/Image.tsx +19 -0
  171. package/src/writer/Image/index.ts +1 -0
  172. package/src/writer/List/List.styles.tsx +47 -0
  173. package/src/writer/List/List.tsx +29 -0
  174. package/src/writer/List/index.ts +4 -0
  175. package/src/writer/NavLinks/NavLinks.styles.ts +23 -24
  176. package/src/writer/NavLinks/NavLinks.tsx +66 -19
  177. package/src/writer/Pre/Pre.styles.tsx +5 -5
  178. package/src/writer/Pre/Pre.tsx +4 -3
  179. package/src/writer/Steps/Steps.styles.tsx +14 -12
  180. package/src/writer/Steps/Steps.tsx +39 -10
  181. package/src/writer/Table/Table.styles.tsx +62 -30
  182. package/src/writer/Table/Table.tsx +121 -11
  183. package/src/writer/Table/index.ts +0 -11
  184. package/src/writer/Tabs/Tabs.styles.tsx +63 -70
  185. package/src/writer/Tabs/Tabs.tsx +31 -29
  186. package/src/writer/Text/Text.styles.tsx +66 -0
  187. package/src/writer/Text/Text.tsx +79 -0
  188. package/src/writer/Text/index.ts +3 -0
  189. package/src/writer/TocCard/TocCard.module.css +44 -0
  190. package/src/writer/TocCard/TocCard.tsx +42 -0
  191. package/src/writer/TocCard/index.ts +3 -0
  192. package/src/writer/UnderlineNav/Tabs.tsx +51 -0
  193. package/src/writer/UnderlineNav/TabsPrimary.styles.tsx +184 -0
  194. package/src/writer/UnderlineNav/TabsPrimary.tsx +209 -0
  195. package/src/writer/UnderlineNav/TabsSecondary.styles.tsx +77 -0
  196. package/src/writer/UnderlineNav/TabsSecondary.tsx +171 -0
  197. package/src/writer/UnderlineNav/UnderlineNav.styles.tsx +181 -45
  198. package/src/writer/UnderlineNav/UnderlineNav.tsx +258 -23
  199. package/src/writer/UnderlineNav/index.ts +2 -1
  200. package/src/writer/UnderlineNav/useValueChange.ts +60 -0
  201. package/src/writer/Update/Update.styles.tsx +33 -0
  202. package/src/writer/Update/Update.tsx +37 -0
  203. package/src/writer/Update/index.ts +1 -0
  204. package/src/writer/VideoGuide/VideoGuide.module.css +105 -0
  205. package/src/writer/VideoGuide/VideoGuide.tsx +75 -0
  206. package/src/writer/VideoGuide/index.ts +1 -0
  207. package/src/writer/index.ts +23 -1
  208. package/tsconfig.json +11 -6
  209. package/types.d.ts +50 -0
  210. package/writer.ts +1 -1
  211. package/dist/CTABanner-BrdYlhnD.js +0 -2
  212. package/dist/CTABanner-BrdYlhnD.js.map +0 -1
  213. package/dist/CTABanner-XQNnnpUx.js +0 -2
  214. package/dist/CTABanner-XQNnnpUx.js.map +0 -1
  215. package/dist/CodeSample-Cp42Adjc.js +0 -2
  216. package/dist/CodeSample-Cp42Adjc.js.map +0 -1
  217. package/dist/CodeSample-DxPp80ID.js +0 -2
  218. package/dist/CodeSample-DxPp80ID.js.map +0 -1
  219. package/dist/HomeView-BN9mZXh9.js +0 -2
  220. package/dist/HomeView-BN9mZXh9.js.map +0 -1
  221. package/dist/HomeView-BVaaV0uE.js +0 -2
  222. package/dist/HomeView-BVaaV0uE.js.map +0 -1
  223. package/dist/UnderlineNav-Bs7Ot9Ch.js +0 -2
  224. package/dist/UnderlineNav-Bs7Ot9Ch.js.map +0 -1
  225. package/dist/UnderlineNav-C2aEVraN.js +0 -2
  226. package/dist/UnderlineNav-C2aEVraN.js.map +0 -1
  227. package/dist/_rollupPluginBabelHelpers-BMmCG_qQ.js +0 -2
  228. package/dist/_rollupPluginBabelHelpers-BMmCG_qQ.js.map +0 -1
  229. package/dist/_rollupPluginBabelHelpers-DsEzE6Ab.js +0 -2
  230. package/dist/_rollupPluginBabelHelpers-DsEzE6Ab.js.map +0 -1
  231. package/dist/index-BVUz77Tm.js +0 -2
  232. package/dist/index-BVUz77Tm.js.map +0 -1
  233. package/dist/index-jxd3nv2J.js +0 -2
  234. package/dist/index-jxd3nv2J.js.map +0 -1
  235. package/dist/tslib.es6-DDIOdJiV.js +0 -2
  236. package/dist/tslib.es6-DUrRPhZd.js +0 -2
  237. package/src/content/Anchor/Anchor.tsx +0 -63
  238. package/src/content/Anchor/index.tsx +0 -3
  239. package/src/content/Content/Content.tsx +0 -21
  240. package/src/content/Content/index.tsx +0 -3
  241. package/src/content/Content.tsx +0 -180
  242. package/src/content/Subtitle/Subtitle.tsx +0 -21
  243. package/src/content/Subtitle/index.tsx +0 -3
  244. package/src/layouts/Layout.styles.tsx +0 -151
  245. package/src/layouts/Layout.tsx +0 -121
  246. package/src/ui/Loader/Loader.styles.tsx +0 -52
  247. package/src/ui/Loader/Loader.tsx +0 -26
  248. package/src/ui/index.ts +0 -1
  249. package/src/writer/Icon/index.tsx +0 -355
  250. package/src/writer/Table/TableV2.styles.tsx +0 -117
  251. package/src/writer/Table/TableV2.tsx +0 -83
@@ -0,0 +1,172 @@
1
+ import React, { useEffect, useState } from "react";
2
+
3
+ import { Button } from "../Button";
4
+
5
+ export function ColorSchemeButton() {
6
+ const [currentScheme, changeColorScheme] = useColorScheme() as [string, () => void]
7
+
8
+ return <Button
9
+ size="sm"
10
+ theme="ghost"
11
+ icon={currentScheme === "dark" ? <IconDarkMode /> : <IconLightMode />}
12
+ onClick={changeColorScheme}
13
+ />
14
+ }
15
+
16
+ export function useColorScheme() {
17
+ const [currentScheme, setCurrentScheme] = useState<string>('light')
18
+
19
+ // TODO: context
20
+ useEffect(() => {
21
+ const updateScheme = () => {
22
+ const html = document.querySelector("html");
23
+ if (html) {
24
+ const scheme = html.getAttribute("data-color-scheme") || "os";
25
+ if (scheme === "os") {
26
+ const preferred = getPreferredColorScheme();
27
+ setCurrentScheme(preferred || "light");
28
+ } else {
29
+ setCurrentScheme(scheme);
30
+ }
31
+ }
32
+ };
33
+
34
+ updateScheme();
35
+
36
+ // Listen for changes to the color scheme
37
+ const observer = new MutationObserver(updateScheme);
38
+ const html = document.querySelector("html");
39
+ if (html) {
40
+ observer.observe(html, { attributes: true, attributeFilter: ['data-color-scheme'] });
41
+ }
42
+
43
+ return () => observer.disconnect();
44
+ }, []);
45
+
46
+ function changeColorScheme() {
47
+ let colorScheme = ""
48
+
49
+ const preferredColorScheme = getPreferredColorScheme()
50
+ if (preferredColorScheme) {
51
+ colorScheme = preferredColorScheme === "dark" ? "light" : "dark"
52
+ }
53
+
54
+ const html = document.querySelector("html");
55
+ if (!html) return;
56
+
57
+ const currentScheme = html.getAttribute("data-color-scheme");
58
+ if (currentScheme && currentScheme !== "os") {
59
+ colorScheme = currentScheme === "dark" ? "light" : "dark";
60
+ }
61
+ if (!colorScheme) {
62
+ colorScheme = "light"
63
+ }
64
+
65
+ html.setAttribute("data-color-scheme", colorScheme);
66
+ localStorage.setItem("xyd-color-scheme", colorScheme);
67
+ }
68
+
69
+ return [currentScheme, changeColorScheme]
70
+ }
71
+
72
+ function getPreferredColorScheme() {
73
+ if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
74
+ return 'dark';
75
+ }
76
+
77
+ if (window.matchMedia('(prefers-color-scheme: light)').matches) {
78
+ return 'light';
79
+ }
80
+
81
+ return null
82
+ }
83
+
84
+
85
+ function IconLightMode() {
86
+ return <svg
87
+ width={16}
88
+ height={16}
89
+ viewBox="0 0 16 16"
90
+ fill="none"
91
+ stroke="currentColor"
92
+ xmlns="http://www.w3.org/2000/svg"
93
+ >
94
+ <g clipPath="url(#clip0_2880_7340)">
95
+ <path
96
+ d="M8 1.11133V2.00022"
97
+ strokeWidth={1.5}
98
+ strokeLinecap="round"
99
+ strokeLinejoin="round"
100
+ />
101
+ <path
102
+ d="M12.8711 3.12891L12.2427 3.75735"
103
+ strokeWidth={1.5}
104
+ strokeLinecap="round"
105
+ strokeLinejoin="round"
106
+ />
107
+ <path
108
+ d="M14.8889 8H14"
109
+ strokeWidth={1.5}
110
+ strokeLinecap="round"
111
+ strokeLinejoin="round"
112
+ />
113
+ <path
114
+ d="M12.8711 12.8711L12.2427 12.2427"
115
+ strokeWidth={1.5}
116
+ strokeLinecap="round"
117
+ strokeLinejoin="round"
118
+ />
119
+ <path
120
+ d="M8 14.8889V14"
121
+ strokeWidth={1.5}
122
+ strokeLinecap="round"
123
+ strokeLinejoin="round"
124
+ />
125
+ <path
126
+ d="M3.12891 12.8711L3.75735 12.2427"
127
+ strokeWidth={1.5}
128
+ strokeLinecap="round"
129
+ strokeLinejoin="round"
130
+ />
131
+ <path
132
+ d="M1.11133 8H2.00022"
133
+ strokeWidth={1.5}
134
+ strokeLinecap="round"
135
+ strokeLinejoin="round"
136
+ />
137
+ <path
138
+ d="M3.12891 3.12891L3.75735 3.75735"
139
+ strokeWidth={1.5}
140
+ strokeLinecap="round"
141
+ strokeLinejoin="round"
142
+ />
143
+ <path
144
+ d="M8.00043 11.7782C10.0868 11.7782 11.7782 10.0868 11.7782 8.00043C11.7782 5.91402 10.0868 4.22266 8.00043 4.22266C5.91402 4.22266 4.22266 5.91402 4.22266 8.00043C4.22266 10.0868 5.91402 11.7782 8.00043 11.7782Z"
145
+ strokeWidth={1.5}
146
+ strokeLinecap="round"
147
+ strokeLinejoin="round"
148
+ />
149
+ </g>
150
+ <defs>
151
+ <clipPath id="clip0_2880_7340">
152
+ <rect width={16} height={16} fill="white" />
153
+ </clipPath>
154
+ </defs>
155
+ </svg>
156
+ }
157
+
158
+ function IconDarkMode() {
159
+ return <svg
160
+ xmlns="http://www.w3.org/2000/svg"
161
+ width={16}
162
+ height={16}
163
+ viewBox="0 0 24 24"
164
+ fill="none"
165
+ stroke="currentColor"
166
+ strokeWidth={2}
167
+ strokeLinecap="round"
168
+ strokeLinejoin="round"
169
+ >
170
+ <path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" />
171
+ </svg>
172
+ }
@@ -0,0 +1 @@
1
+ export { ColorSchemeButton, useColorScheme } from "./ColorSchemeButton";
@@ -1,93 +1,93 @@
1
- import {css} from "@linaria/core";
1
+ import { css } from "@linaria/core";
2
2
 
3
- export const $details = {
4
- host: css`
5
- border-top: 1px solid #ececf1;
3
+ export const DetailsHost = css`
4
+ @layer defaults {
5
+ border-top: 1px solid var(--xyd-details-border-color);
6
+
7
+ &[data-kind="secondary"], &[data-kind="tertiary"] {
8
+ background-color: var(--xyd-details-bgcolor--secondary);
9
+ border: 1px solid var(--xyd-details-border-color);
10
+ border-radius: 8px;
11
+ }
6
12
 
7
- &[open] summary svg[data-icon="true"] { // TODO: bad solution
13
+ &[open] [part="summary"] svg[data-icon="true"] {
8
14
  transform: rotate(90deg);
9
15
  }
10
- `,
11
- host$$secondary: css`
12
- background-color: #f7f7f8;
13
- border: 1px solid #ececf1;
14
- border-radius: 8px;
15
- `,
16
- summary: css`
17
- padding: 16px 14px 16px 0;
18
- font-size: 18px;
19
- cursor: pointer;
20
- font-weight: 500;
21
- font-variant-numeric: tabular-nums;
22
- line-height: 1.4;
23
- transition: color 0.3s;
24
- display: flex;
25
- flex-direction: row;
26
- align-items: center;
27
- justify-content: flex-start;
28
- list-style: none;
29
16
 
30
- &:hover {
31
- color: #565869;
17
+ [part="summary"] {
18
+ padding: 16px 14px 16px 0;
19
+ cursor: pointer;
20
+ font-weight: var(--xyd-font-weight-medium);
21
+ font-variant-numeric: tabular-nums;
22
+ transition: color 0.3s;
23
+ display: flex;
24
+ flex-direction: row;
25
+ align-items: center;
26
+ justify-content: flex-start;
27
+ list-style: none;
28
+
29
+ &:hover {
30
+ color: var(--xyd-details-summary-color--active);
31
+ }
32
+ }
33
+
34
+ &[data-kind="tertiary"] [part="summary"]{
35
+ padding: 10px 24px;
36
+ }
37
+ &[data-kind="secondary"],
38
+ &[data-kind="tertiary"] {
39
+ [part="summary"] {
40
+ display: flex;
41
+ justify-content: space-between;
42
+ align-items: center;
43
+ cursor: pointer;
44
+ padding: 20px 24px;
45
+ }
46
+ }
47
+
48
+ [part="summary-deep"] {
49
+ display: flex;
50
+ align-items: center;
51
+ margin-bottom: 8px;
52
+ }
53
+
54
+ [part="summary-deep-text"] {
55
+ color: var(--xyd-details-summary-color);
56
+ text-transform: none;
57
+ letter-spacing: .08em;
58
+ margin-left: 8px;
59
+ font-weight: var(--xyd-font-weight-bold);
60
+
61
+ code {
62
+ background: var(--xyd-details-summary-code-bgcolor);
63
+ }
64
+ }
65
+
66
+ [part="summary-deep-label"] {
67
+ flex: 1 1 auto;
32
68
  }
33
- `,
34
- summary$$secondary: css`
35
- display: flex;
36
- justify-content: space-between;
37
- align-items: center;
38
- cursor: pointer;
39
- padding: 20px 24px;
40
- `,
41
- summary$$tertiary: css`
42
- padding: 10px 24px;
43
- `,
44
- summaryDeep: css`
45
- display: flex;
46
- align-items: center;
47
- margin-bottom: 8px;
48
- `,
49
- summaryDeep$text: css`
50
- color: #6e6e80;
51
- text-transform: uppercase;
52
- font-size: 12px;
53
- line-height: 16px;
54
- letter-spacing: .08em;
55
- margin-left: 8px;
56
- font-weight: 700;
57
- `,
58
- summaryDeep$text$$tertiary: css`
59
- text-transform: none;
60
-
61
- code {
62
- background: white;
69
+
70
+ // TODO: after migration to web-components should be removed cuz 'part="content"' can be also in another element as child
71
+ & > [part="content"] {
72
+ padding: 0 24px 20px;
73
+ }
74
+ &[data-kind="tertiary"] > [part="content"] {
75
+ background-color: var(--xyd-details-content-bgcolor);
76
+ padding-top: 20px;
77
+
78
+ code {
79
+ background: var(--xyd-details-content-bgcolor);
80
+ }
63
81
  }
64
- `,
65
- label: css`
66
- flex: 1 1 auto;
67
- `,
68
- label$$tertriary: css`
69
- padding: 10px;
70
- `,
71
- icon: css`
72
- flex: 0 0 auto;
73
- font-size: 16px;
74
- display: flex;
75
- align-items: center;
76
- justify-content: center;
77
- padding-right: 6px;
78
- `,
79
- content: css`
80
- padding: 0 24px 20px;
81
- `,
82
- content$$secondary: css`
83
- // TODO: also bad
84
82
 
85
- code {
86
- background: white;
83
+ [part="icon"] {
84
+ flex: 0 0 auto;
85
+ font-size: var(--xyd-font-size-medium);
86
+ display: flex;
87
+ align-items: center;
88
+ justify-content: center;
89
+ padding-right: 6px;
87
90
  }
88
- `,
89
- content$$tertiary: css`
90
- background: white;
91
- padding-top: 20px;
92
- `
93
- }
91
+ }
92
+ `;
93
+
@@ -1,32 +1,68 @@
1
1
  import React from "react"
2
2
 
3
- import {$details} from "./Details.styles";
3
+ import * as cn from "./Details.styles";
4
4
 
5
- interface BaseDetailsProps {
5
+ /**
6
+ * Base interface for all Details component variants
7
+ */
8
+ export interface BaseDetailsProps {
9
+ /** Content to be displayed inside the details element */
6
10
  children: React.ReactNode;
11
+
12
+ /** Label text displayed in the summary */
7
13
  label: string;
8
14
 
9
- icon?: React.SVGProps<SVGSVGElement>;
15
+ /** Optional icon element to be displayed in the summary */
16
+ icon?: React.ReactElement;
17
+
18
+ /** Optional CSS class name for custom styling */
19
+ className?: string;
10
20
  }
11
21
 
12
- interface TertiaryDetailsProps extends BaseDetailsProps {
22
+ /**
23
+ * Props for the tertiary variant of the Details component
24
+ */
25
+ export interface TertiaryDetailsProps extends BaseDetailsProps {
26
+ /** Specifies the tertiary variant */
13
27
  kind: "tertiary";
28
+
29
+ /** Title text or element displayed in the summary */
14
30
  title: string | React.ReactNode;
15
31
  }
16
32
 
17
- interface SecondaryDetailsProps extends BaseDetailsProps {
33
+ /**
34
+ * Props for the secondary variant of the Details component
35
+ */
36
+ export interface SecondaryDetailsProps extends BaseDetailsProps {
37
+ /** Specifies the secondary variant */
18
38
  kind: "secondary";
39
+
40
+ /** Title text or element displayed in the summary */
19
41
  title: string | React.ReactNode;
20
42
  }
21
43
 
22
- interface PrimaryDetailsProps extends BaseDetailsProps {
44
+ /**
45
+ * Props for the primary variant of the Details component
46
+ */
47
+ export interface PrimaryDetailsProps extends BaseDetailsProps {
48
+ /** Specifies the primary variant (default) */
23
49
  kind?: "primary";
24
50
  }
25
51
 
52
+ /** Union type of all possible Details component variants */
26
53
  export type DetailsProps = PrimaryDetailsProps | SecondaryDetailsProps | TertiaryDetailsProps
27
54
 
28
- export function Details(props: DetailsProps) {
29
- const {children, label} = props;
55
+ /**
56
+ * A collapsible details component that supports three variants: primary, secondary, and tertiary.
57
+ * Each variant has a different visual style and structure.
58
+ *
59
+ * @param props - The component props
60
+ * @returns A details element with collapsible content
61
+ *
62
+ * @category Component
63
+ */
64
+ export function Details(props: DetailsProps): React.ReactElement {
65
+ const { children, label } = props;
30
66
 
31
67
  let title
32
68
 
@@ -38,54 +74,45 @@ export function Details(props: DetailsProps) {
38
74
 
39
75
  const kind = props.kind || "primary";
40
76
 
41
- return <details className={`
42
- ${$details.host}
43
- ${isDeepKind && $details.host$$secondary}
44
- `}>
45
- <summary className={`
46
- ${$details.summary}
47
- ${isDeepKind && $details.summary$$secondary}
48
- ${kind === "tertiary" ? $details.summary$$tertiary : ""}
49
- `}>
50
- {kind === "primary" && <>
51
- {props.icon ? props.icon : <$Icon/>}
52
- <$Label>
53
- {label}
54
- </$Label>
55
- </>}
56
- {isDeepKind && <>
77
+ return <details
78
+ part="details"
79
+ className={`${cn.DetailsHost} ${props.className || ""}`}
80
+ data-kind={props.kind}
81
+ >
82
+ <summary part="summary">
83
+ {kind === "primary" && (
84
+ <>
85
+ {props.icon || <$Icon />}
86
+ <div part="summary-deep-label">
87
+ {label}
88
+ </div>
89
+ </>
90
+ )}
91
+
92
+ {isDeepKind && (
57
93
  <div>
58
- <div className={$details.summaryDeep}>
59
- <>
60
- {props.icon ? props.icon : <$IconDeep/>}
61
- </>
62
- <div className={`
63
- ${$details.summaryDeep$text}
64
- ${$details.summaryDeep$text$$tertiary}
65
- `}>
94
+ <div part="summary-deep">
95
+ {props.icon || <$IconDeep />}
96
+ <div part="summary-deep-text">
66
97
  {title}
67
98
  </div>
68
99
  </div>
69
- <$Label>
100
+ <div part="summary-deep-label">
70
101
  {label}
71
- </$Label>
72
- </div>
73
- <$Icon/>
74
- </>}
102
+ </div>
103
+ </div>
104
+ )}
105
+ {isDeepKind && <$Icon />}
75
106
  </summary>
76
107
 
77
- <div className={`
78
- ${$details.content}
79
- ${isDeepKind && $details.content$$secondary}
80
- ${kind === "tertiary" && $details.content$$tertiary}
81
- `}>
108
+ <div part="content">
82
109
  {children}
83
110
  </div>
84
111
  </details>
85
112
  }
86
113
 
87
114
  function $Icon() {
88
- return <div className={$details.icon}>
115
+ return <div part="icon">
89
116
  <svg
90
117
  // TODO: bad solution
91
118
  data-icon="true"
@@ -124,16 +151,9 @@ function $IconDeep() {
124
151
  </g>
125
152
  <defs>
126
153
  <clipPath id="clip0_1689_2180">
127
- <rect width={24} height={24} fill="white"/>
154
+ <rect width={24} height={24} fill="white" />
128
155
  </clipPath>
129
156
  </defs>
130
157
  </svg>
131
158
  }
132
159
 
133
- function $Label({children}: {
134
- children?: React.ReactNode
135
- }) {
136
- return <div className={$details.label}>
137
- {children}
138
- </div>
139
- }
@@ -0,0 +1,5 @@
1
+ import React from "react"
2
+
3
+ export function Example() {
4
+ return <div>Example xD 2</div>
5
+ }