@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.
- 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 +718 -0
- package/LICENSE +21 -0
- package/TODO.md +1 -0
- package/content.ts +0 -2
- package/dist/CTABanner-Bc77pnms.js +2 -0
- package/dist/CTABanner-Bc77pnms.js.map +1 -0
- package/dist/CTABanner-DzO62aGj.js +2 -0
- package/dist/CTABanner-DzO62aGj.js.map +1 -0
- package/dist/CodeSample-BWPDgd2G.js +2 -0
- package/dist/CodeSample-BWPDgd2G.js.map +1 -0
- package/dist/CodeSample-DLnR-knP.js +2 -0
- package/dist/CodeSample-DLnR-knP.js.map +1 -0
- package/dist/HomeView-C8QlNdKh.js +2 -0
- package/dist/HomeView-C8QlNdKh.js.map +1 -0
- package/dist/HomeView-ZAP5saNy.js +2 -0
- package/dist/HomeView-ZAP5saNy.js.map +1 -0
- package/dist/Icon-BESh23UN.js +2 -0
- package/dist/Icon-BESh23UN.js.map +1 -0
- package/dist/Icon-xNucOqd2.js +2 -0
- package/dist/Icon-xNucOqd2.js.map +1 -0
- package/dist/Text-CfN9RkYA.js +2 -0
- package/dist/Text-CfN9RkYA.js.map +1 -0
- package/dist/Text-DKycD2zu.js +2 -0
- package/dist/Text-DKycD2zu.js.map +1 -0
- package/dist/Update-0XruJHjj.js +2 -0
- package/dist/Update-0XruJHjj.js.map +1 -0
- package/dist/Update-DKOAw8p9.js +2 -0
- package/dist/Update-DKOAw8p9.js.map +1 -0
- package/dist/VideoGuide-BUyomFVz.js +2 -0
- package/dist/VideoGuide-BUyomFVz.js.map +1 -0
- package/dist/VideoGuide-B_iUKKv7.js +2 -0
- package/dist/VideoGuide-B_iUKKv7.js.map +1 -0
- package/dist/_rollupPluginBabelHelpers-CxSUtGup.js +4 -0
- package/dist/_rollupPluginBabelHelpers-CxSUtGup.js.map +1 -0
- package/dist/_rollupPluginBabelHelpers-DZ-ucadG.js +4 -0
- package/dist/_rollupPluginBabelHelpers-DZ-ucadG.js.map +1 -0
- package/dist/brand.d.ts +9 -9
- 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 +29 -9
- package/dist/coder.js +1 -1
- package/dist/coder.js.map +1 -1
- package/dist/content.d.ts +268 -204
- package/dist/content.js +1 -1
- package/dist/content.js.map +1 -1
- package/dist/index.css +267 -216
- 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-DyL9kPq9.js +2 -0
- package/dist/{tslib.es6-DDIOdJiV.js.map → tslib.es6-DyL9kPq9.js.map} +1 -1
- package/dist/tslib.es6-Hqk-Mdr9.js +2 -0
- package/dist/{tslib.es6-DUrRPhZd.js.map → tslib.es6-Hqk-Mdr9.js.map} +1 -1
- package/dist/views.js +1 -1
- package/dist/writer.d.ts +411 -78
- 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 +13 -18
- package/project.json +677 -0
- package/rollup.config.js +32 -3
- package/src/brand/Button/Button.styles.tsx +28 -0
- package/src/brand/Button/Button.tsx +3 -35
- package/src/brand/CTABanner/CTABanner.styles.tsx +80 -0
- package/src/brand/CTABanner/CTABanner.tsx +34 -112
- package/src/brand/Footer/Footer.styles.tsx +18 -0
- package/src/brand/Footer/Footer.tsx +4 -24
- package/src/brand/TODO.md +1 -0
- package/src/coder/Code/Code.styles.tsx +134 -35
- package/src/coder/Code/Code.tsx +131 -40
- package/src/coder/Code/CodeLoader.tsx +4 -4
- 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.style.tsx → CodeCopy.styles.tsx} +6 -6
- package/src/coder/CodeCopy/CodeCopy.tsx +6 -6
- package/src/coder/CodeSample/CodeSample.tsx +83 -27
- package/src/coder/CodeTabs/CodeTabs.styles.tsx +99 -78
- package/src/coder/CodeTabs/CodeTabs.tsx +71 -56
- 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/TODO.md +2 -0
- package/src/kit/index.ts +1 -0
- package/src/layouts/LayoutPrimary/LayoutPrimary.styles.tsx +263 -278
- package/src/layouts/LayoutPrimary/LayoutPrimary.tsx +173 -96
- package/src/layouts/LayoutPrimary/index.ts +0 -2
- package/src/layouts/index.ts +0 -7
- package/src/pages/HomePage/HomePage.styles.tsx +16 -0
- package/src/pages/HomePage/HomePage.tsx +7 -21
- package/src/pages/TODO.md +1 -0
- 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/utils/useStyle.ts +19 -0
- package/src/views/HomeView/HomeView.styles.tsx +37 -0
- package/src/views/HomeView/HomeView.tsx +5 -45
- package/src/views/TODO.md +1 -0
- package/src/writer/Anchor/Anchor.styles.tsx +11 -0
- package/src/writer/Anchor/Anchor.tsx +51 -0
- package/src/writer/Anchor/index.tsx +1 -0
- package/src/writer/Badge/Badge.styles.tsx +39 -28
- package/src/writer/Badge/Badge.tsx +37 -20
- 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 +4 -4
- package/src/writer/Blockquote/Blockquote.tsx +6 -3
- package/src/writer/Breadcrumbs/Breadcrumbs.styles.ts +22 -21
- package/src/writer/Breadcrumbs/Breadcrumbs.tsx +19 -13
- 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 +29 -40
- package/src/writer/Callout/Callout.tsx +31 -16
- 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 +10 -11
- package/src/writer/Code/Code.tsx +7 -4
- package/src/writer/ColorSchemeButton/ColorSchemeButton.tsx +172 -0
- package/src/writer/ColorSchemeButton/index.ts +1 -0
- package/src/writer/Details/Details.styles.tsx +84 -84
- package/src/writer/Details/Details.tsx +71 -51
- package/src/writer/Example/index.tsx +5 -0
- package/src/writer/GuideCard/GuideCard.styles.tsx +108 -107
- package/src/writer/GuideCard/GuideCard.tsx +72 -37
- package/src/writer/Heading/Heading.styles.tsx +69 -49
- package/src/writer/Heading/Heading.tsx +92 -22
- package/src/writer/Hr/Hr.styles.tsx +5 -5
- package/src/writer/Hr/Hr.tsx +3 -6
- 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 +23 -24
- package/src/writer/NavLinks/NavLinks.tsx +66 -19
- package/src/writer/Pre/Pre.styles.tsx +5 -5
- package/src/writer/Pre/Pre.tsx +4 -3
- package/src/writer/Steps/Steps.styles.tsx +14 -12
- package/src/writer/Steps/Steps.tsx +39 -10
- package/src/writer/Table/Table.styles.tsx +62 -30
- package/src/writer/Table/Table.tsx +121 -11
- package/src/writer/Table/index.ts +0 -11
- package/src/writer/Tabs/Tabs.styles.tsx +63 -70
- package/src/writer/Tabs/Tabs.tsx +31 -29
- 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 +181 -45
- package/src/writer/UnderlineNav/UnderlineNav.tsx +258 -23
- 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 +11 -6
- package/types.d.ts +50 -0
- package/writer.ts +1 -1
- package/dist/CTABanner-BrdYlhnD.js +0 -2
- package/dist/CTABanner-BrdYlhnD.js.map +0 -1
- package/dist/CTABanner-XQNnnpUx.js +0 -2
- package/dist/CTABanner-XQNnnpUx.js.map +0 -1
- package/dist/CodeSample-Cp42Adjc.js +0 -2
- package/dist/CodeSample-Cp42Adjc.js.map +0 -1
- package/dist/CodeSample-DxPp80ID.js +0 -2
- package/dist/CodeSample-DxPp80ID.js.map +0 -1
- package/dist/HomeView-BN9mZXh9.js +0 -2
- package/dist/HomeView-BN9mZXh9.js.map +0 -1
- package/dist/HomeView-BVaaV0uE.js +0 -2
- package/dist/HomeView-BVaaV0uE.js.map +0 -1
- package/dist/UnderlineNav-Bs7Ot9Ch.js +0 -2
- package/dist/UnderlineNav-Bs7Ot9Ch.js.map +0 -1
- package/dist/UnderlineNav-C2aEVraN.js +0 -2
- package/dist/UnderlineNav-C2aEVraN.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-BMmCG_qQ.js +0 -2
- package/dist/_rollupPluginBabelHelpers-BMmCG_qQ.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-DsEzE6Ab.js +0 -2
- package/dist/_rollupPluginBabelHelpers-DsEzE6Ab.js.map +0 -1
- package/dist/index-BVUz77Tm.js +0 -2
- package/dist/index-BVUz77Tm.js.map +0 -1
- package/dist/index-jxd3nv2J.js +0 -2
- package/dist/index-jxd3nv2J.js.map +0 -1
- package/dist/tslib.es6-DDIOdJiV.js +0 -2
- package/dist/tslib.es6-DUrRPhZd.js +0 -2
- package/src/content/Anchor/Anchor.tsx +0 -63
- package/src/content/Anchor/index.tsx +0 -3
- package/src/content/Content/Content.tsx +0 -21
- package/src/content/Content/index.tsx +0 -3
- package/src/content/Content.tsx +0 -180
- package/src/content/Subtitle/Subtitle.tsx +0 -21
- package/src/content/Subtitle/index.tsx +0 -3
- package/src/layouts/Layout.styles.tsx +0 -151
- package/src/layouts/Layout.tsx +0 -121
- package/src/ui/Loader/Loader.styles.tsx +0 -52
- 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
|
@@ -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
|
|
4
|
-
|
|
5
|
-
border-top: 1px solid
|
|
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"] {
|
|
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
|
-
|
|
31
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
86
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
padding-top: 20px;
|
|
92
|
-
`
|
|
93
|
-
}
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
|
|
@@ -1,32 +1,68 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import * as cn from "./Details.styles";
|
|
4
4
|
|
|
5
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
|
42
|
-
|
|
43
|
-
${
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
100
|
+
<div part="summary-deep-label">
|
|
70
101
|
{label}
|
|
71
|
-
|
|
72
|
-
</div>
|
|
73
|
-
|
|
74
|
-
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
)}
|
|
105
|
+
{isDeepKind && <$Icon />}
|
|
75
106
|
</summary>
|
|
76
107
|
|
|
77
|
-
<div
|
|
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
|
|
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
|
-
}
|