@xyd-js/components 0.1.0-xyd.8 → 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 +712 -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-ACBdUgyz.js.map → HomeView-C8QlNdKh.js.map} +1 -1
- package/dist/HomeView-ZAP5saNy.js +2 -0
- package/dist/{HomeView-B0ATNUF1.js.map → HomeView-ZAP5saNy.js.map} +1 -1
- 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.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 +264 -201
- package/dist/content.js +1 -1
- package/dist/content.js.map +1 -1
- package/dist/index.css +261 -211
- 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-BBkx4Se1.js.map → tslib.es6-DyL9kPq9.js.map} +1 -1
- package/dist/tslib.es6-Hqk-Mdr9.js +2 -0
- package/dist/{tslib.es6-BF6ZLEXa.js.map → tslib.es6-Hqk-Mdr9.js.map} +1 -1
- package/dist/views.js +1 -1
- package/dist/writer.d.ts +409 -77
- package/dist/writer.js +1 -1
- package/dist/writer.js.map +1 -1
- package/docs/.nojekyll +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +22 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1640 -0
- package/docs/functions/GuideCard.html +6 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +2 -0
- package/docs/interfaces/GuideCardProps.html +18 -0
- package/docs/modules.html +1 -0
- package/index.ts +0 -1
- package/package.json +9 -15
- package/project.json +677 -0
- package/rollup.config.js +30 -20
- package/src/brand/Button/Button.styles.tsx +0 -3
- package/src/brand/CTABanner/CTABanner.styles.tsx +2 -4
- package/src/brand/Footer/Footer.styles.tsx +0 -3
- package/src/coder/Code/Code.styles.tsx +135 -33
- package/src/coder/Code/Code.tsx +129 -38
- package/src/coder/Code/CodeLoader.tsx +3 -3
- package/src/coder/Code/annotations.tsx +28 -8
- package/src/coder/Code/highlight.ts +38 -0
- package/src/coder/Code/index.ts +2 -1
- package/src/coder/CodeCopy/CodeCopy.styles.tsx +13 -11
- package/src/coder/CodeCopy/CodeCopy.tsx +5 -3
- package/src/coder/CodeSample/CodeSample.tsx +83 -27
- package/src/coder/CodeTabs/CodeTabs.styles.tsx +111 -94
- package/src/coder/CodeTabs/CodeTabs.tsx +69 -51
- package/src/coder/CodeTheme/CodeTheme.tsx +89 -49
- package/src/coder/CodeTheme/index.ts +0 -1
- package/src/coder/CoderProvider.tsx +26 -0
- package/src/coder/index.ts +8 -4
- package/src/content/ContentDecoator.styles.tsx +113 -0
- package/src/content/ContentDecorator.tsx +17 -0
- package/src/content/GridDecorator.styles.tsx +67 -0
- package/src/content/GridDecorator.tsx +21 -0
- package/src/content/ReactContent.tsx +575 -0
- package/src/content/index.ts +10 -2
- package/src/icons/index.ts +0 -0
- package/src/kit/Loader/Loader.styles.tsx +53 -0
- package/src/kit/Loader/Loader.tsx +22 -0
- package/src/kit/index.ts +1 -0
- package/src/layouts/LayoutPrimary/LayoutPrimary.styles.tsx +270 -306
- package/src/layouts/LayoutPrimary/LayoutPrimary.tsx +171 -91
- package/src/layouts/LayoutPrimary/index.ts +0 -2
- package/src/layouts/index.ts +0 -7
- package/src/system/SearchButton/SearchButton.styles.tsx +86 -0
- package/src/system/SearchButton/SearchButton.tsx +116 -0
- package/src/system/SearchButton/index.ts +1 -0
- package/src/system/index.ts +1 -0
- package/src/writer/Anchor/Anchor.styles.tsx +11 -0
- package/src/{content → writer}/Anchor/Anchor.tsx +20 -22
- package/src/writer/Anchor/index.tsx +1 -0
- package/src/writer/Badge/Badge.styles.tsx +37 -27
- package/src/writer/Badge/Badge.tsx +34 -48
- package/src/writer/Banner/Banner.styles.tsx +91 -0
- package/src/writer/Banner/Banner.tsx +70 -0
- package/src/writer/Banner/index.ts +1 -0
- package/src/writer/Blockquote/Blockquote.styles.tsx +6 -4
- package/src/writer/Blockquote/Blockquote.tsx +5 -2
- package/src/writer/Breadcrumbs/Breadcrumbs.styles.ts +25 -25
- package/src/writer/Breadcrumbs/Breadcrumbs.tsx +18 -12
- package/src/writer/Button/Button.styles.tsx +137 -0
- package/src/writer/Button/Button.tsx +75 -0
- package/src/writer/Button/index.ts +2 -0
- package/src/writer/Callout/Callout.styles.tsx +35 -42
- package/src/writer/Callout/Callout.tsx +30 -15
- package/src/writer/Card/Card.styles.tsx +47 -0
- package/src/writer/Card/Card.tsx +69 -0
- package/src/writer/Card/index.ts +1 -0
- package/src/writer/Code/Code.styles.tsx +12 -11
- package/src/writer/Code/Code.tsx +6 -3
- package/src/writer/ColorSchemeButton/ColorSchemeButton.tsx +172 -0
- package/src/writer/ColorSchemeButton/index.ts +1 -0
- package/src/writer/Details/Details.styles.tsx +87 -98
- package/src/writer/Details/Details.tsx +65 -44
- package/src/writer/Example/index.tsx +5 -0
- package/src/writer/GuideCard/GuideCard.styles.tsx +100 -103
- package/src/writer/GuideCard/GuideCard.tsx +72 -37
- package/src/writer/Heading/Heading.styles.tsx +76 -60
- package/src/writer/Heading/Heading.tsx +92 -22
- package/src/writer/Hr/Hr.styles.tsx +3 -1
- package/src/writer/Hr/Hr.tsx +2 -5
- package/src/writer/Icon/Icon.tsx +48 -0
- package/src/writer/Icon/index.ts +1 -0
- package/src/writer/Image/Image.styles.tsx +9 -0
- package/src/writer/Image/Image.tsx +19 -0
- package/src/writer/Image/index.ts +1 -0
- package/src/writer/List/List.styles.tsx +47 -0
- package/src/writer/List/List.tsx +29 -0
- package/src/writer/List/index.ts +4 -0
- package/src/writer/NavLinks/NavLinks.styles.ts +26 -26
- package/src/writer/NavLinks/NavLinks.tsx +65 -18
- package/src/writer/Pre/Pre.styles.tsx +8 -6
- package/src/writer/Pre/Pre.tsx +3 -2
- package/src/writer/Steps/Steps.styles.tsx +27 -24
- package/src/writer/Steps/Steps.tsx +38 -8
- package/src/writer/Table/Table.styles.tsx +65 -34
- package/src/writer/Table/Table.tsx +121 -11
- package/src/writer/Table/index.ts +0 -11
- package/src/writer/Tabs/Tabs.styles.tsx +51 -55
- package/src/writer/Tabs/Tabs.tsx +30 -23
- package/src/writer/Text/Text.styles.tsx +66 -0
- package/src/writer/Text/Text.tsx +79 -0
- package/src/writer/Text/index.ts +3 -0
- package/src/writer/TocCard/TocCard.module.css +44 -0
- package/src/writer/TocCard/TocCard.tsx +42 -0
- package/src/writer/TocCard/index.ts +3 -0
- package/src/writer/UnderlineNav/Tabs.tsx +51 -0
- package/src/writer/UnderlineNav/TabsPrimary.styles.tsx +184 -0
- package/src/writer/UnderlineNav/TabsPrimary.tsx +209 -0
- package/src/writer/UnderlineNav/TabsSecondary.styles.tsx +77 -0
- package/src/writer/UnderlineNav/TabsSecondary.tsx +171 -0
- package/src/writer/UnderlineNav/UnderlineNav.styles.tsx +165 -31
- package/src/writer/UnderlineNav/UnderlineNav.tsx +257 -22
- package/src/writer/UnderlineNav/index.ts +2 -1
- package/src/writer/UnderlineNav/useValueChange.ts +60 -0
- package/src/writer/Update/Update.styles.tsx +33 -0
- package/src/writer/Update/Update.tsx +37 -0
- package/src/writer/Update/index.ts +1 -0
- package/src/writer/VideoGuide/VideoGuide.module.css +105 -0
- package/src/writer/VideoGuide/VideoGuide.tsx +75 -0
- package/src/writer/VideoGuide/index.ts +1 -0
- package/src/writer/index.ts +23 -1
- package/tsconfig.json +9 -3
- package/types.d.ts +50 -0
- package/writer.ts +1 -1
- package/dist/CTABanner-4FVIoaTR.js +0 -2
- package/dist/CTABanner-4FVIoaTR.js.map +0 -1
- package/dist/CTABanner-C6afsXoE.js +0 -2
- package/dist/CTABanner-C6afsXoE.js.map +0 -1
- package/dist/CTABanner-CEKs-Hb-.js +0 -2
- package/dist/CTABanner-CEKs-Hb-.js.map +0 -1
- package/dist/CTABanner-CUNcTr6s.js +0 -2
- package/dist/CTABanner-CUNcTr6s.js.map +0 -1
- package/dist/CTABanner-D02aIAsD.js +0 -2
- package/dist/CTABanner-D02aIAsD.js.map +0 -1
- package/dist/CTABanner-Dm3tUG3I.js +0 -2
- package/dist/CTABanner-Dm3tUG3I.js.map +0 -1
- package/dist/CTABanner-MCOcVowa.js +0 -2
- package/dist/CTABanner-MCOcVowa.js.map +0 -1
- package/dist/CTABanner-X6K49gSr.js +0 -2
- package/dist/CTABanner-X6K49gSr.js.map +0 -1
- package/dist/CodeSample-B9VUhTKF.js +0 -2
- package/dist/CodeSample-B9VUhTKF.js.map +0 -1
- package/dist/CodeSample-BSXeFy0x.js +0 -2
- package/dist/CodeSample-BSXeFy0x.js.map +0 -1
- package/dist/CodeSample-BwP208sQ.js +0 -2
- package/dist/CodeSample-BwP208sQ.js.map +0 -1
- package/dist/CodeSample-CUemtj_W.js +0 -2
- package/dist/CodeSample-CUemtj_W.js.map +0 -1
- package/dist/CodeSample-D0iKih-A.js +0 -2
- package/dist/CodeSample-D0iKih-A.js.map +0 -1
- package/dist/CodeSample-D33vTa6M.js +0 -2
- package/dist/CodeSample-D33vTa6M.js.map +0 -1
- package/dist/CodeSample-DUSx2KBt.js +0 -2
- package/dist/CodeSample-DUSx2KBt.js.map +0 -1
- package/dist/CodeSample-P4yxkHPW.js +0 -2
- package/dist/CodeSample-P4yxkHPW.js.map +0 -1
- package/dist/HomeView-ACBdUgyz.js +0 -2
- package/dist/HomeView-B0ATNUF1.js +0 -2
- package/dist/HomeView-COJrg8Ju.js +0 -2
- package/dist/HomeView-COJrg8Ju.js.map +0 -1
- package/dist/HomeView-Cun4apuy.js +0 -2
- package/dist/HomeView-Cun4apuy.js.map +0 -1
- package/dist/HomeView-D4DXEOOn.js +0 -2
- package/dist/HomeView-D4DXEOOn.js.map +0 -1
- package/dist/HomeView-DaH1PSBB.js +0 -2
- package/dist/HomeView-DaH1PSBB.js.map +0 -1
- package/dist/HomeView-O_lj2c2t.js +0 -2
- package/dist/HomeView-O_lj2c2t.js.map +0 -1
- package/dist/HomeView-_Nu2RcOM.js +0 -2
- package/dist/HomeView-_Nu2RcOM.js.map +0 -1
- package/dist/UnderlineNav-BCyB0G5d.js +0 -2
- package/dist/UnderlineNav-BCyB0G5d.js.map +0 -1
- package/dist/UnderlineNav-BEhDJk0H.js +0 -2
- package/dist/UnderlineNav-BEhDJk0H.js.map +0 -1
- package/dist/UnderlineNav-BqZ2xAp7.js +0 -2
- package/dist/UnderlineNav-BqZ2xAp7.js.map +0 -1
- package/dist/UnderlineNav-C2-4Vyj8.js +0 -2
- package/dist/UnderlineNav-C2-4Vyj8.js.map +0 -1
- package/dist/UnderlineNav-Co08Gykm.js +0 -2
- package/dist/UnderlineNav-Co08Gykm.js.map +0 -1
- package/dist/UnderlineNav-DC3UVmnZ.js +0 -2
- package/dist/UnderlineNav-DC3UVmnZ.js.map +0 -1
- package/dist/UnderlineNav-DsRYwuGB.js +0 -2
- package/dist/UnderlineNav-DsRYwuGB.js.map +0 -1
- package/dist/UnderlineNav-FbclXKUW.js +0 -2
- package/dist/UnderlineNav-FbclXKUW.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-BEouSrrZ.js +0 -2
- package/dist/_rollupPluginBabelHelpers-BEouSrrZ.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-BHehKRBq.js +0 -2
- package/dist/_rollupPluginBabelHelpers-BHehKRBq.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-Bunpz22T.js +0 -2
- package/dist/_rollupPluginBabelHelpers-Bunpz22T.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-CVblpRvU.js +0 -2
- package/dist/_rollupPluginBabelHelpers-CVblpRvU.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-CxmswfqM.js +0 -2
- package/dist/_rollupPluginBabelHelpers-CxmswfqM.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-DQJTK9EO.js +0 -2
- package/dist/_rollupPluginBabelHelpers-DQJTK9EO.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-DuRQdJ01.js +0 -2
- package/dist/_rollupPluginBabelHelpers-DuRQdJ01.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-tRAa4O0f.js +0 -2
- package/dist/_rollupPluginBabelHelpers-tRAa4O0f.js.map +0 -1
- package/dist/index-B0FncPxO.js +0 -2
- package/dist/index-B0FncPxO.js.map +0 -1
- package/dist/index-BEm-xkm-.js +0 -2
- package/dist/index-BEm-xkm-.js.map +0 -1
- package/dist/index-BHwtxG27.js +0 -2
- package/dist/index-BHwtxG27.js.map +0 -1
- package/dist/index-BTcmIG47.js +0 -2
- package/dist/index-BTcmIG47.js.map +0 -1
- package/dist/index-CNkHt1r7.js +0 -2
- package/dist/index-CNkHt1r7.js.map +0 -1
- package/dist/index-D0XuyFm7.js +0 -2
- package/dist/index-D0XuyFm7.js.map +0 -1
- package/dist/index-DBspcqWq.js +0 -2
- package/dist/index-DBspcqWq.js.map +0 -1
- package/dist/index-DVBO4gYE.js +0 -2
- package/dist/index-DVBO4gYE.js.map +0 -1
- package/dist/tslib.es6-BBkx4Se1.js +0 -2
- package/dist/tslib.es6-BF6ZLEXa.js +0 -2
- package/dist/tslib.es6-BOZCDgb8.js +0 -2
- package/dist/tslib.es6-BOZCDgb8.js.map +0 -1
- package/dist/tslib.es6-Cjl5tesf.js +0 -2
- package/dist/tslib.es6-Cjl5tesf.js.map +0 -1
- package/dist/tslib.es6-DEH7Dkgy.js +0 -2
- package/dist/tslib.es6-DEH7Dkgy.js.map +0 -1
- package/dist/tslib.es6-DTeJ7dWi.js +0 -2
- package/dist/tslib.es6-DTeJ7dWi.js.map +0 -1
- package/dist/tslib.es6-U9-f6pA7.js +0 -2
- package/dist/tslib.es6-U9-f6pA7.js.map +0 -1
- package/dist/tslib.es6-cb69JjeS.js +0 -2
- package/dist/tslib.es6-cb69JjeS.js.map +0 -1
- package/src/content/Anchor/Anchor.styles.tsx +0 -5
- package/src/content/Anchor/index.tsx +0 -3
- package/src/content/Content/Content.styles.tsx +0 -9
- package/src/content/Content/Content.tsx +0 -13
- package/src/content/Content/index.tsx +0 -3
- package/src/content/Content.tsx +0 -179
- package/src/content/Subtitle/Subtitle.styles.ts +0 -8
- package/src/content/Subtitle/Subtitle.tsx +0 -12
- package/src/content/Subtitle/index.tsx +0 -3
- package/src/layouts/Layout.styles.tsx +0 -155
- package/src/layouts/Layout.tsx +0 -119
- package/src/ui/Loader/Loader.styles.tsx +0 -54
- package/src/ui/Loader/Loader.tsx +0 -26
- package/src/ui/index.ts +0 -1
- package/src/writer/Icon/index.tsx +0 -355
- package/src/writer/Table/TableV2.styles.tsx +0 -117
- package/src/writer/Table/TableV2.tsx +0 -83
- /package/src/{ui → kit}/TODO.md +0 -0
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import {css} from "@linaria/core";
|
|
2
2
|
|
|
3
3
|
export const CodeCopyHost = css`
|
|
4
|
-
|
|
4
|
+
@layer defaults {
|
|
5
|
+
all: unset;
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
cursor: pointer;
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
|
|
13
|
+
border-radius: 6px;
|
|
14
|
+
padding: 6px;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
&:hover {
|
|
17
|
+
transition: ease-in 0.1s;
|
|
18
|
+
background: var(--xyd-code-copy-color);
|
|
19
|
+
}
|
|
18
20
|
}
|
|
19
21
|
`;
|
|
@@ -18,13 +18,15 @@ export function CodeCopy({text}: CodeCopyProps) {
|
|
|
18
18
|
}, 1200)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
return
|
|
21
|
+
return <xyd-code-copy>
|
|
22
22
|
<button
|
|
23
|
+
part="button"
|
|
24
|
+
className={cn.CodeCopyHost}
|
|
23
25
|
aria-label="Copy to clipboard"
|
|
24
26
|
onClick={onClick}
|
|
25
|
-
className={cn.CodeCopyHost}
|
|
26
27
|
>
|
|
27
28
|
{copied ? <CheckCheck size={16}/> : <Copy size={16}/>}
|
|
28
29
|
</button>
|
|
29
|
-
|
|
30
|
+
</xyd-code-copy>
|
|
31
|
+
|
|
30
32
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {Theme} from "@code-hike/lighter";
|
|
2
|
+
import { Theme } from "@code-hike/lighter";
|
|
3
3
|
|
|
4
|
-
import type {CodeThemeBlockProps} from "../CodeTheme";
|
|
4
|
+
import type { CodeThemeBlockProps } from "../CodeTheme";
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
Code,
|
|
@@ -10,50 +10,106 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
withCodeTabs
|
|
12
12
|
} from "../CodeTabs";
|
|
13
|
-
import {useCodeTheme} from "../CodeTheme";
|
|
13
|
+
import { useCodeTheme } from "../CodeTheme";
|
|
14
|
+
import { useCoder } from "../CoderProvider";
|
|
14
15
|
|
|
15
16
|
export interface CodeSampleProps {
|
|
16
17
|
name: string;
|
|
17
18
|
description: string;
|
|
18
|
-
codeblocks
|
|
19
|
+
codeblocks?: CodeThemeBlockProps[];
|
|
20
|
+
theme?: Theme
|
|
19
21
|
size?: "full"
|
|
22
|
+
lineNumbers?: boolean
|
|
23
|
+
descriptionHead?: string
|
|
24
|
+
descriptionContent?: string | React.ReactNode
|
|
25
|
+
descriptionIcon?: string
|
|
20
26
|
kind?: "secondary"
|
|
21
|
-
|
|
27
|
+
controlByMeta?: boolean // TODO: BETTER IN THE FUTURE
|
|
22
28
|
}
|
|
23
29
|
|
|
30
|
+
const CodeContext = React.createContext<{
|
|
31
|
+
size?: "full"
|
|
32
|
+
lineNumbers?: boolean
|
|
33
|
+
descriptionHead?: string
|
|
34
|
+
descriptionContent?: string | React.ReactNode
|
|
35
|
+
descriptionIcon?: string
|
|
36
|
+
}>({})
|
|
37
|
+
|
|
24
38
|
export function CodeSample(props: CodeSampleProps) {
|
|
25
|
-
return <Code
|
|
26
|
-
|
|
39
|
+
return <Code
|
|
40
|
+
codeblocks={props.codeblocks}
|
|
41
|
+
theme={props.theme}
|
|
42
|
+
>
|
|
43
|
+
<$ThemedCodeSample {...props} />
|
|
27
44
|
</Code>
|
|
28
45
|
}
|
|
29
46
|
|
|
30
47
|
function $ThemedCodeSample(props: CodeSampleProps) {
|
|
31
|
-
const {highlighted} = useCodeTheme()
|
|
48
|
+
const { highlighted } = useCodeTheme()
|
|
49
|
+
const coder = useCoder()
|
|
32
50
|
|
|
33
51
|
if (props.kind === "secondary") {
|
|
34
|
-
return <
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
52
|
+
return <CodeContext value={{
|
|
53
|
+
size: props.size,
|
|
54
|
+
lineNumbers: props.lineNumbers,
|
|
55
|
+
descriptionHead: props.descriptionHead,
|
|
56
|
+
descriptionContent: props.descriptionContent,
|
|
57
|
+
descriptionIcon: props.descriptionIcon,
|
|
58
|
+
}}>
|
|
59
|
+
<Code.Pre
|
|
60
|
+
codeblock={highlighted[0]}
|
|
61
|
+
handlers={[
|
|
62
|
+
annotations.mark,
|
|
63
|
+
annotations.bg,
|
|
64
|
+
annotations.lineNumbers
|
|
65
|
+
]}
|
|
66
|
+
/>
|
|
67
|
+
</CodeContext>
|
|
42
68
|
}
|
|
43
69
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
70
|
+
let size: "full" | undefined = undefined
|
|
71
|
+
if (typeof props.size === "string") {
|
|
72
|
+
size = props.size
|
|
73
|
+
} else if (typeof coder.scroll === "boolean" && !coder.scroll) {
|
|
74
|
+
size = "full"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const lineNumbers = props.lineNumbers ?? coder.lines
|
|
78
|
+
|
|
79
|
+
return <CodeContext value={{
|
|
80
|
+
size,
|
|
81
|
+
lineNumbers,
|
|
82
|
+
descriptionHead: props.descriptionHead,
|
|
83
|
+
descriptionContent: props.descriptionContent,
|
|
84
|
+
descriptionIcon: props.descriptionIcon,
|
|
85
|
+
}}>
|
|
86
|
+
<$CodeSampleTabs
|
|
87
|
+
description={props.description}
|
|
88
|
+
highlighted={highlighted}
|
|
89
|
+
controlByMeta={props.controlByMeta}
|
|
90
|
+
/>
|
|
91
|
+
</CodeContext>
|
|
49
92
|
}
|
|
50
93
|
|
|
51
|
-
const $CodeSampleTabs = withCodeTabs((props) =>
|
|
52
|
-
{
|
|
53
|
-
handlers=
|
|
94
|
+
const $CodeSampleTabs = withCodeTabs((props) => {
|
|
95
|
+
const { lineNumbers, size, descriptionHead, descriptionContent, descriptionIcon } = React.useContext(CodeContext)
|
|
96
|
+
const handlers = [
|
|
54
97
|
annotations.mark,
|
|
55
98
|
annotations.bg,
|
|
56
|
-
annotations.
|
|
57
|
-
]
|
|
58
|
-
|
|
99
|
+
annotations.diff
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
if (lineNumbers) {
|
|
103
|
+
handlers.push(annotations.lineNumbers)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return <Code.Pre
|
|
107
|
+
{...props}
|
|
108
|
+
descriptionHead={descriptionHead}
|
|
109
|
+
descriptionContent={descriptionContent}
|
|
110
|
+
descriptionIcon={descriptionIcon}
|
|
111
|
+
size={size}
|
|
112
|
+
handlers={handlers}
|
|
113
|
+
/>
|
|
114
|
+
})
|
|
59
115
|
|
|
@@ -1,104 +1,121 @@
|
|
|
1
|
-
import {css} from "@linaria/core";
|
|
1
|
+
import { css } from "@linaria/core";
|
|
2
2
|
|
|
3
3
|
export const CodeTabsHost = css`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
display: block;
|
|
5
|
+
`
|
|
6
|
+
|
|
7
|
+
export const CodeTabsRoot = css`
|
|
8
|
+
@layer defaults {
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
min-width: 0;
|
|
11
|
+
|
|
12
|
+
border: 1px solid var(--xyd-codetabs-border-color);
|
|
13
|
+
border-radius: 16px;
|
|
14
|
+
|
|
15
|
+
&[data-single="true"] [part="pre"] {
|
|
16
|
+
border: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&[data-nodescription="true"] {
|
|
20
|
+
xyd-codetabs-languages [part="languages-list"] {
|
|
21
|
+
justify-content: flex-start;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
15
25
|
`;
|
|
16
26
|
|
|
17
27
|
export const CodeTabsLanguagesHost = css`
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
28
|
+
@layer defaults {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex: 1 1 0%;
|
|
31
|
+
|
|
32
|
+
background: var(--xyd-codetabs-bgcolor);
|
|
33
|
+
|
|
34
|
+
border-top-right-radius: 10px;
|
|
35
|
+
border-top-left-radius: 10px;
|
|
36
|
+
border-bottom: 0px;
|
|
37
|
+
|
|
38
|
+
min-width: 0;
|
|
39
|
+
|
|
40
|
+
font-weight: var(--xyd-font-weight-semibold);
|
|
41
|
+
font-size: var(--xyd-font-size-xsmall);
|
|
42
|
+
|
|
43
|
+
&[data-single="true"] {
|
|
44
|
+
height: 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[part="description"] {
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
gap: 4px;
|
|
51
|
+
|
|
52
|
+
color: var(--xyd-codetabs-color);
|
|
53
|
+
|
|
54
|
+
margin-left: 4px;
|
|
55
|
+
margin-right: 4px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
[part="description-item"] {
|
|
59
|
+
display: flex;
|
|
60
|
+
padding-left: 16px;
|
|
61
|
+
padding-right: 16px;
|
|
62
|
+
flex: 1 1 0%;
|
|
63
|
+
gap: 16px;
|
|
64
|
+
border-radius: 4px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[part="copy"] {
|
|
68
|
+
display: none;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
[part="languages-list"] {
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-grow: 1;
|
|
74
|
+
justify-content: end;
|
|
75
|
+
gap: 8px;
|
|
76
|
+
padding: 0 10px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[part="language-trigger"] {
|
|
80
|
+
all: unset;
|
|
81
|
+
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
|
|
88
|
+
border-radius: 6px;
|
|
89
|
+
padding: 6px;
|
|
90
|
+
|
|
91
|
+
color: var(--xyd-codetabs-color);
|
|
92
|
+
|
|
93
|
+
&[data-state="active"] {
|
|
94
|
+
color: var(--xyd-codetabs-color--active);
|
|
95
|
+
border-bottom: 1px solid var(--xyd-codetabs-color--active);
|
|
96
|
+
border-bottom-left-radius: 0px;
|
|
97
|
+
border-bottom-right-radius: 0px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&:hover {
|
|
101
|
+
transition: ease-in 0.1s;
|
|
102
|
+
background: var(--xyd-codetabs-color--hover);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
[part="copy"] {
|
|
107
|
+
display: flex;
|
|
108
|
+
padding-left: 8px;
|
|
109
|
+
padding-right: 8px;
|
|
110
|
+
align-items: center;
|
|
111
|
+
}
|
|
112
|
+
&[data-single="true"] [part="copy"] {
|
|
113
|
+
top: 17px;
|
|
114
|
+
position: relative;
|
|
115
|
+
right: 5px;
|
|
116
|
+
}
|
|
68
117
|
}
|
|
69
118
|
`;
|
|
70
119
|
|
|
71
|
-
export const CodeTabsLanguagesDescription = css`
|
|
72
|
-
display: flex;
|
|
73
|
-
align-items: center;
|
|
74
|
-
gap: 4px;
|
|
75
|
-
|
|
76
|
-
font-size: 14px;
|
|
77
|
-
color: rgb(53, 55, 64);
|
|
78
|
-
|
|
79
|
-
margin-left: 4px;
|
|
80
|
-
margin-right: 4px;
|
|
81
|
-
`;
|
|
82
|
-
|
|
83
|
-
export const CodeTabsLanguagesDescriptionItem = css`
|
|
84
|
-
display: flex;
|
|
85
|
-
padding-left: 16px;
|
|
86
|
-
padding-right: 16px;
|
|
87
|
-
flex: 1 1 0%;
|
|
88
|
-
gap: 16px;
|
|
89
|
-
border-radius: 4px;
|
|
90
|
-
`;
|
|
91
|
-
|
|
92
|
-
export const CodeTabsLanguagesCopy = css`
|
|
93
|
-
display: flex;
|
|
94
|
-
padding-left: 8px;
|
|
95
|
-
padding-right: 8px;
|
|
96
|
-
align-items: center;
|
|
97
|
-
`;
|
|
98
120
|
|
|
99
|
-
export const CodeTabsLanguagesCopySingle = css`
|
|
100
|
-
top: 17px;
|
|
101
|
-
position: relative;
|
|
102
|
-
right: 5px;
|
|
103
|
-
`;
|
|
104
121
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, {} from "react";
|
|
2
|
-
import
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import {Tabs as TabsPrimitive} from "radix-ui"; // TODO: remove and use separation
|
|
3
3
|
import {
|
|
4
4
|
HighlightedCode,
|
|
5
5
|
} from "codehike/code"
|
|
@@ -12,36 +12,52 @@ import * as cn from "./CodeTabs.styles"; // TODO: style by highlighted?
|
|
|
12
12
|
export interface CodeTabsProps {
|
|
13
13
|
description: string;
|
|
14
14
|
highlighted: HighlightedCode[]
|
|
15
|
-
|
|
15
|
+
className?: string
|
|
16
|
+
controlByMeta?: boolean // TODO: BETTER IN THE FUTURE
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export function withCodeTabs(PreComponent) {
|
|
19
20
|
return function CodeTabs(props: CodeTabsProps) {
|
|
20
|
-
const isSingle = props
|
|
21
|
+
const isSingle = props?.highlighted?.length === 1 && !props.description
|
|
22
|
+
const defaultValue = props.highlighted[0]?.meta || props.highlighted[0]?.lang
|
|
23
|
+
const [activeTab, setActiveTab] = useState(defaultValue)
|
|
24
|
+
|
|
25
|
+
// Reset active tab when highlighted prop changes
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setActiveTab(defaultValue)
|
|
28
|
+
}, [defaultValue])
|
|
29
|
+
|
|
30
|
+
if (props?.highlighted?.length === 0) {
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
|
|
21
34
|
|
|
22
35
|
return (
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
<xyd-codetabs className={`${cn.CodeTabsHost} ${props.className || ""}`}>
|
|
37
|
+
<TabsPrimitive.Root
|
|
38
|
+
part="root"
|
|
39
|
+
data-single={String(isSingle)}
|
|
40
|
+
data-nodescription={!props.description ? "true" : undefined}
|
|
41
|
+
className={`${cn.CodeTabsRoot}`}
|
|
42
|
+
style={props.highlighted[0]?.style}
|
|
43
|
+
value={activeTab}
|
|
44
|
+
onValueChange={setActiveTab}
|
|
45
|
+
>
|
|
46
|
+
<$LanguageTabSwitcher
|
|
47
|
+
description={props.description}
|
|
48
|
+
highlighted={props.highlighted}
|
|
49
|
+
/>
|
|
32
50
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
))}
|
|
44
|
-
</TabsPrimitive.Root>
|
|
51
|
+
{props.highlighted?.map((codeblock, i) => (
|
|
52
|
+
<TabsPrimitive.Content value={codeblock.meta || codeblock.lang} key={i}>
|
|
53
|
+
<PreComponent
|
|
54
|
+
style={codeblock?.style || codeblock?.style}
|
|
55
|
+
codeblock={codeblock}
|
|
56
|
+
/>
|
|
57
|
+
</TabsPrimitive.Content>
|
|
58
|
+
))}
|
|
59
|
+
</TabsPrimitive.Root>
|
|
60
|
+
</xyd-codetabs>
|
|
45
61
|
)
|
|
46
62
|
}
|
|
47
63
|
}
|
|
@@ -52,44 +68,46 @@ interface LanguageTabSwitcherProps {
|
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
function $LanguageTabSwitcher(props: LanguageTabSwitcherProps) {
|
|
55
|
-
const isSingle = props
|
|
71
|
+
const isSingle = props?.highlighted?.length === 1 && !props.description
|
|
56
72
|
|
|
57
|
-
|
|
73
|
+
const highlighted = props.highlighted.filter((item, index, self) =>
|
|
74
|
+
index === self.findIndex((t) => (t.meta || t.lang) === (item.meta || item.lang))
|
|
75
|
+
);
|
|
76
|
+
return <xyd-codetabs-languages
|
|
77
|
+
data-single={String(isSingle)}
|
|
78
|
+
className={`
|
|
58
79
|
${cn.CodeTabsLanguagesHost}
|
|
59
|
-
${isSingle && cn.CodeTabsLanguagesHostSingle}
|
|
60
80
|
`}>
|
|
61
|
-
<$Description description={props.description}/>
|
|
62
81
|
|
|
63
|
-
|
|
64
|
-
|
|
82
|
+
{
|
|
83
|
+
props.description && <div part="description">
|
|
84
|
+
<div part="description-item">
|
|
85
|
+
{props.description}
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
<TabsPrimitive.List part="languages-list">
|
|
91
|
+
{highlighted?.map(({ meta, lang }, i) => {
|
|
65
92
|
if (isSingle) {
|
|
66
93
|
return null
|
|
67
94
|
}
|
|
68
|
-
return <TabsPrimitive.Trigger
|
|
69
|
-
|
|
95
|
+
return <TabsPrimitive.Trigger
|
|
96
|
+
part="language-trigger"
|
|
97
|
+
value={meta || lang}
|
|
98
|
+
key={i}
|
|
99
|
+
>
|
|
100
|
+
{meta || lang}
|
|
70
101
|
</TabsPrimitive.Trigger>
|
|
71
102
|
})}
|
|
72
103
|
</TabsPrimitive.List>
|
|
73
104
|
|
|
74
|
-
<div
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{props.highlighted?.map((codeblock, i) => (
|
|
79
|
-
<TabsPrimitive.Content value={codeblock.meta!} asChild key={i}>
|
|
80
|
-
<CodeCopy text={codeblock.value}/>
|
|
105
|
+
<div part="copy">
|
|
106
|
+
{highlighted?.map((codeblock, i) => (
|
|
107
|
+
<TabsPrimitive.Content value={codeblock.meta || codeblock.lang} asChild key={i}>
|
|
108
|
+
<CodeCopy text={codeblock.value} />
|
|
81
109
|
</TabsPrimitive.Content>
|
|
82
110
|
))}
|
|
83
111
|
</div>
|
|
84
|
-
</
|
|
112
|
+
</xyd-codetabs-languages>
|
|
85
113
|
}
|
|
86
|
-
|
|
87
|
-
function $Description(props: { description: string }) {
|
|
88
|
-
return <div className={cn.CodeTabsLanguagesDescription}>
|
|
89
|
-
<div className={cn.CodeTabsLanguagesDescriptionItem}>
|
|
90
|
-
{props.description}
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|