@xyd-js/components 0.0.0-build
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/TODO.md +1 -0
- package/coder.ts +1 -0
- package/content.ts +1 -0
- package/dist/Button-Dm9DMdZE.js +2 -0
- package/dist/Button-Dm9DMdZE.js.map +1 -0
- package/dist/CodeSample-Dq1qE5TX.js +2 -0
- package/dist/CodeSample-Dq1qE5TX.js.map +1 -0
- package/dist/Icon-Cc24dmoE.js +2 -0
- package/dist/Icon-Cc24dmoE.js.map +1 -0
- package/dist/PageFirstSlide-DsO5zq8p.js +2 -0
- package/dist/PageFirstSlide-DsO5zq8p.js.map +1 -0
- package/dist/TabsAnalytics-Hbe8Rs6o.js +2 -0
- package/dist/TabsAnalytics-Hbe8Rs6o.js.map +1 -0
- package/dist/Update-Bqnm3ZGk.js +2 -0
- package/dist/Update-Bqnm3ZGk.js.map +1 -0
- package/dist/VideoGuide-BLUkXIOB.js +2 -0
- package/dist/VideoGuide-BLUkXIOB.js.map +1 -0
- package/dist/_rollupPluginBabelHelpers-DOxGmVNp.js +4 -0
- package/dist/_rollupPluginBabelHelpers-DOxGmVNp.js.map +1 -0
- package/dist/coder/themes/classic.css +57 -0
- package/dist/coder/themes/classic.d.ts +96 -0
- package/dist/coder/themes/classic.js +2 -0
- package/dist/coder/themes/classic.js.map +1 -0
- package/dist/coder/themes/cosmo.css +64 -0
- package/dist/coder/themes/cosmo.d.ts +96 -0
- package/dist/coder/themes/cosmo.js +2 -0
- package/dist/coder/themes/cosmo.js.map +1 -0
- package/dist/coder.d.ts +94 -0
- package/dist/coder.js +2 -0
- package/dist/coder.js.map +1 -0
- package/dist/content.d.ts +411 -0
- package/dist/content.js +2 -0
- package/dist/content.js.map +1 -0
- package/dist/index.css +282 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts.d.ts +33 -0
- package/dist/layouts.js +2 -0
- package/dist/layouts.js.map +1 -0
- package/dist/pages.d.ts +176 -0
- package/dist/pages.js +2 -0
- package/dist/pages.js.map +1 -0
- package/dist/system.d.ts +45 -0
- package/dist/system.js +2 -0
- package/dist/system.js.map +1 -0
- package/dist/useUXClick-WHliHcAg.js +2 -0
- package/dist/useUXClick-WHliHcAg.js.map +1 -0
- package/dist/useUXEvents-Dlr3yNx3.js +2 -0
- package/dist/useUXEvents-Dlr3yNx3.js.map +1 -0
- package/dist/useUXScrollDepth-uidVGyZB.js +2 -0
- package/dist/useUXScrollDepth-uidVGyZB.js.map +1 -0
- package/dist/uxsdk.d.ts +53 -0
- package/dist/uxsdk.js +2 -0
- package/dist/uxsdk.js.map +1 -0
- package/dist/views.d.ts +18 -0
- package/dist/views.js +2 -0
- package/dist/views.js.map +1 -0
- package/dist/writer.d.ts +580 -0
- package/dist/writer.js +2 -0
- package/dist/writer.js.map +1 -0
- 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 -0
- package/layouts.ts +1 -0
- package/output.txt +13 -0
- package/package.json +81 -0
- package/pages.ts +1 -0
- package/postcss.config.cjs +5 -0
- package/rollup.config.js +195 -0
- package/src/coder/Code/Code.styles.tsx +151 -0
- package/src/coder/Code/Code.tsx +171 -0
- package/src/coder/Code/CodeLoader.tsx +10 -0
- package/src/coder/Code/annotations.tsx +51 -0
- package/src/coder/Code/highlight.ts +208 -0
- package/src/coder/Code/index.ts +16 -0
- package/src/coder/CodeCopy/CodeCopy.styles.tsx +21 -0
- package/src/coder/CodeCopy/CodeCopy.tsx +36 -0
- package/src/coder/CodeCopy/index.ts +7 -0
- package/src/coder/CodeSample/CodeSample.tsx +118 -0
- package/src/coder/CodeSample/CodeSampleAnalytics.tsx +112 -0
- package/src/coder/CodeSample/index.ts +11 -0
- package/src/coder/CodeSample/withLocalStored.tsx +50 -0
- package/src/coder/CodeTabs/CodeTabs.styles.tsx +126 -0
- package/src/coder/CodeTabs/CodeTabs.tsx +128 -0
- package/src/coder/CodeTabs/index.ts +6 -0
- package/src/coder/CodeTheme/CodeTheme.tsx +126 -0
- package/src/coder/CodeTheme/index.ts +7 -0
- package/src/coder/CoderProvider.tsx +26 -0
- package/src/coder/README.md +1 -0
- package/src/coder/hooks/highlight.ts +182 -0
- package/src/coder/index.ts +37 -0
- package/src/coder/themes/classic.css +57 -0
- package/src/coder/themes/classic.ts +270 -0
- package/src/coder/themes/cosmo.css +64 -0
- package/src/coder/themes/cosmo.ts +264 -0
- package/src/content/AppearanceDecorator.styles.tsx +11 -0
- package/src/content/ContentDecoator.styles.tsx +180 -0
- package/src/content/ContentDecorator.tsx +17 -0
- package/src/content/GridDecorator.styles.tsx +86 -0
- package/src/content/GridDecorator.tsx +23 -0
- package/src/content/ReactContent.tsx +671 -0
- package/src/content/TODO.md +1 -0
- package/src/content/index.ts +13 -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 +325 -0
- package/src/layouts/LayoutPrimary/LayoutPrimary.tsx +252 -0
- package/src/layouts/LayoutPrimary/index.ts +3 -0
- package/src/layouts/index.ts +6 -0
- package/src/pages/PageBlogHome/PageBlogHome.styles.tsx +67 -0
- package/src/pages/PageBlogHome/PageBlogHome.tsx +64 -0
- package/src/pages/PageBlogHome/index.ts +3 -0
- package/src/pages/PageBlogHome/types.ts +35 -0
- package/src/pages/PageBlogPost/PageBlogPost.styles.tsx +4 -0
- package/src/pages/PageBlogPost/PageBlogPost.tsx +9 -0
- package/src/pages/PageBlogPost/index.ts +3 -0
- package/src/pages/PageFirstSlide/PageFirstSlide.styles.tsx +134 -0
- package/src/pages/PageFirstSlide/PageFirstSlide.tsx +56 -0
- package/src/pages/PageFirstSlide/index.ts +1 -0
- package/src/pages/PageFirstSlide/types.ts +67 -0
- package/src/pages/PageHome/PageHome.styles.tsx +51 -0
- package/src/pages/PageHome/PageHome.tsx +62 -0
- package/src/pages/PageHome/index.ts +3 -0
- package/src/pages/PageHome/types.ts +79 -0
- package/src/pages/index.ts +7 -0
- package/src/system/Baseline/Baseline.styles.tsx +128 -0
- package/src/system/Baseline/Baseline.tsx +40 -0
- package/src/system/Baseline/bun.svg +1 -0
- package/src/system/Baseline/check.svg +1 -0
- package/src/system/Baseline/index.ts +1 -0
- package/src/system/Baseline/logo.svg +1 -0
- package/src/system/Baseline/node.svg +7 -0
- package/src/system/Baseline/npm.svg +5 -0
- package/src/system/Baseline/pnpm.svg +1 -0
- package/src/system/Footer/Footer.styles.tsx +213 -0
- package/src/system/Footer/Footer.tsx +105 -0
- package/src/system/Footer/index.ts +1 -0
- package/src/system/SearchButton/SearchButton.styles.tsx +89 -0
- package/src/system/SearchButton/SearchButton.tsx +118 -0
- package/src/system/SearchButton/index.ts +1 -0
- package/src/system/index.ts +3 -0
- package/src/utils/useStyle.ts +19 -0
- package/src/uxsdk/const.ts +1 -0
- package/src/uxsdk/index.ts +21 -0
- package/src/uxsdk/useUXClick.ts +21 -0
- package/src/uxsdk/useUXEvents.ts +105 -0
- package/src/uxsdk/useUXScrollDepth.ts +49 -0
- package/src/uxsdk/useUXUnreachableElementTracker.ts +100 -0
- package/src/views/HomeView/HomeView.styles.tsx +37 -0
- package/src/views/HomeView/HomeView.tsx +34 -0
- package/src/views/HomeView/index.ts +3 -0
- package/src/writer/Anchor/Anchor.styles.tsx +26 -0
- package/src/writer/Anchor/Anchor.tsx +51 -0
- package/src/writer/Anchor/index.tsx +1 -0
- package/src/writer/Badge/Badge.styles.tsx +44 -0
- package/src/writer/Badge/Badge.tsx +47 -0
- package/src/writer/Badge/index.ts +7 -0
- package/src/writer/Banner/Banner.styles.tsx +111 -0
- package/src/writer/Banner/Banner.tsx +151 -0
- package/src/writer/Banner/index.ts +1 -0
- package/src/writer/Blockquote/Blockquote.styles.tsx +20 -0
- package/src/writer/Blockquote/Blockquote.tsx +38 -0
- package/src/writer/Blockquote/index.ts +7 -0
- package/src/writer/BlogCard/BlogCard.styles.tsx +4 -0
- package/src/writer/BlogCard/BlogCard.tsx +9 -0
- package/src/writer/BlogCard/index.ts +3 -0
- package/src/writer/Breadcrumbs/Breadcrumbs.styles.ts +24 -0
- package/src/writer/Breadcrumbs/Breadcrumbs.tsx +57 -0
- package/src/writer/Breadcrumbs/index.ts +7 -0
- package/src/writer/Button/Button.styles.tsx +149 -0
- package/src/writer/Button/Button.tsx +82 -0
- package/src/writer/Button/index.ts +2 -0
- package/src/writer/Callout/Callout.styles.tsx +102 -0
- package/src/writer/Callout/Callout.tsx +166 -0
- package/src/writer/Callout/index.tsx +3 -0
- package/src/writer/Card/Card.styles.tsx +110 -0
- package/src/writer/Card/Card.tsx +94 -0
- package/src/writer/Card/index.ts +1 -0
- package/src/writer/Code/Code.styles.tsx +16 -0
- package/src/writer/Code/Code.tsx +16 -0
- package/src/writer/Code/index.ts +3 -0
- package/src/writer/ColorSchemeButton/ColorSchemeButton.tsx +191 -0
- package/src/writer/ColorSchemeButton/index.ts +1 -0
- package/src/writer/Details/Details.styles.tsx +101 -0
- package/src/writer/Details/Details.tsx +168 -0
- package/src/writer/Details/DetailsProps.tsx +34 -0
- package/src/writer/Details/index.ts +6 -0
- package/src/writer/GuideCard/GuideCard.styles.tsx +129 -0
- package/src/writer/GuideCard/GuideCard.tsx +123 -0
- package/src/writer/GuideCard/index.ts +1 -0
- package/src/writer/Heading/Heading.styles.tsx +93 -0
- package/src/writer/Heading/Heading.tsx +123 -0
- package/src/writer/Heading/index.ts +7 -0
- package/src/writer/Hr/Hr.styles.tsx +7 -0
- package/src/writer/Hr/Hr.tsx +10 -0
- package/src/writer/Hr/index.ts +3 -0
- package/src/writer/Icon/Icon.styles.tsx +15 -0
- package/src/writer/Icon/Icon.tsx +99 -0
- package/src/writer/Icon/index.ts +1 -0
- package/src/writer/IconSocial/IconSocial.tsx +107 -0
- package/src/writer/IconSocial/index.ts +1 -0
- package/src/writer/Image/Image.styles.tsx +9 -0
- package/src/writer/Image/Image.tsx +35 -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 +32 -0
- package/src/writer/NavLinks/NavLinks.tsx +95 -0
- package/src/writer/NavLinks/index.ts +7 -0
- package/src/writer/Pre/Pre.styles.tsx +13 -0
- package/src/writer/Pre/Pre.tsx +14 -0
- package/src/writer/Pre/index.ts +3 -0
- package/src/writer/README.md +1 -0
- package/src/writer/Steps/Steps.styles.tsx +91 -0
- package/src/writer/Steps/Steps.tsx +75 -0
- package/src/writer/Steps/index.ts +5 -0
- package/src/writer/Table/Table.styles.tsx +100 -0
- package/src/writer/Table/Table.tsx +158 -0
- package/src/writer/Table/index.ts +3 -0
- package/src/writer/Tabs/Tabs.tsx +67 -0
- package/src/writer/Tabs/TabsAnalytics.tsx +25 -0
- package/src/writer/Tabs/TabsPrimary.styles.tsx +187 -0
- package/src/writer/Tabs/TabsPrimary.tsx +215 -0
- package/src/writer/Tabs/TabsProps.tsx +13 -0
- package/src/writer/Tabs/TabsSecondary.styles.tsx +78 -0
- package/src/writer/Tabs/TabsSecondary.tsx +176 -0
- package/src/writer/Tabs/index.ts +2 -0
- package/src/writer/Tabs/useValueChange.ts +84 -0
- 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/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 +53 -0
- package/system.ts +1 -0
- package/tsconfig.json +46 -0
- package/types.d.ts +52 -0
- package/uxsdk.ts +1 -0
- package/views.ts +2 -0
- package/writer.ts +1 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
|
|
3
|
+
import { Button } from "../Button"
|
|
4
|
+
import { Text } from "../Text"
|
|
5
|
+
|
|
6
|
+
import * as cn from "./Card.styles"
|
|
7
|
+
|
|
8
|
+
interface CardProps {
|
|
9
|
+
title: string
|
|
10
|
+
href?: string
|
|
11
|
+
link?: React.ElementType
|
|
12
|
+
|
|
13
|
+
description?: string
|
|
14
|
+
btnText?: string
|
|
15
|
+
|
|
16
|
+
imgSrc?: string
|
|
17
|
+
imgAlt?: string
|
|
18
|
+
|
|
19
|
+
logoSrc?: string
|
|
20
|
+
logoAlt?: string
|
|
21
|
+
|
|
22
|
+
shadow?: "md"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function Card(props: CardProps) {
|
|
26
|
+
const {
|
|
27
|
+
title,
|
|
28
|
+
description,
|
|
29
|
+
imgSrc,
|
|
30
|
+
imgAlt,
|
|
31
|
+
logoSrc,
|
|
32
|
+
logoAlt,
|
|
33
|
+
shadow,
|
|
34
|
+
href,
|
|
35
|
+
link,
|
|
36
|
+
btnText,
|
|
37
|
+
} = props
|
|
38
|
+
|
|
39
|
+
const Link = link
|
|
40
|
+
|
|
41
|
+
return <xyd-card
|
|
42
|
+
data-shadow={shadow || undefined}
|
|
43
|
+
className={cn.CardHost}
|
|
44
|
+
>
|
|
45
|
+
{imgSrc && (
|
|
46
|
+
<div part="image-container">
|
|
47
|
+
<div part="bg">
|
|
48
|
+
<img src={imgSrc} alt={imgAlt} />
|
|
49
|
+
<div part="bg-shadow" />
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
{
|
|
53
|
+
Link && href && logoSrc && <Link
|
|
54
|
+
target="_blank"
|
|
55
|
+
rel="noopener"
|
|
56
|
+
part="author-link"
|
|
57
|
+
href={href}
|
|
58
|
+
>
|
|
59
|
+
<img
|
|
60
|
+
src={logoSrc}
|
|
61
|
+
alt={logoAlt}
|
|
62
|
+
/>
|
|
63
|
+
</Link>
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
</div>
|
|
67
|
+
)}
|
|
68
|
+
|
|
69
|
+
<div part="body">
|
|
70
|
+
<div part="header">
|
|
71
|
+
{Link && href && !logoSrc ?
|
|
72
|
+
<Text weight="bold">
|
|
73
|
+
<Link href={href}>
|
|
74
|
+
{title}
|
|
75
|
+
</Link>
|
|
76
|
+
</Text>
|
|
77
|
+
: <Text weight="bold">
|
|
78
|
+
{title}
|
|
79
|
+
</Text>}
|
|
80
|
+
{
|
|
81
|
+
btnText && <Button size="md" kind="secondary">
|
|
82
|
+
{btnText}
|
|
83
|
+
</Button>
|
|
84
|
+
}
|
|
85
|
+
</div>
|
|
86
|
+
<div part="description">
|
|
87
|
+
<Text size="small">
|
|
88
|
+
{description}
|
|
89
|
+
</Text>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</xyd-card>
|
|
93
|
+
}
|
|
94
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {Card} from "./Card"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {css} from "@linaria/core";
|
|
2
|
+
|
|
3
|
+
export const CodeHost = css`
|
|
4
|
+
@layer defaults {
|
|
5
|
+
display: inline-block;
|
|
6
|
+
padding: 0 .3em;
|
|
7
|
+
border-radius: 6px;
|
|
8
|
+
margin: 0 3px;
|
|
9
|
+
border: .5px solid var(--xyd-code-border-color);
|
|
10
|
+
background: var(--xyd-code-bgcolor);
|
|
11
|
+
|
|
12
|
+
& [part="content"] {
|
|
13
|
+
position: relative;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
|
|
3
|
+
import * as cn from "./Code.styles";
|
|
4
|
+
|
|
5
|
+
export interface CodeProps {
|
|
6
|
+
className?: string;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function Code({ className, children }: CodeProps) {
|
|
11
|
+
return <code className={`${cn.CodeHost} ${className || ''}`}>
|
|
12
|
+
<span part="content">
|
|
13
|
+
{children}
|
|
14
|
+
</span>
|
|
15
|
+
</code>
|
|
16
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
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(): ["dark" | "light" | null, () => void] {
|
|
17
|
+
const [currentScheme, setCurrentScheme] = useState<"dark" | "light" | null>(null)
|
|
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
|
+
const finalScheme = preferred || "light";
|
|
28
|
+
setCurrentScheme(finalScheme);
|
|
29
|
+
updateColorSchemeInHead(finalScheme);
|
|
30
|
+
} else {
|
|
31
|
+
const finalScheme = scheme as "dark" | "light";
|
|
32
|
+
setCurrentScheme(finalScheme);
|
|
33
|
+
updateColorSchemeInHead(finalScheme);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
updateScheme();
|
|
39
|
+
|
|
40
|
+
// Listen for changes to the color scheme
|
|
41
|
+
const observer = new MutationObserver(updateScheme);
|
|
42
|
+
const html = document.querySelector("html");
|
|
43
|
+
if (html) {
|
|
44
|
+
observer.observe(html, { attributes: true, attributeFilter: ['data-color-scheme'] });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return () => observer.disconnect();
|
|
48
|
+
}, []);
|
|
49
|
+
|
|
50
|
+
function changeColorScheme() {
|
|
51
|
+
let colorScheme = ""
|
|
52
|
+
|
|
53
|
+
const preferredColorScheme = getPreferredColorScheme()
|
|
54
|
+
if (preferredColorScheme) {
|
|
55
|
+
colorScheme = preferredColorScheme === "dark" ? "light" : "dark"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const html = document.querySelector("html");
|
|
59
|
+
if (!html) return;
|
|
60
|
+
|
|
61
|
+
const currentScheme = html.getAttribute("data-color-scheme");
|
|
62
|
+
if (currentScheme && currentScheme !== "os") {
|
|
63
|
+
colorScheme = currentScheme === "dark" ? "light" : "dark";
|
|
64
|
+
}
|
|
65
|
+
if (!colorScheme) {
|
|
66
|
+
colorScheme = "light"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
html.setAttribute("data-color-scheme", colorScheme);
|
|
70
|
+
localStorage.setItem("xyd-color-scheme", colorScheme);
|
|
71
|
+
updateColorSchemeInHead(colorScheme as "dark" | "light");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return [currentScheme, changeColorScheme]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
// Function to update color-scheme in document head
|
|
79
|
+
function updateColorSchemeInHead(scheme: "dark" | "light") {
|
|
80
|
+
let styleElement = document.querySelector('style[data-color-scheme-style]');
|
|
81
|
+
|
|
82
|
+
if (!styleElement) {
|
|
83
|
+
styleElement = document.createElement('style');
|
|
84
|
+
styleElement.setAttribute('data-color-scheme-style', 'true');
|
|
85
|
+
document.head.appendChild(styleElement);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
styleElement.textContent = `:root { color-scheme: ${scheme}; }`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getPreferredColorScheme() {
|
|
92
|
+
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
93
|
+
return 'dark';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (window.matchMedia('(prefers-color-scheme: light)').matches) {
|
|
97
|
+
return 'light';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return null
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
function IconLightMode() {
|
|
105
|
+
return <svg
|
|
106
|
+
width={16}
|
|
107
|
+
height={16}
|
|
108
|
+
viewBox="0 0 16 16"
|
|
109
|
+
fill="none"
|
|
110
|
+
stroke="currentColor"
|
|
111
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
112
|
+
>
|
|
113
|
+
<g clipPath="url(#clip0_2880_7340)">
|
|
114
|
+
<path
|
|
115
|
+
d="M8 1.11133V2.00022"
|
|
116
|
+
strokeWidth={1.5}
|
|
117
|
+
strokeLinecap="round"
|
|
118
|
+
strokeLinejoin="round"
|
|
119
|
+
/>
|
|
120
|
+
<path
|
|
121
|
+
d="M12.8711 3.12891L12.2427 3.75735"
|
|
122
|
+
strokeWidth={1.5}
|
|
123
|
+
strokeLinecap="round"
|
|
124
|
+
strokeLinejoin="round"
|
|
125
|
+
/>
|
|
126
|
+
<path
|
|
127
|
+
d="M14.8889 8H14"
|
|
128
|
+
strokeWidth={1.5}
|
|
129
|
+
strokeLinecap="round"
|
|
130
|
+
strokeLinejoin="round"
|
|
131
|
+
/>
|
|
132
|
+
<path
|
|
133
|
+
d="M12.8711 12.8711L12.2427 12.2427"
|
|
134
|
+
strokeWidth={1.5}
|
|
135
|
+
strokeLinecap="round"
|
|
136
|
+
strokeLinejoin="round"
|
|
137
|
+
/>
|
|
138
|
+
<path
|
|
139
|
+
d="M8 14.8889V14"
|
|
140
|
+
strokeWidth={1.5}
|
|
141
|
+
strokeLinecap="round"
|
|
142
|
+
strokeLinejoin="round"
|
|
143
|
+
/>
|
|
144
|
+
<path
|
|
145
|
+
d="M3.12891 12.8711L3.75735 12.2427"
|
|
146
|
+
strokeWidth={1.5}
|
|
147
|
+
strokeLinecap="round"
|
|
148
|
+
strokeLinejoin="round"
|
|
149
|
+
/>
|
|
150
|
+
<path
|
|
151
|
+
d="M1.11133 8H2.00022"
|
|
152
|
+
strokeWidth={1.5}
|
|
153
|
+
strokeLinecap="round"
|
|
154
|
+
strokeLinejoin="round"
|
|
155
|
+
/>
|
|
156
|
+
<path
|
|
157
|
+
d="M3.12891 3.12891L3.75735 3.75735"
|
|
158
|
+
strokeWidth={1.5}
|
|
159
|
+
strokeLinecap="round"
|
|
160
|
+
strokeLinejoin="round"
|
|
161
|
+
/>
|
|
162
|
+
<path
|
|
163
|
+
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"
|
|
164
|
+
strokeWidth={1.5}
|
|
165
|
+
strokeLinecap="round"
|
|
166
|
+
strokeLinejoin="round"
|
|
167
|
+
/>
|
|
168
|
+
</g>
|
|
169
|
+
<defs>
|
|
170
|
+
<clipPath id="clip0_2880_7340">
|
|
171
|
+
<rect width={16} height={16} fill="white" />
|
|
172
|
+
</clipPath>
|
|
173
|
+
</defs>
|
|
174
|
+
</svg>
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function IconDarkMode() {
|
|
178
|
+
return <svg
|
|
179
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
180
|
+
width={16}
|
|
181
|
+
height={16}
|
|
182
|
+
viewBox="0 0 24 24"
|
|
183
|
+
fill="none"
|
|
184
|
+
stroke="currentColor"
|
|
185
|
+
strokeWidth={2}
|
|
186
|
+
strokeLinecap="round"
|
|
187
|
+
strokeLinejoin="round"
|
|
188
|
+
>
|
|
189
|
+
<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" />
|
|
190
|
+
</svg>
|
|
191
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColorSchemeButton, useColorScheme } from "./ColorSchemeButton";
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { css } from "@linaria/core";
|
|
2
|
+
|
|
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
|
+
}
|
|
12
|
+
|
|
13
|
+
&[data-kind="tertiary"] {
|
|
14
|
+
padding: 8px;
|
|
15
|
+
|
|
16
|
+
[part="content"] {
|
|
17
|
+
border-radius: 8px;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&[open] [part="summary"] svg[data-icon="true"] {
|
|
22
|
+
transform: rotate(90deg);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[part="summary"] {
|
|
26
|
+
padding: 16px 14px 16px 0;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
font-weight: var(--xyd-font-weight-medium);
|
|
29
|
+
font-variant-numeric: tabular-nums;
|
|
30
|
+
transition: color 0.3s;
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: row;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: flex-start;
|
|
35
|
+
list-style: none;
|
|
36
|
+
|
|
37
|
+
&:hover {
|
|
38
|
+
color: var(--xyd-details-summary-color--active);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&[data-kind="tertiary"] [part="summary"]{
|
|
43
|
+
padding: 10px 24px;
|
|
44
|
+
}
|
|
45
|
+
&[data-kind="secondary"],
|
|
46
|
+
&[data-kind="tertiary"] {
|
|
47
|
+
[part="summary"] {
|
|
48
|
+
display: flex;
|
|
49
|
+
justify-content: space-between;
|
|
50
|
+
align-items: center;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
padding: 20px 24px;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
[part="summary-deep"] {
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
margin-bottom: 8px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
[part="summary-deep-text"] {
|
|
63
|
+
color: var(--xyd-details-summary-color);
|
|
64
|
+
text-transform: none;
|
|
65
|
+
letter-spacing: .08em;
|
|
66
|
+
margin-left: 8px;
|
|
67
|
+
font-weight: var(--xyd-font-weight-bold);
|
|
68
|
+
|
|
69
|
+
code {
|
|
70
|
+
background: var(--xyd-details-summary-code-bgcolor);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
[part="summary-deep-label"] {
|
|
75
|
+
flex: 1 1 auto;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// TODO: after migration to web-components should be removed cuz 'part="content"' can be also in another element as child
|
|
79
|
+
& > [part="content"] {
|
|
80
|
+
padding: 0 24px 20px;
|
|
81
|
+
}
|
|
82
|
+
&[data-kind="tertiary"] > [part="content"] {
|
|
83
|
+
background-color: var(--xyd-details-content-bgcolor);
|
|
84
|
+
padding-top: 20px;
|
|
85
|
+
|
|
86
|
+
code {
|
|
87
|
+
background: var(--xyd-details-content-bgcolor);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
[part="icon"] {
|
|
92
|
+
flex: 0 0 auto;
|
|
93
|
+
font-size: var(--xyd-font-size-medium);
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
padding-right: 6px;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import React, {} from "react"
|
|
2
|
+
|
|
3
|
+
import * as cn from "./Details.styles";
|
|
4
|
+
import {useUXClick, useUXEvents} from "../../uxsdk";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Base interface for all Details component variants
|
|
8
|
+
*/
|
|
9
|
+
export interface BaseDetailsProps {
|
|
10
|
+
/** Content to be displayed inside the details element */
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
|
|
13
|
+
/** Label text displayed in the summary */
|
|
14
|
+
label: string;
|
|
15
|
+
|
|
16
|
+
/** Optional icon element to be displayed in the summary */
|
|
17
|
+
icon?: React.ReactElement;
|
|
18
|
+
|
|
19
|
+
/** Optional CSS class name for custom styling */
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Props for the tertiary variant of the Details component
|
|
25
|
+
*/
|
|
26
|
+
export interface TertiaryDetailsProps extends BaseDetailsProps {
|
|
27
|
+
/** Specifies the tertiary variant */
|
|
28
|
+
kind: "tertiary";
|
|
29
|
+
|
|
30
|
+
/** Title text or element displayed in the summary */
|
|
31
|
+
title: string | React.ReactNode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Props for the secondary variant of the Details component
|
|
36
|
+
*/
|
|
37
|
+
export interface SecondaryDetailsProps extends BaseDetailsProps {
|
|
38
|
+
/** Specifies the secondary variant */
|
|
39
|
+
kind: "secondary";
|
|
40
|
+
|
|
41
|
+
/** Title text or element displayed in the summary */
|
|
42
|
+
title: string | React.ReactNode;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Props for the primary variant of the Details component
|
|
47
|
+
*/
|
|
48
|
+
export interface PrimaryDetailsProps extends BaseDetailsProps {
|
|
49
|
+
/** Specifies the primary variant (default) */
|
|
50
|
+
kind?: "primary";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Union type of all possible Details component variants */
|
|
54
|
+
export type DetailsProps = PrimaryDetailsProps | SecondaryDetailsProps | TertiaryDetailsProps
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A collapsible details component that supports three variants: primary, secondary, and tertiary.
|
|
58
|
+
* Each variant has a different visual style and structure.
|
|
59
|
+
*
|
|
60
|
+
* @param props - The component props
|
|
61
|
+
* @returns A details element with collapsible content
|
|
62
|
+
*
|
|
63
|
+
* @category Component
|
|
64
|
+
*/
|
|
65
|
+
export function Details(props: DetailsProps): React.ReactElement {
|
|
66
|
+
const {children, label} = props;
|
|
67
|
+
|
|
68
|
+
const ux = useUXEvents();
|
|
69
|
+
const uxClick = useUXClick(
|
|
70
|
+
ux.docs.details.open,
|
|
71
|
+
ux.docs.details.close,
|
|
72
|
+
() => ({label})
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
let title
|
|
76
|
+
|
|
77
|
+
const isDeepKind = ["secondary", "tertiary"].includes(props.kind || "");
|
|
78
|
+
|
|
79
|
+
if (isDeepKind && "title" in props) {
|
|
80
|
+
title = props.title;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const kind = props.kind || "primary";
|
|
84
|
+
|
|
85
|
+
return <details
|
|
86
|
+
part="details"
|
|
87
|
+
className={`${cn.DetailsHost} ${props.className || ""}`}
|
|
88
|
+
data-kind={props.kind}
|
|
89
|
+
onClick={uxClick}
|
|
90
|
+
>
|
|
91
|
+
<summary part="summary">
|
|
92
|
+
{kind === "primary" && (
|
|
93
|
+
<>
|
|
94
|
+
{props.icon || <$Icon/>}
|
|
95
|
+
<div part="summary-deep-label">
|
|
96
|
+
{label}
|
|
97
|
+
</div>
|
|
98
|
+
</>
|
|
99
|
+
)}
|
|
100
|
+
|
|
101
|
+
{isDeepKind && (
|
|
102
|
+
<div>
|
|
103
|
+
<div part="summary-deep">
|
|
104
|
+
{props.icon || <$IconDeep/>}
|
|
105
|
+
<div part="summary-deep-text">
|
|
106
|
+
{title}
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
<div part="summary-deep-label">
|
|
110
|
+
{label}
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
)}
|
|
114
|
+
{isDeepKind && <$Icon/>}
|
|
115
|
+
</summary>
|
|
116
|
+
|
|
117
|
+
<div part="content">
|
|
118
|
+
{children}
|
|
119
|
+
</div>
|
|
120
|
+
</details>
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function $Icon() {
|
|
124
|
+
return <div part="icon">
|
|
125
|
+
<svg
|
|
126
|
+
// TODO: bad solution
|
|
127
|
+
data-icon="true"
|
|
128
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
129
|
+
width="1em"
|
|
130
|
+
height="1em"
|
|
131
|
+
fill="currentColor"
|
|
132
|
+
viewBox="0 0 24 24"
|
|
133
|
+
>
|
|
134
|
+
<path
|
|
135
|
+
fillRule="evenodd"
|
|
136
|
+
d="M8.293 4.293a1 1 0 0 1 1.414 0l7 7a1 1 0 0 1 0 1.414l-7 7a1 1 0 0 1-1.414-1.414L14.586 12 8.293 5.707a1 1 0 0 1 0-1.414Z"
|
|
137
|
+
clipRule="evenodd"
|
|
138
|
+
/>
|
|
139
|
+
</svg>
|
|
140
|
+
</div>
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function $IconDeep() {
|
|
144
|
+
return <svg
|
|
145
|
+
width="1em"
|
|
146
|
+
height="1em"
|
|
147
|
+
viewBox="0 0 24 24"
|
|
148
|
+
stroke="none"
|
|
149
|
+
fill="currentColor"
|
|
150
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
151
|
+
>
|
|
152
|
+
<g clipPath="url(#clip0_1689_2180)">
|
|
153
|
+
<path
|
|
154
|
+
d="M4.3 4.3L7.1 7.1M10.6 5.7V1.5M14.8 7.8L17.6 5M5.7 11.3H1.5M7.1 14.8L4.3 17.6M15.5 22.5L9.9 9.9L22.5 14.8L16.9 16.2L15.5 22.5Z"
|
|
155
|
+
stroke="currentColor"
|
|
156
|
+
strokeWidth={2}
|
|
157
|
+
strokeLinecap="round"
|
|
158
|
+
strokeLinejoin="round"
|
|
159
|
+
/>
|
|
160
|
+
</g>
|
|
161
|
+
<defs>
|
|
162
|
+
<clipPath id="clip0_1689_2180">
|
|
163
|
+
<rect width={24} height={24} fill="white"/>
|
|
164
|
+
</clipPath>
|
|
165
|
+
</defs>
|
|
166
|
+
</svg>
|
|
167
|
+
}
|
|
168
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface DetailsProps {
|
|
2
|
+
/** Content to be displayed inside the details element */
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
|
|
5
|
+
/** Label text displayed in the summary */
|
|
6
|
+
label: string;
|
|
7
|
+
|
|
8
|
+
/** Optional icon element to be displayed in the summary */
|
|
9
|
+
icon?: React.ReactElement;
|
|
10
|
+
|
|
11
|
+
/** Optional CSS class name for custom styling */
|
|
12
|
+
className?: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Which visual style to use.
|
|
16
|
+
* @default 'primary'
|
|
17
|
+
*/
|
|
18
|
+
kind?: 'primary' | 'secondary' | 'tertiary';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Title text or element displayed in the summary.
|
|
22
|
+
* Required when `kind` is 'secondary' or 'tertiary'.
|
|
23
|
+
*/
|
|
24
|
+
title?: React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Props for the Details component
|
|
29
|
+
*
|
|
30
|
+
* @category Component
|
|
31
|
+
*/
|
|
32
|
+
export function DetailsProps(props: DetailsProps) {
|
|
33
|
+
return props
|
|
34
|
+
}
|