@redocly/theme 0.1.27 → 0.1.28
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/Button/Button.js +3 -3
- package/CodeBlock/CodeBlock.js +1 -1
- package/CopyButton/CopyButton.js +17 -1
- package/Footer/Footer.js +2 -1
- package/Footer/FooterColumn.js +1 -1
- package/Footer/FooterColumns.d.ts +2 -2
- package/Footer/FooterColumns.js +1 -1
- package/JsonViewer/JsonViewer.d.ts +2 -0
- package/JsonViewer/JsonViewer.js +53 -22
- package/Markdown/Admonition.js +1 -1
- package/Markdown/CodeSample/CodeSample.js +17 -1
- package/Markdown/Heading.js +1 -1
- package/Markdown/Mermaid.js +1 -1
- package/Markdown/Sup.d.ts +2 -0
- package/Markdown/Sup.js +19 -0
- package/Markdown/Tabs/Tabs.js +17 -1
- package/Markdown/index.d.ts +4 -3
- package/Markdown/index.js +4 -3
- package/Navbar/MobileNavbarDropdown.d.ts +8 -0
- package/Navbar/MobileNavbarDropdown.js +21 -0
- package/Navbar/MobileNavbarItem.d.ts +15 -0
- package/Navbar/MobileNavbarItem.js +102 -0
- package/Navbar/MobileNavbarMenu.d.ts +6 -0
- package/Navbar/MobileNavbarMenu.js +32 -0
- package/Navbar/MobileNavbarMenuButton.d.ts +4 -0
- package/Navbar/MobileNavbarMenuButton.js +19 -0
- package/Navbar/Navbar.js +26 -4
- package/Navbar/NavbarDropdown.js +1 -1
- package/Navbar/NavbarItem.d.ts +9 -3
- package/Navbar/NavbarItem.js +9 -9
- package/Navbar/NavbarMenu.js +3 -2
- package/PageNavigation/NextPageLink.js +4 -4
- package/PageNavigation/PreviousPageLink.js +4 -4
- package/Panel/PanelComponent.js +18 -2
- package/Search/Autocomplete.js +18 -2
- package/Search/utils.js +17 -1
- package/Sidebar/SidebarLayout.js +17 -1
- package/SourceCode/SourceCode.d.ts +10 -3
- package/SourceCode/SourceCode.js +10 -5
- package/TableOfContent/TableOfContent.js +4 -4
- package/globalStyle.js +2 -2
- package/hooks/useActiveHeading.js +17 -1
- package/hooks/useActiveSectionId.js +17 -1
- package/hooks/useControl.js +17 -1
- package/hooks/useMobileMenu.js +17 -1
- package/hooks/useNavbarHeight.js +17 -1
- package/package.json +1 -1
- package/src/Button/Button.tsx +5 -1
- package/src/CodeBlock/CodeBlock.ts +12 -0
- package/src/Footer/Footer.tsx +4 -3
- package/src/Footer/FooterColumn.tsx +3 -1
- package/src/Footer/FooterColumns.tsx +3 -3
- package/src/JsonViewer/JsonViewer.tsx +55 -40
- package/src/Markdown/Admonition.tsx +1 -1
- package/src/Markdown/Heading.tsx +1 -1
- package/src/Markdown/Mermaid.tsx +1 -1
- package/src/Markdown/Sup.tsx +8 -0
- package/src/Markdown/index.ts +4 -3
- package/src/Navbar/MobileNavbarDropdown.tsx +37 -0
- package/src/Navbar/MobileNavbarItem.tsx +116 -0
- package/src/Navbar/MobileNavbarMenu.tsx +106 -0
- package/src/Navbar/MobileNavbarMenuButton.tsx +13 -0
- package/src/Navbar/Navbar.tsx +11 -3
- package/src/Navbar/NavbarDropdown.tsx +1 -1
- package/src/Navbar/NavbarItem.tsx +9 -8
- package/src/Navbar/NavbarMenu.tsx +9 -4
- package/src/PageNavigation/NextPageLink.tsx +3 -3
- package/src/PageNavigation/PreviousPageLink.tsx +3 -3
- package/src/SourceCode/SourceCode.tsx +32 -5
- package/src/TableOfContent/TableOfContent.tsx +3 -3
- package/src/globalStyle.ts +2 -0
- package/src/types/portal/src/client/app/Sidebar/types.d.ts +2 -1
- package/src/types/portal/src/server/constants.d.ts +2 -0
- package/src/types/portal/src/server/dev-server/types.d.ts +22 -0
- package/src/types/portal/src/server/plugins/markdown/types.d.ts +15 -5
- package/src/types/portal/src/server/plugins/portal-config/get-frontmatter-keys-to-resolve.d.ts +2 -0
- package/src/types/portal/src/server/plugins/portal-config/types.d.ts +6 -2
- package/src/types/portal/src/server/plugins/reference-docs/utils.d.ts +26 -0
- package/src/types/portal/src/server/plugins/types.d.ts +29 -12
- package/src/types/portal/src/server/store.d.ts +16 -16
- package/src/types/portal/src/server/utils/fs.d.ts +2 -1
- package/src/types/portal/src/server/utils/index.d.ts +1 -0
- package/src/types/portal/src/server/utils/paths.d.ts +4 -0
- package/src/types/portal/src/server/utils/rbac.d.ts +15 -0
- package/src/types/portal/src/shared/constants.d.ts +7 -0
- package/src/types/portal/src/shared/models/config.d.ts +24 -12
- package/src/types/portal/src/shared/types.d.ts +17 -4
- package/src/types/portal/src/shared/urls.d.ts +1 -1
- package/src/types/portal/src/shared/utils.d.ts +2 -0
- package/src/ui/Burger.tsx +36 -0
- package/src/ui/Flex.tsx +1 -0
- package/src/utils/args-typecheck.ts +9 -0
- package/src/utils/highlight.ts +11 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/jsonToHtml.ts +171 -59
- package/ui/Burger.d.ts +8 -0
- package/ui/Burger.js +23 -0
- package/ui/Dropdown.js +17 -1
- package/ui/Flex.js +1 -1
- package/ui/UniversalLink.js +17 -1
- package/utils/args-typecheck.d.ts +2 -0
- package/utils/args-typecheck.js +13 -0
- package/utils/highlight.d.ts +1 -0
- package/utils/highlight.js +12 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/jsonToHtml.d.ts +4 -1
- package/utils/jsonToHtml.js +287 -83
- package/utils/media-css.js +40 -3
- package/utils/theme-helpers.js +56 -9
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
2
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
19
|
exports.useActiveHeading = void 0;
|
|
4
20
|
var react_1 = require("react");
|
|
5
21
|
function useActiveHeading(contentElement) {
|
|
6
|
-
var _a = (0, react_1.useState)(undefined), heading = _a[0], setHeading = _a[1];
|
|
22
|
+
var _a = __read((0, react_1.useState)(undefined), 2), heading = _a[0], setHeading = _a[1];
|
|
7
23
|
var headings = (0, react_1.useMemo)(function () { return contentElement && contentElement.querySelectorAll('.heading-anchor'); }, [contentElement]);
|
|
8
24
|
var handler = (0, react_1.useCallback)(
|
|
9
25
|
// throttle(
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
2
18
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
19
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
20
|
};
|
|
@@ -9,7 +25,7 @@ var lodash_throttle_1 = __importDefault(require("lodash.throttle"));
|
|
|
9
25
|
var useNavbarHeight_1 = require("../hooks/useNavbarHeight");
|
|
10
26
|
function useActiveSectionId(location, hasOverviewPage) {
|
|
11
27
|
if (hasOverviewPage === void 0) { hasOverviewPage = false; }
|
|
12
|
-
var _a = (0, react_1.useState)(''), itemId = _a[0], setItemId = _a[1];
|
|
28
|
+
var _a = __read((0, react_1.useState)(''), 2), itemId = _a[0], setItemId = _a[1];
|
|
13
29
|
var navbarHeight = (0, useNavbarHeight_1.useNavbarHeight)(location);
|
|
14
30
|
var scrollListener = (0, react_1.useMemo)(function () {
|
|
15
31
|
return (0, lodash_throttle_1.default)(function () {
|
package/hooks/useControl.js
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
2
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
19
|
exports.useControl = void 0;
|
|
4
20
|
var react_1 = require("react");
|
|
5
21
|
var useControl = function (initialVal) {
|
|
6
22
|
if (initialVal === void 0) { initialVal = false; }
|
|
7
|
-
var _a = (0, react_1.useState)(initialVal), isOpened = _a[0], setIsOpened = _a[1];
|
|
23
|
+
var _a = __read((0, react_1.useState)(initialVal), 2), isOpened = _a[0], setIsOpened = _a[1];
|
|
8
24
|
var handleOpen = (0, react_1.useCallback)(function () { return setIsOpened(true); }, []);
|
|
9
25
|
var handleClose = (0, react_1.useCallback)(function () { return setIsOpened(false); }, []);
|
|
10
26
|
return {
|
package/hooks/useMobileMenu.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
2
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
19
|
exports.useMobileMenu = void 0;
|
|
4
20
|
var react_1 = require("react");
|
|
@@ -6,7 +22,7 @@ var react_router_dom_1 = require("react-router-dom");
|
|
|
6
22
|
function useMobileMenu(initialState) {
|
|
7
23
|
if (initialState === void 0) { initialState = false; }
|
|
8
24
|
var location = (0, react_router_dom_1.useHistory)().location;
|
|
9
|
-
var _a = (0, react_1.useState)(initialState), isOpen = _a[0], setIsOpen = _a[1];
|
|
25
|
+
var _a = __read((0, react_1.useState)(initialState), 2), isOpen = _a[0], setIsOpen = _a[1];
|
|
10
26
|
(0, react_1.useEffect)(function () { return setIsOpen(false); }, [location.pathname]);
|
|
11
27
|
return [isOpen, setIsOpen];
|
|
12
28
|
}
|
package/hooks/useNavbarHeight.js
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
2
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
19
|
exports.useNavbarHeight = void 0;
|
|
4
20
|
var react_1 = require("react");
|
|
5
21
|
var getNavbarElement_1 = require("../utils/getNavbarElement");
|
|
6
22
|
function useNavbarHeight(location) {
|
|
7
|
-
var _a = (0, react_1.useState)(0), height = _a[0], setHeight = _a[1];
|
|
23
|
+
var _a = __read((0, react_1.useState)(0), 2), height = _a[0], setHeight = _a[1];
|
|
8
24
|
(0, react_1.useEffect)(function () {
|
|
9
25
|
var navbar = (0, getNavbarElement_1.getNavbarElement)();
|
|
10
26
|
setHeight((navbar && navbar.clientHeight) || 0);
|
package/package.json
CHANGED
package/src/Button/Button.tsx
CHANGED
|
@@ -48,6 +48,7 @@ export const baseButtonStyles = css`
|
|
|
48
48
|
font-weight: var(--button-font-weight);
|
|
49
49
|
font-size: 14px;
|
|
50
50
|
padding: 2px 20px;
|
|
51
|
+
margin: var(--button-margin);
|
|
51
52
|
cursor: pointer;
|
|
52
53
|
transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
|
|
53
54
|
line-height: 1;
|
|
@@ -92,12 +93,15 @@ const StyledButton = styled.button.attrs(({ color = 'default', extraClass }: But
|
|
|
92
93
|
`
|
|
93
94
|
: css`
|
|
94
95
|
color: var(--button-color);
|
|
96
|
+
border: 2px solid var(--button-background-color);
|
|
95
97
|
background-color: var(--button-background-color);
|
|
96
98
|
&:hover {
|
|
99
|
+
border: 2px solid var(--button-hover-background-color);
|
|
97
100
|
background-color: var(--button-hover-background-color);
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
&:active {
|
|
104
|
+
border: 2px solid var(--button-active-background-color);
|
|
101
105
|
background-color: var(--button-active-background-color);
|
|
102
106
|
}
|
|
103
107
|
`};
|
|
@@ -121,7 +125,7 @@ const StyledButton = styled.button.attrs(({ color = 'default', extraClass }: But
|
|
|
121
125
|
&,
|
|
122
126
|
&:hover {
|
|
123
127
|
cursor: default;
|
|
124
|
-
color: #
|
|
128
|
+
color: #999;
|
|
125
129
|
pointer-events: none;
|
|
126
130
|
}
|
|
127
131
|
`}
|
|
@@ -84,5 +84,17 @@ export const CodeBlock = styled.div.attrs(() => ({
|
|
|
84
84
|
cursor: help;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
.code-line {
|
|
88
|
+
&:before {
|
|
89
|
+
content: attr(data-line-number);
|
|
90
|
+
display: inline-block;
|
|
91
|
+
min-width: 2em;
|
|
92
|
+
padding-right: 0.8em;
|
|
93
|
+
text-align: right;
|
|
94
|
+
pointer-events: none;
|
|
95
|
+
user-select: none;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
87
99
|
${generateCodeBlockTokens()}
|
|
88
100
|
`;
|
package/src/Footer/Footer.tsx
CHANGED
|
@@ -3,9 +3,10 @@ import styled from 'styled-components';
|
|
|
3
3
|
|
|
4
4
|
import { FooterColumns } from '@theme/Footer/FooterColumns';
|
|
5
5
|
import { FooterCopyright } from '@theme/Footer/FooterCopyright';
|
|
6
|
-
import type { NavGroupRecord } from '@theme/types/portal';
|
|
6
|
+
import type { NavGroupRecord, ResolvedNavItem } from '@theme/types/portal';
|
|
7
7
|
import { useThemeSettings } from '@portal/hooks';
|
|
8
8
|
import { DEFAULT_THEME_NAME } from '@portal/constants';
|
|
9
|
+
import { isEmptyArray } from '@theme/utils';
|
|
9
10
|
|
|
10
11
|
interface FooterProps {
|
|
11
12
|
data: NavGroupRecord;
|
|
@@ -14,13 +15,13 @@ interface FooterProps {
|
|
|
14
15
|
export function Footer({ data: { columns, copyrightText } }: FooterProps): JSX.Element | null {
|
|
15
16
|
const { footer } = useThemeSettings(DEFAULT_THEME_NAME);
|
|
16
17
|
|
|
17
|
-
if (
|
|
18
|
+
if (isEmptyArray(columns) || !copyrightText || footer?.hide) {
|
|
18
19
|
return null;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
return (
|
|
22
23
|
<FooterContainer data-component-name="Footer/Footer">
|
|
23
|
-
<FooterColumns columns={columns} />
|
|
24
|
+
<FooterColumns columns={columns as ResolvedNavItem[]} />
|
|
24
25
|
<FooterCopyright copyrightText={copyrightText} />
|
|
25
26
|
</FooterContainer>
|
|
26
27
|
);
|
|
@@ -2,14 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
4
|
import { FooterColumn } from '@theme/Footer/FooterColumn';
|
|
5
|
-
import type {
|
|
5
|
+
import type { ResolvedNavItem } from '@theme/types/portal';
|
|
6
6
|
|
|
7
7
|
interface FooterColumnsProps {
|
|
8
|
-
columns:
|
|
8
|
+
columns: ResolvedNavItem[];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function FooterColumns({ columns }: FooterColumnsProps): JSX.Element | null {
|
|
12
|
-
if (
|
|
12
|
+
if (!columns?.length) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -11,9 +11,17 @@ export interface JsonProps {
|
|
|
11
11
|
data: any;
|
|
12
12
|
className?: string;
|
|
13
13
|
jsonSampleExpandLevel: number;
|
|
14
|
+
withLineNumbers?: boolean;
|
|
15
|
+
startLineNumber?: number;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
function JsonComponent({
|
|
18
|
+
function JsonComponent({
|
|
19
|
+
data,
|
|
20
|
+
jsonSampleExpandLevel,
|
|
21
|
+
className,
|
|
22
|
+
withLineNumbers,
|
|
23
|
+
startLineNumber,
|
|
24
|
+
}: JsonProps): JSX.Element {
|
|
17
25
|
const node = useRef<HTMLDivElement | null>(null);
|
|
18
26
|
|
|
19
27
|
useMount(() => {
|
|
@@ -84,10 +92,10 @@ function JsonComponent({ data, jsonSampleExpandLevel, className }: JsonProps): J
|
|
|
84
92
|
)}
|
|
85
93
|
</SampleControls>
|
|
86
94
|
<StyledCodeBlock
|
|
87
|
-
className={className}
|
|
95
|
+
className={withLineNumbers ? `${className} line-numbers` : className}
|
|
88
96
|
ref={node}
|
|
89
97
|
dangerouslySetInnerHTML={{
|
|
90
|
-
__html: jsonToHTML(data, jsonSampleExpandLevel),
|
|
98
|
+
__html: jsonToHTML(data, jsonSampleExpandLevel, startLineNumber),
|
|
91
99
|
}}
|
|
92
100
|
/>
|
|
93
101
|
</JsonViewerWrap>
|
|
@@ -111,15 +119,11 @@ export const JsonViewer = styled(Json).attrs(() => ({
|
|
|
111
119
|
color: var(--color-content-inverse);
|
|
112
120
|
padding: inherit;
|
|
113
121
|
border: none;
|
|
114
|
-
|
|
115
|
-
& > .collapser {
|
|
116
|
-
display: none;
|
|
117
|
-
pointer-events: none;
|
|
118
|
-
}
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
contain: content;
|
|
122
125
|
overflow-x: auto;
|
|
126
|
+
position: relative;
|
|
123
127
|
padding: 10px;
|
|
124
128
|
border-radius: var(--global-border-radius);
|
|
125
129
|
background-color: var(--samples-panel-controls-background-color);
|
|
@@ -128,13 +132,26 @@ export const JsonViewer = styled(Json).attrs(() => ({
|
|
|
128
132
|
font-family: var(--code-font-family);
|
|
129
133
|
white-space: var(--code-wrap, pre);
|
|
130
134
|
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
&.line-numbers {
|
|
136
|
+
padding: 20px 20px 20px 3em;
|
|
137
|
+
|
|
138
|
+
*[data-line]:not(.collapsed *[data-line]) {
|
|
139
|
+
&:before {
|
|
140
|
+
content: attr(data-line);
|
|
141
|
+
position: absolute;
|
|
142
|
+
left: 0;
|
|
143
|
+
min-width: 2em;
|
|
144
|
+
text-align: right;
|
|
145
|
+
pointer-events: none;
|
|
146
|
+
user-select: none;
|
|
147
|
+
padding: 0 0.5em;
|
|
148
|
+
font-size: 13px;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
133
151
|
}
|
|
134
152
|
|
|
135
|
-
.
|
|
136
|
-
|
|
137
|
-
cursor: pointer;
|
|
153
|
+
.callback-function {
|
|
154
|
+
color: gray;
|
|
138
155
|
}
|
|
139
156
|
|
|
140
157
|
.collapsed > .collapser:after {
|
|
@@ -147,11 +164,17 @@ export const JsonViewer = styled(Json).attrs(() => ({
|
|
|
147
164
|
}
|
|
148
165
|
|
|
149
166
|
.collapsible {
|
|
150
|
-
|
|
167
|
+
padding-left: 2ch;
|
|
168
|
+
display: inline-block;
|
|
151
169
|
}
|
|
152
170
|
|
|
153
171
|
.hoverable {
|
|
154
172
|
padding: 1px 2px;
|
|
173
|
+
display: inline-block;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.collapsed {
|
|
177
|
+
display: inline-flex;
|
|
155
178
|
}
|
|
156
179
|
|
|
157
180
|
.hovered {
|
|
@@ -161,39 +184,31 @@ export const JsonViewer = styled(Json).attrs(() => ({
|
|
|
161
184
|
.collapser {
|
|
162
185
|
background-color: transparent;
|
|
163
186
|
border: 0;
|
|
187
|
+
padding: 0;
|
|
164
188
|
color: #fff;
|
|
165
|
-
|
|
166
|
-
align-items: center;
|
|
167
|
-
justify-content: center;
|
|
168
|
-
width: 15px;
|
|
189
|
+
width: 0;
|
|
169
190
|
height: 15px;
|
|
170
|
-
position: absolute;
|
|
171
|
-
top: 4px;
|
|
172
|
-
left: -1.5em;
|
|
173
191
|
cursor: default;
|
|
174
192
|
user-select: none;
|
|
175
193
|
-webkit-user-select: none;
|
|
176
|
-
padding: 2px;
|
|
177
194
|
font-family: var(--code-font-family);
|
|
178
195
|
font-size: var(--code-font-size);
|
|
179
|
-
&:focus {
|
|
180
|
-
outline: #fff dotted 1px;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
ul {
|
|
185
|
-
list-style-type: none;
|
|
186
|
-
padding: 0;
|
|
187
|
-
margin: 0 0 0 26px;
|
|
188
|
-
}
|
|
189
196
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
&:after {
|
|
198
|
+
content: '-';
|
|
199
|
+
cursor: pointer;
|
|
200
|
+
display: flex;
|
|
201
|
+
align-items: center;
|
|
202
|
+
justify-content: center;
|
|
203
|
+
width: 15px;
|
|
204
|
+
height: 100%;
|
|
205
|
+
padding: 2px 5px 2px 2px;
|
|
206
|
+
transform: translateX(-100%);
|
|
207
|
+
|
|
208
|
+
&:focus {
|
|
209
|
+
outline: #fff dotted 1px;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
197
212
|
}
|
|
198
213
|
|
|
199
214
|
.selected {
|
|
@@ -210,7 +225,7 @@ export const JsonViewer = styled(Json).attrs(() => ({
|
|
|
210
225
|
}
|
|
211
226
|
|
|
212
227
|
.collapsed > .ellipsis {
|
|
213
|
-
display:
|
|
228
|
+
display: inline;
|
|
214
229
|
}
|
|
215
230
|
`;
|
|
216
231
|
|
|
@@ -17,7 +17,7 @@ export function Admonition({
|
|
|
17
17
|
children,
|
|
18
18
|
}: React.PropsWithChildren<AdmonitionProps>): JSX.Element {
|
|
19
19
|
return (
|
|
20
|
-
<Wrapper type={type} data-component-name="Markdown/Admonition
|
|
20
|
+
<Wrapper type={type} data-component-name="Markdown/Admonition">
|
|
21
21
|
<AlertIcon type={type} />
|
|
22
22
|
{name ? <Heading type={type}>{name}</Heading> : null}
|
|
23
23
|
<Content>{children}</Content>
|
package/src/Markdown/Heading.tsx
CHANGED
package/src/Markdown/Mermaid.tsx
CHANGED
|
@@ -10,7 +10,7 @@ export function Mermaid({ diagramHtml }: MermaidProps): JSX.Element {
|
|
|
10
10
|
<Wrapper
|
|
11
11
|
className="mermaid-wrapper"
|
|
12
12
|
dangerouslySetInnerHTML={{ __html: diagramHtml }}
|
|
13
|
-
data-component-name="Markdown/Mermaid
|
|
13
|
+
data-component-name="Markdown/Mermaid"
|
|
14
14
|
/>
|
|
15
15
|
);
|
|
16
16
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export function Sup({ children }: PropsWithChildren<unknown>): JSX.Element {
|
|
5
|
+
return <Wrapper data-component-name="Markdown/Sup">{children}</Wrapper>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const Wrapper = styled.sup``;
|
package/src/Markdown/index.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export * from '@theme/Markdown/CodeSample';
|
|
2
|
-
export * from '@theme/Markdown/Tabs';
|
|
3
1
|
export * from '@theme/Markdown/Admonition';
|
|
2
|
+
export * from '@theme/Markdown/CodeSample';
|
|
4
3
|
export * from '@theme/Markdown/ContentWrapper';
|
|
5
4
|
export * from '@theme/Markdown/Heading';
|
|
6
5
|
export * from '@theme/Markdown/MarkdownLayout';
|
|
6
|
+
export * from '@theme/Markdown/MarkdownWrapper';
|
|
7
7
|
export * from '@theme/Markdown/Mermaid';
|
|
8
8
|
export * from '@theme/Markdown/PageWrapper';
|
|
9
|
-
export * from '@theme/Markdown/
|
|
9
|
+
export * from '@theme/Markdown/Sup';
|
|
10
|
+
export * from '@theme/Markdown/Tabs';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { ResolvedNavLinkItem } from '@theme/types/portal';
|
|
5
|
+
import { Link } from '@portal/Link';
|
|
6
|
+
|
|
7
|
+
interface NavbarDropdownProps {
|
|
8
|
+
items: ResolvedNavLinkItem[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function MobileNavbarDropdown({ items }: NavbarDropdownProps): JSX.Element {
|
|
12
|
+
return (
|
|
13
|
+
<MobileDropdownWrapper data-component-name="Navbar/MobileNavbarDropdown">
|
|
14
|
+
{items.map((item, index) => (
|
|
15
|
+
<div key={`${item.label}_${index}`}>
|
|
16
|
+
<Link to={item.link}>{item.label}</Link>
|
|
17
|
+
</div>
|
|
18
|
+
))}
|
|
19
|
+
</MobileDropdownWrapper>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const MobileDropdownWrapper = styled.div`
|
|
24
|
+
padding: 0 15px;
|
|
25
|
+
width: max-content;
|
|
26
|
+
transition: all 0.2s ease-in-out;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
box-shadow: var(--navbar-dropdown-shadow);
|
|
29
|
+
& > div {
|
|
30
|
+
padding: 10px 0;
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
a {
|
|
33
|
+
color: var(--navbar-text-color);
|
|
34
|
+
text-decoration: none;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
ResolvedNavItem,
|
|
7
|
+
ResolvedNavLinkItem,
|
|
8
|
+
ResolvedNavGroupItem,
|
|
9
|
+
} from '@theme/types/portal';
|
|
10
|
+
import { Link } from '@portal/Link';
|
|
11
|
+
import { withPathPrefix } from '@portal/utils';
|
|
12
|
+
import { MobileDropdownWrapper, MobileNavbarDropdown } from '@theme/Navbar/MobileNavbarDropdown';
|
|
13
|
+
|
|
14
|
+
export interface NavbarItemProps {
|
|
15
|
+
navItem: ResolvedNavItem;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function MobileNavbarItem({ navItem, className }: NavbarItemProps): JSX.Element | null {
|
|
20
|
+
const { pathname } = useLocation();
|
|
21
|
+
const [expandedDropdown, setExpandedDropdown] = useState(false);
|
|
22
|
+
const toggleDropdown = () => setExpandedDropdown(!expandedDropdown);
|
|
23
|
+
|
|
24
|
+
if ((navItem as ResolvedNavLinkItem).link) {
|
|
25
|
+
const item = navItem as ResolvedNavLinkItem;
|
|
26
|
+
const isActive = pathname === withPathPrefix(item.link);
|
|
27
|
+
return (
|
|
28
|
+
<NavMenuItem
|
|
29
|
+
active={isActive}
|
|
30
|
+
data-component-name="Navbar/MobileNavbarItem"
|
|
31
|
+
className={className}
|
|
32
|
+
>
|
|
33
|
+
<NavLink to={item.link} active={isActive}>
|
|
34
|
+
<NavLabel>{item.label}</NavLabel>
|
|
35
|
+
</NavLink>
|
|
36
|
+
</NavMenuItem>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if ((navItem as ResolvedNavGroupItem).items) {
|
|
41
|
+
const item = navItem as ResolvedNavGroupItem;
|
|
42
|
+
return (
|
|
43
|
+
<NavMenuItemWithDropdownWrapper expanded={expandedDropdown}>
|
|
44
|
+
<NavMenuItem
|
|
45
|
+
active={false}
|
|
46
|
+
onClick={toggleDropdown}
|
|
47
|
+
data-component-name="Navbar/MobileNavbarItem"
|
|
48
|
+
className={className}
|
|
49
|
+
>
|
|
50
|
+
<NavLabel>{item.label}</NavLabel>
|
|
51
|
+
<ExpandedArrow />
|
|
52
|
+
</NavMenuItem>
|
|
53
|
+
<MobileNavbarDropdown items={item.items as ResolvedNavLinkItem[]} />
|
|
54
|
+
</NavMenuItemWithDropdownWrapper>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const ExpandedArrow = styled.div`
|
|
62
|
+
width: 5px;
|
|
63
|
+
height: 5px;
|
|
64
|
+
border: 1px solid;
|
|
65
|
+
border-left: none;
|
|
66
|
+
border-top: none;
|
|
67
|
+
transition: all 0.3s ease-out;
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
export const NavMenuItem = styled.li<{ active?: boolean }>`
|
|
71
|
+
display: flex;
|
|
72
|
+
justify-content: space-between;
|
|
73
|
+
align-items: center;
|
|
74
|
+
padding: calc(var(--sidebar-spacing-horizontal) * 2);
|
|
75
|
+
text-align: left;
|
|
76
|
+
line-height: 1;
|
|
77
|
+
font-size: var(--navbar-item-font-size);
|
|
78
|
+
margin-left: var(--navbar-item-margin-horizontal);
|
|
79
|
+
margin-right: var(--navbar-item-margin-horizontal);
|
|
80
|
+
font-weight: var(--navbar-item-font-weight);
|
|
81
|
+
background: ${({ active }) => (active ? 'var(--navbar-item-active-background-color)' : 'none')};
|
|
82
|
+
&:not(:last-child) {
|
|
83
|
+
border-bottom: 1px solid var(--navbar-item-separator-line-color, #dadada);
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
export const NavMenuItemWithDropdownWrapper = styled.div<{ expanded: boolean }>`
|
|
88
|
+
display: inline-block;
|
|
89
|
+
position: relative;
|
|
90
|
+
border-bottom: 1px solid var(--navbar-item-separator-line-color, #dadada);
|
|
91
|
+
|
|
92
|
+
${ExpandedArrow} {
|
|
93
|
+
transform: rotate(${({ expanded }) => (expanded ? '' : '-')}45deg);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
${MobileDropdownWrapper} {
|
|
97
|
+
height: ${({ expanded }) => (expanded ? '100%' : '0')};
|
|
98
|
+
opacity: ${({ expanded }) => (expanded ? '1' : '0')};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
${NavMenuItem} {
|
|
102
|
+
border-bottom: none;
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
export const NavLink = styled(Link)`
|
|
107
|
+
color: ${({ active }) =>
|
|
108
|
+
active ? 'var(--navbar-item-active-text-color)' : 'var(--navbar-text-color)'};
|
|
109
|
+
text-decoration: ${({ active }) =>
|
|
110
|
+
active ? 'var(--navbar-item-active-text-decoration)' : 'none'};
|
|
111
|
+
`;
|
|
112
|
+
|
|
113
|
+
const NavLabel = styled.span`
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
vertical-align: middle;
|
|
116
|
+
`;
|