docusaurus-theme-openapi-docs 0.0.0-beta.644 → 0.0.0-beta.645

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/lib/theme/ApiDemoPanel/ApiCodeBlock/Container/_Container.scss +6 -0
  2. package/lib/theme/ApiDemoPanel/ApiCodeBlock/Container/index.js +29 -0
  3. package/lib/theme/ApiDemoPanel/ApiCodeBlock/Content/Element.js +30 -0
  4. package/lib/theme/ApiDemoPanel/ApiCodeBlock/Content/String.js +131 -0
  5. package/lib/theme/ApiDemoPanel/ApiCodeBlock/Content/_Content.scss +88 -0
  6. package/lib/theme/ApiDemoPanel/ApiCodeBlock/CopyButton/_CopyButton.scss +44 -0
  7. package/lib/theme/ApiDemoPanel/ApiCodeBlock/CopyButton/index.js +74 -0
  8. package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExitButton/_ExitButton.scss +16 -0
  9. package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExitButton/index.js +47 -0
  10. package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/_ExpandButton.scss +42 -0
  11. package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js +180 -0
  12. package/lib/theme/ApiDemoPanel/ApiCodeBlock/Line/_Line.scss +46 -0
  13. package/lib/theme/ApiDemoPanel/ApiCodeBlock/Line/index.js +47 -0
  14. package/lib/theme/ApiDemoPanel/ApiCodeBlock/WordWrapButton/_WordWrapButton.scss +10 -0
  15. package/lib/theme/ApiDemoPanel/ApiCodeBlock/WordWrapButton/index.js +44 -0
  16. package/lib/theme/ApiDemoPanel/ApiCodeBlock/index.js +40 -0
  17. package/lib/theme/ApiDemoPanel/CodeTabs/_CodeTabs.scss +19 -1
  18. package/lib/theme/ApiDemoPanel/CodeTabs/index.js +1 -1
  19. package/lib/theme/ApiDemoPanel/Curl/index.js +5 -2
  20. package/lib/theme/ParamsItem/index.js +1 -1
  21. package/lib/theme/SchemaItem/index.js +1 -1
  22. package/lib/theme/styles.scss +10 -0
  23. package/package.json +5 -3
  24. package/src/theme/ApiDemoPanel/ApiCodeBlock/Container/_Container.scss +6 -0
  25. package/src/theme/ApiDemoPanel/ApiCodeBlock/Container/index.js +29 -0
  26. package/src/theme/ApiDemoPanel/ApiCodeBlock/Content/Element.js +30 -0
  27. package/src/theme/ApiDemoPanel/ApiCodeBlock/Content/String.js +131 -0
  28. package/src/theme/ApiDemoPanel/ApiCodeBlock/Content/_Content.scss +88 -0
  29. package/src/theme/ApiDemoPanel/ApiCodeBlock/CopyButton/_CopyButton.scss +44 -0
  30. package/src/theme/ApiDemoPanel/ApiCodeBlock/CopyButton/index.js +74 -0
  31. package/src/theme/ApiDemoPanel/ApiCodeBlock/ExitButton/_ExitButton.scss +16 -0
  32. package/src/theme/ApiDemoPanel/ApiCodeBlock/ExitButton/index.js +47 -0
  33. package/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/_ExpandButton.scss +42 -0
  34. package/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js +180 -0
  35. package/src/theme/ApiDemoPanel/ApiCodeBlock/Line/_Line.scss +46 -0
  36. package/src/theme/ApiDemoPanel/ApiCodeBlock/Line/index.js +47 -0
  37. package/src/theme/ApiDemoPanel/ApiCodeBlock/WordWrapButton/_WordWrapButton.scss +10 -0
  38. package/src/theme/ApiDemoPanel/ApiCodeBlock/WordWrapButton/index.js +44 -0
  39. package/src/theme/ApiDemoPanel/ApiCodeBlock/index.js +40 -0
  40. package/src/theme/ApiDemoPanel/CodeTabs/_CodeTabs.scss +19 -1
  41. package/src/theme/ApiDemoPanel/CodeTabs/index.js +1 -1
  42. package/src/theme/ApiDemoPanel/Curl/index.tsx +5 -3
  43. package/src/theme/ParamsItem/index.js +1 -1
  44. package/src/theme/SchemaItem/index.js +1 -1
  45. package/src/theme/styles.scss +10 -0
  46. package/src/theme-openapi.d.ts +4 -0
