@acmekit/docs-ui 2.13.41
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/dist/Items-YPPZD6C6.mjs +312 -0
- package/dist/chunk-JD7BP7O5.mjs +13144 -0
- package/dist/index.d.mts +1550 -0
- package/dist/index.d.ts +1550 -0
- package/dist/index.js +15218 -0
- package/dist/index.mjs +366 -0
- package/package.json +58 -0
- package/src/components/Badge/index.tsx +74 -0
- package/src/components/BadgesList/index.tsx +18 -0
- package/src/components/BetaBadge/index.tsx +24 -0
- package/src/components/Bordered/index.tsx +21 -0
- package/src/components/BorderedIcon/index.tsx +60 -0
- package/src/components/Breadcrumbs/index.tsx +83 -0
- package/src/components/Button/index.tsx +100 -0
- package/src/components/Card/Layout/Default/index.tsx +124 -0
- package/src/components/Card/Layout/Filler/index.tsx +30 -0
- package/src/components/Card/Layout/Large/index.tsx +88 -0
- package/src/components/Card/Layout/Mini/index.tsx +142 -0
- package/src/components/Card/index.tsx +50 -0
- package/src/components/CardList/index.tsx +40 -0
- package/src/components/ChildDocs/index.tsx +9 -0
- package/src/components/CodeBlock/Actions/AskAi/index.tsx +10 -0
- package/src/components/CodeBlock/Actions/Copy/index.tsx +59 -0
- package/src/components/CodeBlock/Actions/index.tsx +137 -0
- package/src/components/CodeBlock/Collapsible/Button/index.tsx +58 -0
- package/src/components/CodeBlock/Collapsible/Fade/index.tsx +55 -0
- package/src/components/CodeBlock/Collapsible/Lines/index.tsx +22 -0
- package/src/components/CodeBlock/Header/Wrapper/index.tsx +46 -0
- package/src/components/CodeBlock/Header/index.tsx +67 -0
- package/src/components/CodeBlock/Inline/index.tsx +20 -0
- package/src/components/CodeBlock/Line/index.tsx +331 -0
- package/src/components/CodeBlock/index.tsx +510 -0
- package/src/components/CodeMdx/index.tsx +45 -0
- package/src/components/CodeTabs/Item/index.tsx +67 -0
- package/src/components/CodeTabs/index.tsx +319 -0
- package/src/components/ContentMenu/Actions/index.tsx +7 -0
- package/src/components/ContentMenu/Products/index.tsx +64 -0
- package/src/components/ContentMenu/Toc/index.tsx +148 -0
- package/src/components/ContentMenu/Version/index.tsx +77 -0
- package/src/components/ContentMenu/index.tsx +31 -0
- package/src/components/CopyButton/index.tsx +76 -0
- package/src/components/Details/Summary/index.tsx +75 -0
- package/src/components/Details/index.tsx +98 -0
- package/src/components/DetailsList/index.tsx +32 -0
- package/src/components/DottedSeparator/index.tsx +30 -0
- package/src/components/EditButton/index.tsx +32 -0
- package/src/components/EditDate/index.tsx +33 -0
- package/src/components/ErrorPage/Icon/index.tsx +428 -0
- package/src/components/ErrorPage/index.tsx +32 -0
- package/src/components/Feedback/Solutions/index.tsx +105 -0
- package/src/components/Feedback/index.tsx +304 -0
- package/src/components/Footer/index.tsx +23 -0
- package/src/components/Heading/H1/index.tsx +21 -0
- package/src/components/Heading/H2/index.tsx +47 -0
- package/src/components/Heading/H3/index.tsx +42 -0
- package/src/components/Heading/H4/index.tsx +14 -0
- package/src/components/Heading/index.tsx +4 -0
- package/src/components/IconHeadline/index.tsx +15 -0
- package/src/components/Icons/AiAssistant/index.tsx +462 -0
- package/src/components/Icons/ArrowRightDown/index.tsx +30 -0
- package/src/components/Icons/BundledProduct/index.tsx +72 -0
- package/src/components/Icons/CalendarRefresh/index.tsx +70 -0
- package/src/components/Icons/ChefHat/index.tsx +65 -0
- package/src/components/Icons/CircleDottedLine/index.tsx +60 -0
- package/src/components/Icons/CloudSolid/index.tsx +47 -0
- package/src/components/Icons/ColoredAcmeKit/index.tsx +13 -0
- package/src/components/Icons/DecisionProcess/index.tsx +58 -0
- package/src/components/Icons/Erp/index.tsx +92 -0
- package/src/components/Icons/Github/index.tsx +22 -0
- package/src/components/Icons/House/index.tsx +23 -0
- package/src/components/Icons/ImageBinary/index.tsx +69 -0
- package/src/components/Icons/Kapa/index.tsx +22 -0
- package/src/components/Icons/Markdown/index.tsx +25 -0
- package/src/components/Icons/NavigationDropdown/Admin/index.tsx +33 -0
- package/src/components/Icons/NavigationDropdown/Doc/index.tsx +41 -0
- package/src/components/Icons/NavigationDropdown/DocV1/index.tsx +37 -0
- package/src/components/Icons/NavigationDropdown/Modules/index.tsx +33 -0
- package/src/components/Icons/NavigationDropdown/Resources/index.tsx +37 -0
- package/src/components/Icons/NavigationDropdown/Store/index.tsx +37 -0
- package/src/components/Icons/NavigationDropdown/Ui/index.tsx +37 -0
- package/src/components/Icons/NavigationDropdown/User/index.tsx +37 -0
- package/src/components/Icons/PuzzleColored/index.tsx +35 -0
- package/src/components/Icons/QuestionMark/index.tsx +23 -0
- package/src/components/Icons/Restock/index.tsx +55 -0
- package/src/components/Icons/ScrollText/index.tsx +68 -0
- package/src/components/Icons/ShadedBg/index.tsx +334 -0
- package/src/components/Icons/Shop/index.tsx +68 -0
- package/src/components/Icons/SidebarLeft/index.tsx +42 -0
- package/src/components/Icons/StripeColored/index.tsx +60 -0
- package/src/components/Icons/ThumbDown/index.tsx +23 -0
- package/src/components/Icons/ThumbUp/index.tsx +23 -0
- package/src/components/Icons/WindowPaintbrush/index.tsx +57 -0
- package/src/components/Icons/index.tsx +20 -0
- package/src/components/InlineCode/index.tsx +42 -0
- package/src/components/InlineIcon/index.tsx +21 -0
- package/src/components/InlineThemeImage/index.tsx +14 -0
- package/src/components/Input/Search/index.tsx +64 -0
- package/src/components/Input/Text/index.tsx +39 -0
- package/src/components/Kbd/index.tsx +33 -0
- package/src/components/Label/index.tsx +19 -0
- package/src/components/Link/index.tsx +67 -0
- package/src/components/LinkButton/index.tsx +43 -0
- package/src/components/Loading/Dots/index.tsx +16 -0
- package/src/components/Loading/Spinner/index.tsx +19 -0
- package/src/components/Loading/index.tsx +43 -0
- package/src/components/MDXComponents/index.tsx +209 -0
- package/src/components/MainNav/DesktopMenu/ThemeMenu/index.tsx +76 -0
- package/src/components/MainNav/DesktopMenu/index.tsx +100 -0
- package/src/components/MainNav/Items/Dropdown/index.tsx +88 -0
- package/src/components/MainNav/Items/Link/index.tsx +34 -0
- package/src/components/MainNav/Items/index.tsx +61 -0
- package/src/components/MainNav/MobileMenu/Main/index.tsx +67 -0
- package/src/components/MainNav/MobileMenu/SubMenu/index.tsx +77 -0
- package/src/components/MainNav/MobileMenu/index.tsx +103 -0
- package/src/components/MainNav/Version/index.tsx +33 -0
- package/src/components/MainNav/index.tsx +153 -0
- package/src/components/MarkdownContent/index.tsx +41 -0
- package/src/components/Menu/Action/index.tsx +43 -0
- package/src/components/Menu/Divider/index.tsx +35 -0
- package/src/components/Menu/Dropdown/index.tsx +78 -0
- package/src/components/Menu/Item/index.tsx +36 -0
- package/src/components/Menu/SubMenu/index.tsx +47 -0
- package/src/components/Menu/index.tsx +44 -0
- package/src/components/Modal/Footer/index.tsx +29 -0
- package/src/components/Modal/Header/index.tsx +33 -0
- package/src/components/Modal/index.tsx +124 -0
- package/src/components/Note/Layout/index.tsx +139 -0
- package/src/components/Note/Types/checks.tsx +7 -0
- package/src/components/Note/Types/default.tsx +7 -0
- package/src/components/Note/Types/error.tsx +7 -0
- package/src/components/Note/Types/soon.tsx +7 -0
- package/src/components/Note/Types/sucess.tsx +7 -0
- package/src/components/Note/Types/warning.tsx +7 -0
- package/src/components/Note/index.tsx +32 -0
- package/src/components/Notices/DeprecatedNotice/index.tsx +33 -0
- package/src/components/Notices/ExpandableNotice/index.tsx +36 -0
- package/src/components/Notices/FeatureFlagNotice/index.tsx +36 -0
- package/src/components/Notices/VersionNotice/index.tsx +37 -0
- package/src/components/Notification/Item/Layout/Default/index.tsx +89 -0
- package/src/components/Notification/Item/index.tsx +88 -0
- package/src/components/Notification/index.tsx +65 -0
- package/src/components/Pagination/Card/index.tsx +80 -0
- package/src/components/Pagination/index.tsx +35 -0
- package/src/components/Prerequisites/Item/index.tsx +43 -0
- package/src/components/Prerequisites/index.tsx +94 -0
- package/src/components/RadioItem/index.tsx +38 -0
- package/src/components/Rating/index.tsx +133 -0
- package/src/components/RootProviders/index.tsx +31 -0
- package/src/components/Select/Badge/index.tsx +122 -0
- package/src/components/Select/Dropdown/index.tsx +188 -0
- package/src/components/Select/Input/index.tsx +123 -0
- package/src/components/Select/index.ts +13 -0
- package/src/components/Sidebar/Child/index.tsx +43 -0
- package/src/components/Sidebar/Item/Category/index.tsx +151 -0
- package/src/components/Sidebar/Item/Link/index.tsx +174 -0
- package/src/components/Sidebar/Item/Sidebar/index.tsx +67 -0
- package/src/components/Sidebar/Item/SubCategory/index.tsx +83 -0
- package/src/components/Sidebar/Item/index.tsx +41 -0
- package/src/components/Sidebar/Top/MobileClose/index.tsx +21 -0
- package/src/components/Sidebar/Top/index.tsx +33 -0
- package/src/components/Sidebar/index.tsx +153 -0
- package/src/components/SourceCodeLink/index.tsx +37 -0
- package/src/components/SplitLists/index.tsx +58 -0
- package/src/components/Table/index.tsx +87 -0
- package/src/components/Tabs/index.tsx +106 -0
- package/src/components/TextArea/index.tsx +30 -0
- package/src/components/ThemeImage/index.tsx +26 -0
- package/src/components/Toggle/index.tsx +28 -0
- package/src/components/Tooltip/index.tsx +65 -0
- package/src/components/TypeList/Items/index.tsx +337 -0
- package/src/components/TypeList/index.tsx +63 -0
- package/src/components/WideSection/index.tsx +25 -0
- package/src/components/ZoomImg/index.tsx +17 -0
- package/src/components/index.ts +75 -0
- package/src/constants.tsx +261 -0
- package/src/global-config.ts +11 -0
- package/src/hooks/index.ts +14 -0
- package/src/hooks/use-active-on-scroll/index.tsx +223 -0
- package/src/hooks/use-click-outside/index.tsx +37 -0
- package/src/hooks/use-collapsible/index.tsx +128 -0
- package/src/hooks/use-collapsible-code-lines/index.tsx +149 -0
- package/src/hooks/use-copy/index.tsx +28 -0
- package/src/hooks/use-heading-url/index.tsx +32 -0
- package/src/hooks/use-is-external-link/index.tsx +19 -0
- package/src/hooks/use-keyboard-shortcut/index.tsx +71 -0
- package/src/hooks/use-mutation-observer/index.ts +32 -0
- package/src/hooks/use-page-scroll-manager/index.tsx +82 -0
- package/src/hooks/use-resize-observer/index.ts +20 -0
- package/src/hooks/use-scroll-utils/index.tsx +372 -0
- package/src/hooks/use-select/index.tsx +99 -0
- package/src/hooks/use-tabs/index.tsx +94 -0
- package/src/index.ts +8 -0
- package/src/layouts/barebone.tsx +18 -0
- package/src/layouts/index.ts +4 -0
- package/src/layouts/main-content.tsx +86 -0
- package/src/layouts/root.tsx +43 -0
- package/src/layouts/tight.tsx +29 -0
- package/src/layouts/wide.tsx +25 -0
- package/src/providers/AiAssistant/index.tsx +65 -0
- package/src/providers/BrowserProvider/index.tsx +40 -0
- package/src/providers/ColorMode/index.tsx +73 -0
- package/src/providers/Layout/index.tsx +52 -0
- package/src/providers/MainNav/index.tsx +134 -0
- package/src/providers/Mobile/index.tsx +62 -0
- package/src/providers/Modal/index.tsx +52 -0
- package/src/providers/Notification/index.tsx +149 -0
- package/src/providers/Pagination/index.tsx +230 -0
- package/src/providers/Search/index.tsx +91 -0
- package/src/providers/Sidebar/index.tsx +745 -0
- package/src/providers/SiteConfig/index.tsx +70 -0
- package/src/providers/index.ts +13 -0
- package/src/types/config.ts +34 -0
- package/src/types/frontmatter.ts +23 -0
- package/src/types/general.ts +1 -0
- package/src/types/index.ts +9 -0
- package/src/types/menu.ts +40 -0
- package/src/types/navigation-dropdown.ts +16 -0
- package/src/types/navigation.ts +21 -0
- package/src/types/sidebar.ts +109 -0
- package/src/types/toc.ts +19 -0
- package/src/types/ui.ts +9 -0
- package/src/utils/array-same-elms.ts +10 -0
- package/src/utils/capitalize.ts +3 -0
- package/src/utils/check-sidebar-item-visibility.ts +47 -0
- package/src/utils/decode-str.ts +8 -0
- package/src/utils/dom-utils.ts +29 -0
- package/src/utils/event-parser.ts +54 -0
- package/src/utils/get-link-with-base-path.ts +3 -0
- package/src/utils/get-navbar-items.ts +55 -0
- package/src/utils/get-scrolled-top.ts +8 -0
- package/src/utils/index.ts +13 -0
- package/src/utils/is-elm-window.ts +3 -0
- package/src/utils/is-in-view.ts +10 -0
- package/src/utils/os-browser-utils.ts +39 -0
- package/src/utils/set-obj-value.ts +38 -0
- package/src/utils/sidebar-utils.ts +129 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
|
|
2
|
+
import clsx from "clsx"
|
|
3
|
+
import React from "react"
|
|
4
|
+
import { Link } from "../../../components/Link"
|
|
5
|
+
import { Tooltip } from "../../../components/Tooltip"
|
|
6
|
+
import { ExclamationCircle, PlaySolid } from "@acmekit/icons"
|
|
7
|
+
import { GITHUB_ISSUES_LINK } from "../../../constants"
|
|
8
|
+
import { CodeBlockCopyAction } from "./Copy"
|
|
9
|
+
import { CodeBlockAskAiAction } from "./AskAi"
|
|
10
|
+
|
|
11
|
+
export type CodeBlockActionsProps = {
|
|
12
|
+
source: string
|
|
13
|
+
isSingleLine?: boolean
|
|
14
|
+
inHeader: boolean
|
|
15
|
+
showGradientBg?: boolean
|
|
16
|
+
inInnerCode?: boolean
|
|
17
|
+
isCollapsed: boolean
|
|
18
|
+
canShowApiTesting?: boolean
|
|
19
|
+
onApiTesting?: React.Dispatch<React.SetStateAction<boolean>>
|
|
20
|
+
noReport?: boolean
|
|
21
|
+
noCopy?: boolean
|
|
22
|
+
noAskAi?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const CodeBlockActions = ({
|
|
26
|
+
source,
|
|
27
|
+
inHeader,
|
|
28
|
+
showGradientBg = true,
|
|
29
|
+
inInnerCode = false,
|
|
30
|
+
isCollapsed,
|
|
31
|
+
isSingleLine = false,
|
|
32
|
+
canShowApiTesting = false,
|
|
33
|
+
onApiTesting,
|
|
34
|
+
noReport = false,
|
|
35
|
+
noCopy = false,
|
|
36
|
+
noAskAi = false,
|
|
37
|
+
}: CodeBlockActionsProps) => {
|
|
38
|
+
const iconClassName = [
|
|
39
|
+
"text-acmekit-contrast-fg-secondary",
|
|
40
|
+
"group-hover:text-acmekit-contrast-fg-primary",
|
|
41
|
+
"group-focus:text-acmekit-contrast-fg-primary",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div
|
|
46
|
+
className={clsx(
|
|
47
|
+
"hidden md:block",
|
|
48
|
+
!inHeader &&
|
|
49
|
+
"xs:rounded xs:absolute xs:right-0 xs:top-0 xs:w-[calc(17%+10px)] xs:h-full"
|
|
50
|
+
)}
|
|
51
|
+
>
|
|
52
|
+
{!inHeader && (
|
|
53
|
+
<div
|
|
54
|
+
className={clsx(
|
|
55
|
+
!inHeader &&
|
|
56
|
+
showGradientBg && [
|
|
57
|
+
inInnerCode &&
|
|
58
|
+
"xs:bg-subtle-code-fade-right-to-left dark:xs:bg-subtle-code-fade-right-to-left-dark",
|
|
59
|
+
!inInnerCode &&
|
|
60
|
+
"xs:bg-base-code-fade-right-to-left dark:xs:bg-base-code-fade-right-to-left-dark",
|
|
61
|
+
],
|
|
62
|
+
(inHeader || !showGradientBg) && "xs:bg-transparent",
|
|
63
|
+
"z-[9] w-full h-full absolute top-0 left-0"
|
|
64
|
+
)}
|
|
65
|
+
/>
|
|
66
|
+
)}
|
|
67
|
+
<div
|
|
68
|
+
className={clsx(
|
|
69
|
+
"md:flex md:justify-end md:gap-docs_0.25 relative",
|
|
70
|
+
!inHeader && [
|
|
71
|
+
"md:pr-docs_0.5 z-[11]",
|
|
72
|
+
isCollapsed && "md:pt-docs_2.5",
|
|
73
|
+
!isCollapsed && [
|
|
74
|
+
isSingleLine && "md:pt-docs_0.25",
|
|
75
|
+
!isSingleLine && "md:pt-docs_0.5",
|
|
76
|
+
],
|
|
77
|
+
]
|
|
78
|
+
)}
|
|
79
|
+
>
|
|
80
|
+
{!noAskAi && (
|
|
81
|
+
<CodeBlockAskAiAction source={source} inHeader={inHeader} />
|
|
82
|
+
)}
|
|
83
|
+
{canShowApiTesting && (
|
|
84
|
+
<Tooltip
|
|
85
|
+
text="Test API"
|
|
86
|
+
tooltipClassName="font-base"
|
|
87
|
+
className={clsx("group")}
|
|
88
|
+
innerClassName={clsx(
|
|
89
|
+
inHeader && "flex",
|
|
90
|
+
"h-fit rounded-docs_sm",
|
|
91
|
+
"group-hover:bg-acmekit-contrast-bg-base-hover group-focus:bg-acmekit-contrast-bg-base-hover"
|
|
92
|
+
)}
|
|
93
|
+
>
|
|
94
|
+
<span
|
|
95
|
+
className={clsx(
|
|
96
|
+
!inHeader && "p-[6px]",
|
|
97
|
+
inHeader && "p-[4.5px]",
|
|
98
|
+
"cursor-pointer"
|
|
99
|
+
)}
|
|
100
|
+
onClick={() => onApiTesting?.(true)}
|
|
101
|
+
>
|
|
102
|
+
<PlaySolid className={clsx(iconClassName)} />
|
|
103
|
+
</span>
|
|
104
|
+
</Tooltip>
|
|
105
|
+
)}
|
|
106
|
+
{!noReport && (
|
|
107
|
+
<Tooltip
|
|
108
|
+
text="Report Issue"
|
|
109
|
+
tooltipClassName="font-base"
|
|
110
|
+
className={clsx("group")}
|
|
111
|
+
innerClassName={clsx(
|
|
112
|
+
inHeader && "flex",
|
|
113
|
+
"h-fit rounded-docs_sm",
|
|
114
|
+
"group-hover:bg-acmekit-contrast-bg-base-hover group-focus:bg-acmekit-contrast-bg-base-hover"
|
|
115
|
+
)}
|
|
116
|
+
>
|
|
117
|
+
<Link
|
|
118
|
+
href={GITHUB_ISSUES_LINK}
|
|
119
|
+
target="_blank"
|
|
120
|
+
className={clsx(
|
|
121
|
+
"bg-transparent border-none cursor-pointer rounded",
|
|
122
|
+
"[&:not(:first-child)]:ml-docs_0.5",
|
|
123
|
+
"inline-flex justify-center items-center invisible xs:visible",
|
|
124
|
+
!inHeader && "p-[6px]",
|
|
125
|
+
inHeader && "p-[4.5px]"
|
|
126
|
+
)}
|
|
127
|
+
rel="noreferrer"
|
|
128
|
+
>
|
|
129
|
+
<ExclamationCircle className={clsx(iconClassName)} />
|
|
130
|
+
</Link>
|
|
131
|
+
</Tooltip>
|
|
132
|
+
)}
|
|
133
|
+
{!noCopy && <CodeBlockCopyAction source={source} inHeader={inHeader} />}
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
)
|
|
137
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
|
|
2
|
+
import clsx from "clsx"
|
|
3
|
+
import React from "react"
|
|
4
|
+
import { CollapsibleReturn } from "../../../../hooks/use-collapsible"
|
|
5
|
+
import { Button } from "@acmekit/ui"
|
|
6
|
+
|
|
7
|
+
export type CodeBlockCollapsibleButtonProps = {
|
|
8
|
+
type: "start" | "end"
|
|
9
|
+
expandButtonLabel?: string
|
|
10
|
+
className?: string
|
|
11
|
+
} & Omit<CollapsibleReturn, "getCollapsibleElms">
|
|
12
|
+
|
|
13
|
+
export const CodeBlockCollapsibleButton = ({
|
|
14
|
+
type,
|
|
15
|
+
expandButtonLabel = "Show more",
|
|
16
|
+
collapsed,
|
|
17
|
+
setCollapsed,
|
|
18
|
+
className,
|
|
19
|
+
}: CodeBlockCollapsibleButtonProps) => {
|
|
20
|
+
if (!collapsed) {
|
|
21
|
+
return <></>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
{type === "start" && (
|
|
27
|
+
<Button
|
|
28
|
+
className={clsx(
|
|
29
|
+
"font-base w-full !p-docs_0.5 !shadow-none z-10",
|
|
30
|
+
"bg-acmekit-contrast-button hover:bg-acmekit-contrast-button-hover",
|
|
31
|
+
"txt-compact-xsmall text-acmekit-contrast-fg-secondary",
|
|
32
|
+
type === "start" && "rounded-t-docs_DEFAULT rounded-b-none",
|
|
33
|
+
className
|
|
34
|
+
)}
|
|
35
|
+
data-testid="collapsible-button-start"
|
|
36
|
+
onClick={() => setCollapsed(false)}
|
|
37
|
+
>
|
|
38
|
+
{expandButtonLabel}
|
|
39
|
+
</Button>
|
|
40
|
+
)}
|
|
41
|
+
{type === "end" && (
|
|
42
|
+
<Button
|
|
43
|
+
className={clsx(
|
|
44
|
+
"font-base w-full !p-docs_0.5 !shadow-none z-10",
|
|
45
|
+
"bg-acmekit-contrast-button hover:bg-acmekit-contrast-button-hover",
|
|
46
|
+
"txt-compact-xsmall text-acmekit-contrast-fg-secondary",
|
|
47
|
+
"rounded-t-none rounded-b-docs_DEFAULT",
|
|
48
|
+
className
|
|
49
|
+
)}
|
|
50
|
+
data-testid="collapsible-button-end"
|
|
51
|
+
onClick={() => setCollapsed(false)}
|
|
52
|
+
>
|
|
53
|
+
{expandButtonLabel}
|
|
54
|
+
</Button>
|
|
55
|
+
)}
|
|
56
|
+
</>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import clsx from "clsx"
|
|
2
|
+
import React from "react"
|
|
3
|
+
import { CollapsibleReturn } from "../../../../hooks/use-collapsible"
|
|
4
|
+
|
|
5
|
+
export type CodeBlockCollapsibleFadeProps = {
|
|
6
|
+
type: "start" | "end"
|
|
7
|
+
hasHeader?: boolean
|
|
8
|
+
} & Pick<CollapsibleReturn, "collapsed">
|
|
9
|
+
|
|
10
|
+
export const CodeBlockCollapsibleFade = ({
|
|
11
|
+
type,
|
|
12
|
+
hasHeader = false,
|
|
13
|
+
collapsed,
|
|
14
|
+
}: CodeBlockCollapsibleFadeProps) => {
|
|
15
|
+
if (!collapsed) {
|
|
16
|
+
return <></>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<span
|
|
21
|
+
className={clsx(
|
|
22
|
+
"absolute flex flex-col z-10",
|
|
23
|
+
hasHeader && "left-[6px] w-[calc(100%-12px)]",
|
|
24
|
+
!hasHeader && "w-full left-0",
|
|
25
|
+
type === "start" && [
|
|
26
|
+
hasHeader && "top-[44px]",
|
|
27
|
+
!hasHeader && "top-[36px]",
|
|
28
|
+
],
|
|
29
|
+
type === "end" && [
|
|
30
|
+
hasHeader && "bottom-[44px]",
|
|
31
|
+
!hasHeader && "bottom-[36px]",
|
|
32
|
+
]
|
|
33
|
+
)}
|
|
34
|
+
>
|
|
35
|
+
{type === "end" && (
|
|
36
|
+
<span
|
|
37
|
+
className={clsx(
|
|
38
|
+
"w-full h-[56px]",
|
|
39
|
+
"bg-code-fade-bottom-to-top dark:bg-code-fade-bottom-to-top-dark"
|
|
40
|
+
)}
|
|
41
|
+
data-testid="collapsible-fade-end"
|
|
42
|
+
/>
|
|
43
|
+
)}
|
|
44
|
+
{type === "start" && (
|
|
45
|
+
<span
|
|
46
|
+
className={clsx(
|
|
47
|
+
"w-full h-[56px]",
|
|
48
|
+
"bg-code-fade-top-to-bottom dark:bg-code-fade-top-to-bottom-dark"
|
|
49
|
+
)}
|
|
50
|
+
data-testid="collapsible-fade-start"
|
|
51
|
+
/>
|
|
52
|
+
)}
|
|
53
|
+
</span>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { CollapsibleReturn } from "../../../../hooks/use-collapsible"
|
|
3
|
+
|
|
4
|
+
export type CodeBlockCollapsibleLinesProps = {
|
|
5
|
+
children: React.ReactNode
|
|
6
|
+
type: "start" | "end"
|
|
7
|
+
} & Pick<CollapsibleReturn, "collapsed">
|
|
8
|
+
|
|
9
|
+
export const CodeBlockCollapsibleLines = ({
|
|
10
|
+
children,
|
|
11
|
+
type,
|
|
12
|
+
collapsed,
|
|
13
|
+
}: CodeBlockCollapsibleLinesProps) => {
|
|
14
|
+
const isStart = type === "start"
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
{collapsed && Array.isArray(children)
|
|
18
|
+
? children.slice(isStart ? -2 : 0, isStart ? undefined : 2)
|
|
19
|
+
: children}
|
|
20
|
+
</>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import clsx from "clsx"
|
|
2
|
+
import React, { useMemo } from "react"
|
|
3
|
+
import { useColorMode } from "../../../../providers/ColorMode"
|
|
4
|
+
import { CodeBlockStyle } from "../../../CodeBlock"
|
|
5
|
+
|
|
6
|
+
export type CodeBlockHeaderWrapperProps = {
|
|
7
|
+
blockStyle?: CodeBlockStyle
|
|
8
|
+
children: React.ReactNode
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const CodeBlockHeaderWrapper = React.forwardRef<
|
|
12
|
+
HTMLDivElement,
|
|
13
|
+
CodeBlockHeaderWrapperProps
|
|
14
|
+
>(function CodeBlockHeaderWrapper({ children, blockStyle = "loud" }, ref) {
|
|
15
|
+
const { colorMode } = useColorMode()
|
|
16
|
+
|
|
17
|
+
const bgColor = useMemo(
|
|
18
|
+
() =>
|
|
19
|
+
clsx(
|
|
20
|
+
blockStyle === "loud" && "bg-acmekit-contrast-bg-base",
|
|
21
|
+
blockStyle === "subtle" && [
|
|
22
|
+
colorMode === "light" && "bg-acmekit-bg-component",
|
|
23
|
+
colorMode === "dark" && "bg-acmekit-code-bg-header",
|
|
24
|
+
]
|
|
25
|
+
),
|
|
26
|
+
[blockStyle, colorMode]
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
className={clsx(
|
|
32
|
+
"py-docs_0.5 px-docs_1 mb-0",
|
|
33
|
+
"rounded-t-docs_lg relative flex justify-between items-center",
|
|
34
|
+
blockStyle === "subtle" && [
|
|
35
|
+
"border border-solid border-b-0",
|
|
36
|
+
colorMode === "light" && "border-acmekit-border-base",
|
|
37
|
+
colorMode === "dark" && "border-acmekit-code-border",
|
|
38
|
+
],
|
|
39
|
+
bgColor
|
|
40
|
+
)}
|
|
41
|
+
ref={ref}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
</div>
|
|
45
|
+
)
|
|
46
|
+
})
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useMemo } from "react"
|
|
3
|
+
import clsx from "clsx"
|
|
4
|
+
import { CodeBlockStyle } from "../../CodeBlock"
|
|
5
|
+
import { useColorMode } from "../../../providers/ColorMode"
|
|
6
|
+
import { Badge, BadgeVariant } from "../../../components/Badge"
|
|
7
|
+
import { CodeBlockActions, CodeBlockActionsProps } from "../Actions"
|
|
8
|
+
import { CodeBlockHeaderWrapper } from "./Wrapper"
|
|
9
|
+
|
|
10
|
+
export type CodeBlockHeaderMeta = {
|
|
11
|
+
badgeLabel?: string
|
|
12
|
+
badgeColor?: BadgeVariant
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type CodeBlockHeaderProps = {
|
|
16
|
+
title?: string
|
|
17
|
+
blockStyle?: CodeBlockStyle
|
|
18
|
+
actionsProps: CodeBlockActionsProps
|
|
19
|
+
hideActions?: boolean
|
|
20
|
+
} & CodeBlockHeaderMeta
|
|
21
|
+
|
|
22
|
+
export const CodeBlockHeader = ({
|
|
23
|
+
title,
|
|
24
|
+
blockStyle = "loud",
|
|
25
|
+
badgeLabel,
|
|
26
|
+
actionsProps,
|
|
27
|
+
badgeColor,
|
|
28
|
+
hideActions = false,
|
|
29
|
+
}: CodeBlockHeaderProps) => {
|
|
30
|
+
const { colorMode } = useColorMode()
|
|
31
|
+
|
|
32
|
+
const titleColor = useMemo(
|
|
33
|
+
() =>
|
|
34
|
+
clsx(
|
|
35
|
+
blockStyle === "loud" && "text-acmekit-contrast-fg-secondary",
|
|
36
|
+
blockStyle === "subtle" && [
|
|
37
|
+
colorMode === "light" && "text-acmekit-fg-subtle",
|
|
38
|
+
colorMode === "dark" && "text-acmekit-contrast-fg-secondary",
|
|
39
|
+
]
|
|
40
|
+
),
|
|
41
|
+
[blockStyle, colorMode]
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<CodeBlockHeaderWrapper blockStyle={blockStyle}>
|
|
46
|
+
<div
|
|
47
|
+
className={clsx("flex-1", "flex gap-docs_0.75 items-start")}
|
|
48
|
+
data-testid="code-block-header"
|
|
49
|
+
>
|
|
50
|
+
{badgeLabel && (
|
|
51
|
+
<Badge variant={badgeColor || "code"} className="font-base">
|
|
52
|
+
{badgeLabel}
|
|
53
|
+
</Badge>
|
|
54
|
+
)}
|
|
55
|
+
{title && (
|
|
56
|
+
<div
|
|
57
|
+
className={clsx("text-compact-x-small font-base", titleColor)}
|
|
58
|
+
data-testid="code-block-header-title"
|
|
59
|
+
>
|
|
60
|
+
{title}
|
|
61
|
+
</div>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
{!hideActions && <CodeBlockActions {...actionsProps} />}
|
|
65
|
+
</CodeBlockHeaderWrapper>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import clsx from "clsx"
|
|
3
|
+
import { CodeBlockProps } from "../../.."
|
|
4
|
+
|
|
5
|
+
export const CodeBlockInline = ({ source }: CodeBlockProps) => {
|
|
6
|
+
return (
|
|
7
|
+
<pre
|
|
8
|
+
className={clsx(
|
|
9
|
+
"px-[6px] bg-acmekit-tag-neutral-bg",
|
|
10
|
+
"w-full my-docs_0.5 rounded-docs_sm",
|
|
11
|
+
"border border-acmekit-tag-neutral-border",
|
|
12
|
+
"whitespace-pre-wrap"
|
|
13
|
+
)}
|
|
14
|
+
>
|
|
15
|
+
<code className="w-full text-code-label text-acmekit-tag-neutral-text">
|
|
16
|
+
{source}
|
|
17
|
+
</code>
|
|
18
|
+
</pre>
|
|
19
|
+
)
|
|
20
|
+
}
|