@@ -0,0 +1,46 @@
1
+ /* Intentionally has zero specificity, so that to be able to override
2
+ the background in custom CSS file due bug https://github.com/facebook/docusaurus/issues/3678 */
3
+ :where(:root) {
4
+ --docusaurus-highlighted-code-line-bg: rgb(72 77 91);
5
+ }
6
+
7
+ :where([data-theme="dark"]) {
8
+ --docusaurus-highlighted-code-line-bg: rgb(100 100 100);
9
+ }
10
+
11
+ .theme-code-block-highlighted-line {
12
+ background-color: var(--docusaurus-highlighted-code-line-bg);
13
+ display: block;
14
+ margin: 0 calc(-1 * var(--ifm-pre-padding));
15
+ padding: 0 var(--ifm-pre-padding);
16
+ }
17
+
18
+ .openapi-demo__code-block-code-line {
19
+ display: table-row;
20
+ counter-increment: line-count;
21
+ }
22
+
23
+ .openapi-demo__code-block-code-line-number {
24
+ display: table-cell;
25
+ text-align: right;
26
+ width: 1%;
27
+ position: sticky;
28
+ left: 0;
29
+ padding: 0 var(--ifm-pre-padding);
30
+ background: var(--ifm-pre-background);
31
+ overflow-wrap: normal;
32
+ }
33
+
34
+ .openapi-demo__code-block-code-line-number::before {
35
+ content: counter(line-count);
36
+ opacity: 0.4;
37
+ }
38
+
39
+ :global(.theme-code-block-highlighted-line)
40
+ .openapi-demo__code-block-code-line-number::before {
41
+ opacity: 0.8;
42
+ }
43
+
44
+ .openapi-demo__code-block-code-line-number {
45
+ padding-right: var(--ifm-pre-padding);
46
+ }
@@ -0,0 +1,47 @@
1
+ /* ============================================================================
2
+ * Copyright (c) Palo Alto Networks
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ * ========================================================================== */
7
+
8
+ import React from "react";
9
+
10
+ import clsx from "clsx";
11
+
12
+ export default function CodeBlockLine({
13
+ line,
14
+ classNames,
15
+ showLineNumbers,
16
+ getLineProps,
17
+ getTokenProps,
18
+ }) {
19
+ if (line.length === 1 && line[0].content === "\n") {
20
+ line[0].content = "";
21
+ }
22
+ const lineProps = getLineProps({
23
+ line,
24
+ className: clsx(
25
+ classNames,
26
+ showLineNumbers && "openapi-demo__code-block-code-line"
27
+ ),
28
+ });
29
+ const lineTokens = line.map((token, key) => (
30
+ <span key={key} {...getTokenProps({ token, key })} />
31
+ ));
32
+ return (
33
+ <span {...lineProps}>
34
+ {showLineNumbers ? (
35
+ <>
36
+ <span className="openapi-demo__code-block-code-line-number" />
37
+ <span className="openapi-demo__code-block-code-line-content">
38
+ {lineTokens}
39
+ </span>
40
+ </>
41
+ ) : (
42
+ lineTokens
43
+ )}
44
+ <br />
45
+ </span>
46
+ );
47
+ }
@@ -0,0 +1,10 @@
1
+ .openapi-demo__code-block-word-wrap-btn-icon {
2
+ width: 1.2rem;
3
+ height: 1.2rem;
4
+ }
5
+
6
+ .openapi-demo__code-block-word-wrap-btn--enabled {
7
+ .openapi-demo__code-block-word-wrap-btn-icon {
8
+ color: var(--ifm-color-primary);
9
+ }
10
+ }
@@ -0,0 +1,44 @@
1
+ /* ============================================================================
2
+ * Copyright (c) Palo Alto Networks
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ * ========================================================================== */
7
+
8
+ import React from "react";
9
+
10
+ import { translate } from "@docusaurus/Translate";
11
+ import clsx from "clsx";
12
+
13
+ export default function WordWrapButton({ className, onClick, isEnabled }) {
14
+ const title = translate({
15
+ id: "theme.CodeBlock.wordWrapToggle",
16
+ message: "Toggle word wrap",
17
+ description:
18
+ "The title attribute for toggle word wrapping button of code block lines",
19
+ });
20
+ return (
21
+ <button
22
+ type="button"
23
+ onClick={onClick}
24
+ className={clsx(
25
+ "clean-btn",
26
+ className,
27
+ isEnabled && "openapi-demo__code-block-word-wrap-btn--enabled"
28
+ )}
29
+ aria-label={title}
30
+ title={title}
31
+ >
32
+ <svg
33
+ className="openapi-demo__code-block-word-wrap-btn-icon"
34
+ viewBox="0 0 24 24"
35
+ aria-hidden="true"
36
+ >
37
+ <path
38
+ fill="currentColor"
39
+ d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"
40
+ />
41
+ </svg>
42
+ </button>
43
+ );
44
+ }
@@ -0,0 +1,40 @@
1
+ /* ============================================================================
2
+ * Copyright (c) Palo Alto Networks
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ * ========================================================================== */
7
+
8
+ import React, { isValidElement } from "react";
9
+
10
+ import useIsBrowser from "@docusaurus/useIsBrowser";
11
+ import ElementContent from "@theme/ApiDemoPanel/ApiCodeBlock/Content/Element";
12
+ import StringContent from "@theme/ApiDemoPanel/ApiCodeBlock/Content/String";
13
+ /**
14
+ * Best attempt to make the children a plain string so it is copyable. If there
15
+ * are react elements, we will not be able to copy the content, and it will
16
+ * return `children` as-is; otherwise, it concatenates the string children
17
+ * together.
18
+ */
19
+ function maybeStringifyChildren(children) {
20
+ if (React.Children.toArray(children).some((el) => isValidElement(el))) {
21
+ return children;
22
+ }
23
+ // The children is now guaranteed to be one/more plain strings
24
+ return Array.isArray(children) ? children.join("") : children;
25
+ }
26
+ export default function ApiCodeBlock({ children: rawChildren, ...props }) {
27
+ // The Prism theme on SSR is always the default theme but the site theme can
28
+ // be in a different mode. React hydration doesn't update DOM styles that come
29
+ // from SSR. Hence force a re-render after mounting to apply the current
30
+ // relevant styles.
31
+ const isBrowser = useIsBrowser();
32
+ const children = maybeStringifyChildren(rawChildren);
33
+ const CodeBlockComp =
34
+ typeof children === "string" ? StringContent : ElementContent;
35
+ return (
36
+ <CodeBlockComp key={String(isBrowser)} {...props}>
37
+ {children}
38
+ </CodeBlockComp>
39
+ );
40
+ }
@@ -10,6 +10,10 @@
10
10
  --bash-border-radius: 20px;
11
11
  }
12
12
 
13
+ .openapi-tabs__code-container {
14
+ margin-bottom: 1rem;
15
+ }
16
+
13
17
  .openapi-tabs__code-list-container {
14
18
  display: flex;
15
19
  justify-content: flex-start;
@@ -21,7 +25,13 @@
21
25
  }
22
26
 
23
27
  .openapi-demo__code-block code {
24
- max-height: 500px;
28
+ max-height: 200px;
29
+ }
30
+
31
+ body[class="ReactModal__Body--open"] {
32
+ .openapi-demo__code-block code {
33
+ max-height: 600px;
34
+ }
25
35
  }
26
36
 
27
37
  .openapi-tabs__code-item {
@@ -215,3 +225,11 @@
215
225
  justify-content: space-around;
216
226
  }
217
227
  }
228
+
229
+ .ReactModal__Body--open {
230
+ overflow: hidden !important;
231
+ }
232
+
233
+ .openapi-modal--open {
234
+ background-color: rgba(0, 0, 0, 0.7) !important;
235
+ }
@@ -136,7 +136,7 @@ function TabContent({ lazy, children, selectedValue }) {
136
136
  function TabsComponent(props) {
137
137
  const tabs = useTabs(props);
138
138
  return (
139
- <div className="tabs-container">
139
+ <div className="tabs-container openapi-tabs__code-container">
140
140
  <TabList {...props} {...tabs} />
141
141
  <TabContent {...props} {...tabs} />
142
142
  </div>
@@ -63,12 +63,14 @@ const useDocusaurusContext_1 = __importDefault(
63
63
  const postman_code_generators_1 = __importDefault(
64
64
  require("@paloaltonetworks/postman-code-generators")
65
65
  );
66
+ const ApiCodeBlock_1 = __importDefault(
67
+ require("@theme/ApiDemoPanel/ApiCodeBlock")
68
+ );
66
69
  const buildPostmanRequest_1 = __importDefault(
67
70
  require("@theme/ApiDemoPanel/buildPostmanRequest")
68
71
  );
69
72
  const CodeTabs_1 = __importDefault(require("@theme/ApiDemoPanel/CodeTabs"));
70
73
  const hooks_1 = require("@theme/ApiItem/hooks");
71
- const CodeBlock_1 = __importDefault(require("@theme/CodeBlock"));
72
74
  const merge_1 = __importDefault(require("lodash/merge"));
73
75
  exports.languageSet = [
74
76
  {
@@ -319,11 +321,12 @@ function Curl({ postman, codeSamples }) {
319
321
  },
320
322
  },
321
323
  react_1.default.createElement(
322
- CodeBlock_1.default,
324
+ ApiCodeBlock_1.default,
323
325
  {
324
326
  language: lang.highlight,
325
327
  className: "openapi-demo__code-block",
326
328
  title: `${lang.language} / ${lang.variant}`,
329
+ showLineNumbers: true,
327
330
  },
328
331
  codeText
329
332
  )
@@ -123,7 +123,7 @@ function ParamsItem({
123
123
  <span className="openapi-schema__container">
124
124
  <strong>{name}</strong>
125
125
  {renderSchemaName}
126
- {required && <span class="openapi-schema__divider"></span>}
126
+ {required && <span className="openapi-schema__divider"></span>}
127
127
  {renderSchemaRequired}
128
128
  </span>
129
129
  {renderSchema}
@@ -101,7 +101,7 @@ function SchemaItem({
101
101
  </strong>
102
102
  <span className="openapi-schema__name"> {schemaName}</span>
103
103
  {(nullable || required || deprecated) && (
104
- <span class="openapi-schema__divider"></span>
104
+ <span className="openapi-schema__divider"></span>
105
105
  )}
106
106
  {renderNullable}
107
107
  {!deprecated && renderRequired}
@@ -18,6 +18,16 @@
18
18
  @use "./ApiDemoPanel/Request/Request";
19
19
  @use "./ApiDemoPanel/Response/Response";
20
20
  @use "./ApiDemoPanel/Server/Server";
21
+
22
+ /* Api Demo Panel / ApiCodeBlock */
23
+ @use "./ApiDemoPanel/ApiCodeBlock/Container/Container";
24
+ @use "./ApiDemoPanel/ApiCodeBlock/Content/Content";
25
+ @use "./ApiDemoPanel/ApiCodeBlock/CopyButton/CopyButton";
26
+ @use "./ApiDemoPanel/ApiCodeBlock/ExitButton/ExitButton";
27
+ @use "./ApiDemoPanel/ApiCodeBlock/ExpandButton/ExpandButton";
28
+ @use "./ApiDemoPanel/ApiCodeBlock/Line/Line";
29
+ @use "./ApiDemoPanel/ApiCodeBlock/WordWrapButton/WordWrapButton";
30
+
21
31
  /* Schema Styling */
22
32
  @use "./ParamsItem/ParamsItem";
23
33
  @use "./SchemaItem/SchemaItem";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docusaurus-theme-openapi-docs",
3
3
  "description": "OpenAPI theme for Docusaurus.",
4
- "version": "0.0.0-beta.644",
4
+ "version": "0.0.0-beta.645",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -47,13 +47,15 @@
47
47
  "@reduxjs/toolkit": "^1.7.1",
48
48
  "buffer": "^6.0.3",
49
49
  "clsx": "^1.1.1",
50
+ "copy-text-to-clipboard": "^3.1.0",
50
51
  "crypto-js": "^4.1.1",
51
- "docusaurus-plugin-openapi-docs": "0.0.0-beta.644",
52
+ "docusaurus-plugin-openapi-docs": "0.0.0-beta.645",
52
53
  "docusaurus-plugin-sass": "^0.2.3",
53
54
  "file-saver": "^2.0.5",
54
55
  "immer": "^9.0.7",
55
56
  "lodash": "^4.17.20",
56
57
  "node-polyfill-webpack-plugin": "^2.0.1",
58
+ "prism-react-renderer": "^1.3.5",
57
59
  "process": "^0.11.10",
58
60
  "react-live": "^3.1.1",
59
61
  "react-magic-dropzone": "^1.0.1",
@@ -73,5 +75,5 @@
73
75
  "engines": {
74
76
  "node": ">=14"
75
77
  },
76
- "gitHead": "82e67409b8afa0f1d4deaeb77b87b0b5b67e6a9c"
78
+ "gitHead": "66986dbe5010aa8fec65f1425a82ab3ac9357a7d"
77
79
  }
@@ -0,0 +1,6 @@
1
+ .openapi-demo__code-block-container {
2
+ background: var(--prism-background-color);
3
+ color: var(--prism-color);
4
+ margin-bottom: unset;
5
+ box-shadow: var(--ifm-global-shadow-lw);
6
+ }
@@ -0,0 +1,29 @@
1
+ /* ============================================================================
2
+ * Copyright (c) Palo Alto Networks
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ * ========================================================================== */
7
+
8
+ import React from "react";
9
+
10
+ import { ThemeClassNames, usePrismTheme } from "@docusaurus/theme-common";
11
+ import { getPrismCssVariables } from "@docusaurus/theme-common/internal";
12
+ import clsx from "clsx";
13
+
14
+ export default function CodeBlockContainer({ as: As, ...props }) {
15
+ const prismTheme = usePrismTheme();
16
+ const prismCssVariables = getPrismCssVariables(prismTheme);
17
+ return (
18
+ <As
19
+ // Polymorphic components are hard to type, without `oneOf` generics
20
+ {...props}
21
+ style={prismCssVariables}
22
+ className={clsx(
23
+ "openapi-demo__code-block-container",
24
+ props.className,
25
+ ThemeClassNames.common.codeBlock
26
+ )}
27
+ />
28
+ );
29
+ }
@@ -0,0 +1,30 @@
1
+ /* ============================================================================
2
+ * Copyright (c) Palo Alto Networks
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ * ========================================================================== */
7
+
8
+ import React from "react";
9
+
10
+ import Container from "@theme/ApiDemoPanel/ApiCodeBlock/Container";
11
+ import clsx from "clsx";
12
+
13
+ // <pre> tags in markdown map to CodeBlocks. They may contain JSX children. When
14
+ // the children is not a simple string, we just return a styled block without
15
+ // actually highlighting.
16
+ export default function CodeBlockJSX({ children, className }) {
17
+ return (
18
+ <Container
19
+ as="pre"
20
+ tabIndex={0}
21
+ className={clsx(
22
+ "openapi-demo__code-block-standalone",
23
+ "thin-scrollbar",
24
+ className
25
+ )}
26
+ >
27
+ <code className="openapi-demo__code-block-lines">{children}</code>
28
+ </Container>
29
+ );
30
+ }
@@ -0,0 +1,131 @@
1
+ /* ============================================================================
2
+ * Copyright (c) Palo Alto Networks
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ * ========================================================================== */
7
+
8
+ import React from "react";
9
+
10
+ import { useThemeConfig, usePrismTheme } from "@docusaurus/theme-common";
11
+ import {
12
+ parseCodeBlockTitle,
13
+ parseLanguage,
14
+ parseLines,
15
+ containsLineNumbers,
16
+ useCodeWordWrap,
17
+ } from "@docusaurus/theme-common/internal";
18
+ import Container from "@theme/ApiDemoPanel/ApiCodeBlock/Container";
19
+ import CopyButton from "@theme/ApiDemoPanel/ApiCodeBlock/CopyButton";
20
+ import ExpandButton from "@theme/ApiDemoPanel/ApiCodeBlock/ExpandButton";
21
+ import Line from "@theme/ApiDemoPanel/ApiCodeBlock/Line";
22
+ import WordWrapButton from "@theme/ApiDemoPanel/ApiCodeBlock/WordWrapButton";
23
+ import clsx from "clsx";
24
+ import Highlight, { defaultProps } from "prism-react-renderer";
25
+
26
+ export default function CodeBlockString({
27
+ children,
28
+ className: blockClassName = "",
29
+ metastring,
30
+ title: titleProp,
31
+ showLineNumbers: showLineNumbersProp,
32
+ language: languageProp,
33
+ }) {
34
+ const {
35
+ prism: { defaultLanguage, magicComments },
36
+ } = useThemeConfig();
37
+ const language =
38
+ languageProp ?? parseLanguage(blockClassName) ?? defaultLanguage;
39
+ const prismTheme = usePrismTheme();
40
+ const wordWrap = useCodeWordWrap();
41
+ // We still parse the metastring in case we want to support more syntax in the
42
+ // future. Note that MDX doesn't strip quotes when parsing metastring:
43
+ // "title=\"xyz\"" => title: "\"xyz\""
44
+ const title = parseCodeBlockTitle(metastring) || titleProp;
45
+ const { lineClassNames, code } = parseLines(children, {
46
+ metastring,
47
+ language,
48
+ magicComments,
49
+ });
50
+ const showLineNumbers =
51
+ showLineNumbersProp ?? containsLineNumbers(metastring);
52
+
53
+ return (
54
+ <Container
55
+ as="div"
56
+ className={clsx(
57
+ blockClassName,
58
+ language &&
59
+ !blockClassName.includes(`language-${language}`) &&
60
+ `language-${language}`
61
+ )}
62
+ >
63
+ {title && <div className="openapi-demo__code-block-title">{title}</div>}
64
+ <div className="openapi-demo__code-block-content">
65
+ <Highlight
66
+ {...defaultProps}
67
+ theme={prismTheme}
68
+ code={code}
69
+ language={language ?? "text"}
70
+ >
71
+ {({ className, tokens, getLineProps, getTokenProps }) => (
72
+ <pre
73
+ /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
74
+ tabIndex={0}
75
+ ref={wordWrap.codeBlockRef}
76
+ className={clsx(
77
+ className,
78
+ "openapi-demo__code-block",
79
+ "thin-scrollbar"
80
+ )}
81
+ >
82
+ <code
83
+ className={clsx(
84
+ "openapi-demo__code-block-lines",
85
+ showLineNumbers && "openapi-demo__code-block-lines-numbering"
86
+ )}
87
+ >
88
+ {tokens.map((line, i) => (
89
+ <Line
90
+ key={i}
91
+ line={line}
92
+ getLineProps={getLineProps}
93
+ getTokenProps={getTokenProps}
94
+ classNames={lineClassNames[i]}
95
+ showLineNumbers={showLineNumbers}
96
+ />
97
+ ))}
98
+ </code>
99
+ </pre>
100
+ )}
101
+ </Highlight>
102
+ <div className="openapi-demo__code-block-btn-group">
103
+ {(wordWrap.isEnabled || wordWrap.isCodeScrollable) && (
104
+ <WordWrapButton
105
+ className="openapi-demo__code-block-code-btn"
106
+ onClick={() => wordWrap.toggle()}
107
+ isEnabled={wordWrap.isEnabled}
108
+ />
109
+ )}
110
+ <CopyButton
111
+ className="openapi-demo__code-block-code-btn"
112
+ code={code}
113
+ />
114
+ <ExpandButton
115
+ className={clsx(
116
+ "openapi-demo__code-block-code-btn",
117
+ "openapi-demo__expand-btn"
118
+ )}
119
+ code={code}
120
+ language={language}
121
+ showLineNumbers={showLineNumbers}
122
+ blockClassName={blockClassName}
123
+ title={title}
124
+ lineClassNames={lineClassNames}
125
+ wordWrap={wordWrap}
126
+ />
127
+ </div>
128
+ </div>
129
+ </Container>
130
+ );
131
+ }
@@ -0,0 +1,88 @@
1
+ .openapi-demo__code-block-content {
2
+ position: relative;
3
+ /* rtl:ignore */
4
+ direction: ltr;
5
+ border-radius: inherit;
6
+ }
7
+
8
+ .openapi-demo__code-block-title {
9
+ border-bottom: 1px solid var(--ifm-color-emphasis-300);
10
+ font-size: var(--ifm-code-font-size);
11
+ font-weight: 500;
12
+ padding: 0.75rem var(--ifm-pre-padding);
13
+ border-top-left-radius: inherit;
14
+ border-top-right-radius: inherit;
15
+ }
16
+
17
+ .openapi-demo__code-block {
18
+ --ifm-pre-background: var(--prism-background-color);
19
+ margin: 0;
20
+ padding: 0;
21
+ }
22
+
23
+ .openapi-demo__code-block-title
24
+ + .openapi-demo__code-block-content
25
+ .openapi-demo__code-block {
26
+ border-top-left-radius: 0;
27
+ border-top-right-radius: 0;
28
+ }
29
+
30
+ .openapi-demo__code-block-standalone {
31
+ padding: 0;
32
+ }
33
+
34
+ .openapi-demo__code-block-lines {
35
+ font: inherit;
36
+ /* rtl:ignore */
37
+ float: left;
38
+ min-width: 100%;
39
+ padding: var(--ifm-pre-padding);
40
+ }
41
+
42
+ .openapi-demo__code-block-lines-numbering {
43
+ // This causes max-height to unset
44
+ // display: table;
45
+ padding: var(--ifm-pre-padding) 0;
46
+ }
47
+
48
+ @media print {
49
+ .openapi-demo__code-block-lines {
50
+ white-space: pre-wrap;
51
+ }
52
+ }
53
+
54
+ .openapi-demo__code-block-btn-group {
55
+ display: flex;
56
+ column-gap: 0.2rem;
57
+ position: absolute;
58
+ right: calc(var(--ifm-pre-padding) / 2);
59
+ top: calc(var(--ifm-pre-padding) / 2);
60
+ }
61
+
62
+ .openapi-demo__code-block-btn-group button {
63
+ display: flex;
64
+ align-items: center;
65
+ background: var(--prism-background-color);
66
+ color: var(--prism-color);
67
+ border: 1px solid var(--ifm-color-emphasis-300);
68
+ border-radius: var(--ifm-global-radius);
69
+ padding: 0.4rem;
70
+ line-height: 0;
71
+ transition: opacity 200ms ease-in-out;
72
+ opacity: 0;
73
+ }
74
+
75
+ .openapi-demo__code-block-btn-group button:focus-visible,
76
+ .openapi-demo__code-block-btn-group button:hover {
77
+ opacity: 1 !important;
78
+ }
79
+
80
+ .theme-code-block:hover .openapi-demo__code-block-btn-group button {
81
+ opacity: 0.4;
82
+ }
83
+
84
+ @media screen and (max-width: 996px) {
85
+ .openapi-demo__expand-btn {
86
+ display: none !important;
87
+ }
88
+ }
@@ -0,0 +1,44 @@
1
+ .theme-code-block:hover {
2
+ .openapi-demo__code-block-copy-btn--copied {
3
+ opacity: 1 !important;
4
+ }
5
+ }
6
+
7
+ .openapi-demo__code-block-copy-btn-icons {
8
+ position: relative;
9
+ width: 1.125rem;
10
+ height: 1.125rem;
11
+ }
12
+
13
+ .openapi-demo__code-block-copy-btn-icon,
14
+ .openapi-demo__code-block-copy-btn-icon--success {
15
+ position: absolute;
16
+ top: 0;
17
+ left: 0;
18
+ fill: currentColor;
19
+ opacity: inherit;
20
+ width: inherit;
21
+ height: inherit;
22
+ transition: all 0.15s ease;
23
+ }
24
+
25
+ .openapi-demo__code-block-copy-btn-icon--success {
26
+ top: 50%;
27
+ left: 50%;
28
+ transform: translate(-50%, -50%) scale(0.33);
29
+ opacity: 0;
30
+ color: #00d600;
31
+ }
32
+
33
+ .openapi-demo__code-block-copy-btn--copied {
34
+ .openapi-demo__code-block-copy-btn-icon {
35
+ transform: scale(0.33);
36
+ opacity: 0;
37
+ }
38
+
39
+ .openapi-demo__code-block-copy-btn-icon--success {
40
+ transform: translate(-50%, -50%) scale(1);
41
+ opacity: 1;
42
+ transition-delay: 0.075s;
43
+ }
44
+ }