@redocly/theme 0.5.0 → 0.6.0
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/lib/ColorModeSwitcher/ColorModeSwitcher.js +23 -10
- package/lib/EditPageButton/EditPageButton.d.ts +1 -1
- package/lib/EditPageButton/EditPageButton.js +1 -1
- package/lib/Footer/Footer.js +2 -2
- package/lib/LastUpdated/LastUpdated.js +30 -7
- package/lib/Markdown/CodeSample/CodeSample.js +6 -14
- package/lib/Markdown/MarkdownLayout.d.ts +1 -1
- package/lib/Markdown/MarkdownLayout.js +5 -1
- package/lib/Navbar/Navbar.js +2 -2
- package/lib/PageNavigation/NextPageLink.js +30 -7
- package/lib/PageNavigation/PageNavigation.js +4 -3
- package/lib/PageNavigation/PreviousPageLink.js +4 -4
- package/lib/Sidebar/SidebarLayout.js +2 -2
- package/lib/Sidebar/types/MenuStyle.js +0 -1
- package/lib/TableOfContent/TableOfContent.d.ts +0 -1
- package/lib/TableOfContent/TableOfContent.js +5 -7
- package/lib/config.d.ts +385 -0
- package/lib/config.js +113 -0
- package/lib/globalStyle.js +3 -5
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/useActiveHeading.js +1 -1
- package/lib/hooks/useActiveSectionId.js +1 -1
- package/lib/hooks/useThemeConfig.d.ts +1 -0
- package/lib/hooks/useThemeConfig.js +6 -0
- package/lib/icons/ColorModeIcon/ColorModeIcon.js +3 -3
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/mocks/Link.js +1 -1
- package/lib/mocks/hooks/index.d.ts +2 -5
- package/lib/mocks/hooks/index.js +22 -6
- package/lib/mocks/types.d.ts +0 -11
- package/lib/mocks/types.js +1 -0
- package/lib/mocks/utils.js +1 -1
- package/lib/types/config.d.ts +5 -0
- package/lib/types/config.js +3 -0
- package/lib/utils/args-typecheck.js +1 -1
- package/package.json +10 -8
- package/src/ColorModeSwitcher/ColorModeSwitcher.tsx +29 -12
- package/src/EditPageButton/EditPageButton.tsx +2 -2
- package/src/Footer/Footer.tsx +2 -2
- package/src/LastUpdated/LastUpdated.tsx +8 -6
- package/src/Markdown/CodeSample/CodeSample.tsx +7 -16
- package/src/Markdown/MarkdownLayout.tsx +9 -3
- package/src/Navbar/Navbar.tsx +2 -2
- package/src/PageNavigation/NextPageLink.tsx +8 -5
- package/src/PageNavigation/PageNavigation.tsx +3 -3
- package/src/PageNavigation/PreviousPageLink.tsx +7 -4
- package/src/Sidebar/SidebarLayout.tsx +2 -2
- package/src/Sidebar/types/MenuStyle.ts +0 -1
- package/src/TableOfContent/TableOfContent.tsx +5 -7
- package/src/config.ts +130 -0
- package/src/globalStyle.ts +3 -5
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useActiveHeading.ts +3 -1
- package/src/hooks/useActiveSectionId.ts +1 -1
- package/src/hooks/useThemeConfig.ts +1 -0
- package/src/icons/ColorModeIcon/ColorModeIcon.tsx +3 -3
- package/src/index.ts +3 -0
- package/src/mocks/Link.tsx +8 -1
- package/src/mocks/hooks/index.ts +22 -9
- package/src/mocks/types.ts +2 -11
- package/src/mocks/utils.ts +1 -1
- package/src/types/config.ts +5 -0
- package/src/types/portal/src/shared/constants.d.ts +0 -1
- package/src/utils/args-typecheck.ts +1 -1
- package/lib/hooks/useDefaultThemeSettings.d.ts +0 -2
- package/lib/hooks/useDefaultThemeSettings.js +0 -10
- package/src/hooks/useDefaultThemeSettings.ts +0 -7
|
@@ -31,22 +31,21 @@ const react_1 = __importStar(require("react"));
|
|
|
31
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
32
|
const ColorModeIcon_1 = require("../icons/ColorModeIcon");
|
|
33
33
|
const hooks_1 = require("../hooks");
|
|
34
|
-
const useDefaultThemeSettings_1 = require("../hooks/useDefaultThemeSettings");
|
|
35
34
|
function ColorModeSwitcher() {
|
|
36
|
-
const themeSettings = (0,
|
|
35
|
+
const themeSettings = (0, hooks_1.useThemeConfig)();
|
|
37
36
|
const colorMode = themeSettings.colorMode;
|
|
38
37
|
const [activeColorMode, setActiveColorMode] = (0, react_1.useState)('');
|
|
38
|
+
const modes = (colorMode === null || colorMode === void 0 ? void 0 : colorMode.modes) || ['light', 'dark'];
|
|
39
|
+
const defaultColor = (colorMode === null || colorMode === void 0 ? void 0 : colorMode.default) || modes[0] || 'light';
|
|
39
40
|
(0, hooks_1.useMount)(() => {
|
|
40
|
-
setActiveColorMode(document.documentElement.className ||
|
|
41
|
+
setActiveColorMode(document.documentElement.className || defaultColor);
|
|
41
42
|
});
|
|
42
|
-
if (
|
|
43
|
+
if (colorMode === null || colorMode === void 0 ? void 0 : colorMode.hide) {
|
|
43
44
|
return null;
|
|
44
45
|
}
|
|
45
46
|
const handelChangeColorMode = () => {
|
|
46
|
-
const activeIndex =
|
|
47
|
-
const mode = activeIndex <
|
|
48
|
-
? colorMode.modes[activeIndex + 1]
|
|
49
|
-
: colorMode.modes[0];
|
|
47
|
+
const activeIndex = modes.indexOf(activeColorMode);
|
|
48
|
+
const mode = activeIndex < modes.length - 1 ? modes[activeIndex + 1] : modes[0];
|
|
50
49
|
setActiveColorMode(mode);
|
|
51
50
|
localStorage.setItem('colorSchema', mode);
|
|
52
51
|
document.documentElement.className = `${mode} notransition`;
|
|
@@ -54,8 +53,7 @@ function ColorModeSwitcher() {
|
|
|
54
53
|
document.documentElement.classList.remove('notransition');
|
|
55
54
|
});
|
|
56
55
|
};
|
|
57
|
-
return (react_1.default.createElement(Wrapper, { "data-component-name": "ColorModeSwitcher/ColorModeSwitcher", onClick: handelChangeColorMode },
|
|
58
|
-
react_1.default.createElement(ColorModeIcon_1.ColorModeIcon, { mode: activeColorMode })));
|
|
56
|
+
return (react_1.default.createElement(Wrapper, { "data-component-name": "ColorModeSwitcher/ColorModeSwitcher", onClick: handelChangeColorMode, modes: modes }, modes.map((mode) => (react_1.default.createElement(ColorModeIcon_1.ColorModeIcon, { mode: mode, key: mode })))));
|
|
59
57
|
}
|
|
60
58
|
exports.ColorModeSwitcher = ColorModeSwitcher;
|
|
61
59
|
const Wrapper = styled_components_1.default.div `
|
|
@@ -64,5 +62,20 @@ const Wrapper = styled_components_1.default.div `
|
|
|
64
62
|
align-items: center;
|
|
65
63
|
cursor: pointer;
|
|
66
64
|
user-select: none;
|
|
65
|
+
|
|
66
|
+
${ColorModeIcon_1.ColorModeIcon} {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
${({ modes }) => {
|
|
71
|
+
const items = modes.map((mode) => {
|
|
72
|
+
return `
|
|
73
|
+
html.${mode} & ${ColorModeIcon_1.ColorModeIcon}.${mode} {
|
|
74
|
+
display: block;
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
});
|
|
78
|
+
return items.join('');
|
|
79
|
+
}}
|
|
67
80
|
`;
|
|
68
81
|
//# sourceMappingURL=ColorModeSwitcher.js.map
|
|
@@ -9,7 +9,7 @@ const styled_components_1 = __importDefault(require("styled-components"));
|
|
|
9
9
|
const Link_1 = require("../mocks/Link");
|
|
10
10
|
const EditPageButton = ({ text, to, icon }) => {
|
|
11
11
|
return (react_1.default.createElement(EditButton, { to: to },
|
|
12
|
-
react_1.default.createElement(ButtonIcon, { src: icon }),
|
|
12
|
+
icon ? react_1.default.createElement(ButtonIcon, { src: icon }) : null,
|
|
13
13
|
react_1.default.createElement(ButtonText, null, text)));
|
|
14
14
|
};
|
|
15
15
|
exports.EditPageButton = EditPageButton;
|
package/lib/Footer/Footer.js
CHANGED
|
@@ -9,9 +9,9 @@ const styled_components_1 = __importDefault(require("styled-components"));
|
|
|
9
9
|
const FooterColumns_1 = require("../Footer/FooterColumns");
|
|
10
10
|
const FooterCopyright_1 = require("../Footer/FooterCopyright");
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
|
-
const
|
|
12
|
+
const hooks_1 = require("../hooks");
|
|
13
13
|
function Footer({ data: { columns, copyrightText } }) {
|
|
14
|
-
const { footer } = (0,
|
|
14
|
+
const { footer } = (0, hooks_1.useThemeConfig)();
|
|
15
15
|
if ((0, utils_1.isEmptyArray)(columns) || !copyrightText || (footer === null || footer === void 0 ? void 0 : footer.hide)) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.LastUpdated = void 0;
|
|
7
|
-
const
|
|
30
|
+
const React = __importStar(require("react"));
|
|
8
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
32
|
const timeago_js_1 = require("timeago.js");
|
|
10
|
-
const
|
|
33
|
+
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
11
34
|
const FORMATS = {
|
|
12
35
|
timeago: (date, locale) => (0, timeago_js_1.format)(date, locale),
|
|
13
36
|
iso: (date) => date.toISOString().split('T')[0],
|
|
@@ -15,20 +38,20 @@ const FORMATS = {
|
|
|
15
38
|
long: (date, locale) => date.toLocaleDateString(locale, { month: 'long', day: 'numeric', year: 'numeric' }),
|
|
16
39
|
};
|
|
17
40
|
function LastUpdated(props) {
|
|
18
|
-
const { lastUpdatedBlock } = (0,
|
|
41
|
+
const { markdown: { lastUpdatedBlock = {} } = {} } = (0, useThemeConfig_1.useThemeConfig)();
|
|
19
42
|
if (lastUpdatedBlock === null || lastUpdatedBlock === void 0 ? void 0 : lastUpdatedBlock.hide) {
|
|
20
43
|
return null;
|
|
21
44
|
}
|
|
22
45
|
const lastModified = props.lastModified;
|
|
23
|
-
const format = props.format ||
|
|
24
|
-
const locale = props.locale ||
|
|
46
|
+
const format = props.format || lastUpdatedBlock.format || 'timeago';
|
|
47
|
+
const locale = props.locale || lastUpdatedBlock.locale || 'en-US';
|
|
25
48
|
const isoDate = lastModified.toISOString().split('T')[0];
|
|
26
49
|
const lastUpdatedString = FORMATS[format](lastModified, locale);
|
|
27
50
|
const separator = format === 'timeago' ? ' ' : ' on ';
|
|
28
|
-
return (
|
|
51
|
+
return (React.createElement(Wrapper, { "data-component-name": "LastUpdated/LastUpdated", rawOnPrint: format === 'timeago', "data-print-datetime": isoDate },
|
|
29
52
|
"Last updated",
|
|
30
53
|
separator,
|
|
31
|
-
|
|
54
|
+
React.createElement("time", { dateTime: isoDate }, lastUpdatedString)));
|
|
32
55
|
}
|
|
33
56
|
exports.LastUpdated = LastUpdated;
|
|
34
57
|
const Wrapper = styled_components_1.default.div `
|
|
@@ -27,28 +27,20 @@ exports.CodeSample = void 0;
|
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
29
29
|
const ClipboardService_1 = require("../../utils/ClipboardService");
|
|
30
|
-
const
|
|
31
|
-
const defaultCopyCodeSnippet = {
|
|
32
|
-
hide: false,
|
|
33
|
-
buttonText: 'Copy',
|
|
34
|
-
tooltipText: 'Copy the code snippet',
|
|
35
|
-
toasterText: 'Copied',
|
|
36
|
-
toasterDuration: 1500,
|
|
37
|
-
};
|
|
30
|
+
const useThemeConfig_1 = require("../../hooks/useThemeConfig");
|
|
38
31
|
function CodeSample({ rawContent, highlighted, language }) {
|
|
39
32
|
const langClassName = language ? `language-${language}` : '';
|
|
40
|
-
const { copyCodeSnippet } = (0,
|
|
41
|
-
const copyCodeProps = Object.assign(Object.assign({}, defaultCopyCodeSnippet), copyCodeSnippet);
|
|
33
|
+
const { markdown: { copyCodeSnippet = {} } = {} } = (0, useThemeConfig_1.useThemeConfig)();
|
|
42
34
|
const [isCopied, setIsCopied] = (0, react_1.useState)(false);
|
|
43
35
|
const copyCode = (code) => {
|
|
44
36
|
ClipboardService_1.ClipboardService.copyCustom(code);
|
|
45
37
|
setIsCopied(true);
|
|
46
|
-
setTimeout(() => setIsCopied(false),
|
|
38
|
+
setTimeout(() => setIsCopied(false), copyCodeSnippet.toasterDuration);
|
|
47
39
|
};
|
|
48
40
|
return (react_1.default.createElement(Wrapper, { className: "code-sample", "data-component-name": "Markdown/CodeSample/CodeSample" },
|
|
49
|
-
!
|
|
50
|
-
!isCopied && (react_1.default.createElement(CopyCodeButton, { title:
|
|
51
|
-
isCopied && react_1.default.createElement(DoneIndicator, null,
|
|
41
|
+
!copyCodeSnippet.hide && (react_1.default.createElement(CodeSampleButtonContainer, { onClick: () => copyCode(rawContent) },
|
|
42
|
+
!isCopied && (react_1.default.createElement(CopyCodeButton, { title: copyCodeSnippet.tooltipText || 'Copy to clipboard' }, copyCodeSnippet.buttonText)),
|
|
43
|
+
isCopied && react_1.default.createElement(DoneIndicator, null, copyCodeSnippet.toasterText))),
|
|
52
44
|
react_1.default.createElement("pre", { className: langClassName },
|
|
53
45
|
react_1.default.createElement("code", { className: langClassName, dangerouslySetInnerHTML: { __html: highlighted } }))));
|
|
54
46
|
}
|
|
@@ -11,12 +11,16 @@ const ContainerWrapper_1 = require("../Markdown/ContainerWrapper");
|
|
|
11
11
|
const PageNavigation_1 = require("../PageNavigation/PageNavigation");
|
|
12
12
|
const EditPageButton_1 = require("../EditPageButton");
|
|
13
13
|
const LastUpdated_1 = require("../LastUpdated/LastUpdated");
|
|
14
|
+
const hooks_1 = require("../hooks");
|
|
14
15
|
function MarkdownLayout({ tableOfContent, markdownWrapper, editPage, lastModified, }) {
|
|
16
|
+
const { markdown } = (0, hooks_1.useThemeConfig)();
|
|
17
|
+
const { editPage: themeEditPage } = markdown || {};
|
|
18
|
+
const mergedConf = editPage ? Object.assign(Object.assign({}, editPage), themeEditPage) : undefined;
|
|
15
19
|
return (react_1.default.createElement(PageWrapper_1.PageWrapper, { "data-component-name": "Markdown/MarkdownLayout" },
|
|
16
20
|
react_1.default.createElement(ContainerWrapper_1.ContainerWrapper, { withToc: true },
|
|
17
21
|
react_1.default.createElement(LayoutTop, null,
|
|
18
22
|
lastModified && react_1.default.createElement(LastUpdated_1.LastUpdated, { lastModified: new Date(lastModified) }),
|
|
19
|
-
|
|
23
|
+
mergedConf && (react_1.default.createElement(EditPageButton_1.EditPageButton, { text: mergedConf.text, to: mergedConf.to, icon: mergedConf.icon }))),
|
|
20
24
|
markdownWrapper,
|
|
21
25
|
react_1.default.createElement(PageNavigation_1.PageNavigation, null)),
|
|
22
26
|
tableOfContent));
|
package/lib/Navbar/Navbar.js
CHANGED
|
@@ -11,10 +11,10 @@ const useMobileMenu_1 = require("../hooks/useMobileMenu");
|
|
|
11
11
|
const MobileNavbarMenuButton_1 = require("../Navbar/MobileNavbarMenuButton");
|
|
12
12
|
const MobileNavbarMenu_1 = require("../Navbar/MobileNavbarMenu");
|
|
13
13
|
const ColorModeSwitcher_1 = require("../ColorModeSwitcher/ColorModeSwitcher");
|
|
14
|
-
const
|
|
14
|
+
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
15
15
|
function Navbar({ menu, logo, search, profile }) {
|
|
16
16
|
const [isOpen, setIsOpen] = (0, useMobileMenu_1.useMobileMenu)(false);
|
|
17
|
-
const { search: searchSettings, navbar } = (0,
|
|
17
|
+
const { search: searchSettings, navbar } = (0, useThemeConfig_1.useThemeConfig)();
|
|
18
18
|
const hideSearch = (searchSettings === null || searchSettings === void 0 ? void 0 : searchSettings.hide) || ((searchSettings === null || searchSettings === void 0 ? void 0 : searchSettings.placement) && (searchSettings === null || searchSettings === void 0 ? void 0 : searchSettings.placement) !== 'navbar');
|
|
19
19
|
if (navbar === null || navbar === void 0 ? void 0 : navbar.hide) {
|
|
20
20
|
return null;
|
|
@@ -1,23 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.NextPageLink = void 0;
|
|
7
|
-
const
|
|
30
|
+
const React = __importStar(require("react"));
|
|
8
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
32
|
const hooks_1 = require("../mocks/hooks");
|
|
10
33
|
const Button_1 = require("../Button/Button");
|
|
11
|
-
const
|
|
34
|
+
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
12
35
|
function NextPageLink() {
|
|
13
36
|
var _a, _b;
|
|
14
37
|
const { nextPage } = (0, hooks_1.useSidebarSiblingsData)() || {};
|
|
15
|
-
const { navigation } = (0,
|
|
16
|
-
if (!nextPage || (
|
|
17
|
-
return
|
|
38
|
+
const { navigation } = (0, useThemeConfig_1.useThemeConfig)();
|
|
39
|
+
if (!nextPage || ((_a = navigation === null || navigation === void 0 ? void 0 : navigation.nextPageLink) === null || _a === void 0 ? void 0 : _a.hide)) {
|
|
40
|
+
return React.createElement("div", null, "\u00A0");
|
|
18
41
|
}
|
|
19
|
-
const label = ((_b = navigation === null || navigation === void 0 ? void 0 : navigation.nextPageLink) === null || _b === void 0 ? void 0 : _b.label) ||
|
|
20
|
-
return (
|
|
42
|
+
const label = (((_b = navigation === null || navigation === void 0 ? void 0 : navigation.nextPageLink) === null || _b === void 0 ? void 0 : _b.label) || 'Next to {label}').replace('{label}', nextPage.label || nextPage.routeSlug || '');
|
|
43
|
+
return (React.createElement(StyledButton, { variant: "outlined", size: "large", to: nextPage.link, "data-component-name": "PageNavigation/NextPageLink" }, label));
|
|
21
44
|
}
|
|
22
45
|
exports.NextPageLink = NextPageLink;
|
|
23
46
|
const StyledButton = (0, styled_components_1.default)(Button_1.Button) `
|
|
@@ -8,10 +8,11 @@ const react_1 = __importDefault(require("react"));
|
|
|
8
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
9
|
const PreviousPageLink_1 = require("../PageNavigation/PreviousPageLink");
|
|
10
10
|
const NextPageLink_1 = require("../PageNavigation/NextPageLink");
|
|
11
|
-
const
|
|
11
|
+
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
12
12
|
function PageNavigation() {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const { navigation } = (0, useThemeConfig_1.useThemeConfig)();
|
|
15
|
+
if (((_a = navigation === null || navigation === void 0 ? void 0 : navigation.prevPageLink) === null || _a === void 0 ? void 0 : _a.hide) && ((_b = navigation === null || navigation === void 0 ? void 0 : navigation.nextPageLink) === null || _b === void 0 ? void 0 : _b.hide)) {
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
17
18
|
return (react_1.default.createElement(PageNavigationWrapper, { "data-component-name": "PageNavigation/PageNavigation" },
|
|
@@ -7,16 +7,16 @@ exports.PreviousPageLink = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
9
|
const hooks_1 = require("../mocks/hooks");
|
|
10
|
-
const
|
|
10
|
+
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
11
11
|
const Button_1 = require("../Button/Button");
|
|
12
12
|
function PreviousPageLink() {
|
|
13
13
|
var _a, _b;
|
|
14
14
|
const { prevPage } = (0, hooks_1.useSidebarSiblingsData)() || {};
|
|
15
|
-
const { navigation } = (0,
|
|
16
|
-
if (!prevPage || (
|
|
15
|
+
const { navigation } = (0, useThemeConfig_1.useThemeConfig)();
|
|
16
|
+
if (!prevPage || ((_a = navigation === null || navigation === void 0 ? void 0 : navigation.prevPageLink) === null || _a === void 0 ? void 0 : _a.hide)) {
|
|
17
17
|
return react_1.default.createElement("div", null, "\u00A0");
|
|
18
18
|
}
|
|
19
|
-
const label = ((_b = navigation === null || navigation === void 0 ? void 0 : navigation.prevPageLink) === null || _b === void 0 ? void 0 : _b.label) ||
|
|
19
|
+
const label = (((_b = navigation === null || navigation === void 0 ? void 0 : navigation.prevPageLink) === null || _b === void 0 ? void 0 : _b.label) || 'Back to {label}').replace('{label}', prevPage.label || prevPage.routeSlug || '');
|
|
20
20
|
return (react_1.default.createElement(StyledButton, { variant: "outlined", size: "large", to: prevPage.link, "data-component-name": "PageNavigation/PreviousPageLink" }, label));
|
|
21
21
|
}
|
|
22
22
|
exports.PreviousPageLink = PreviousPageLink;
|
|
@@ -11,11 +11,11 @@ const useMobileMenu_1 = require("../hooks/useMobileMenu");
|
|
|
11
11
|
const MobileSidebarButton_1 = require("../Sidebar/MobileSidebarButton");
|
|
12
12
|
const MenuContainer_1 = require("../Sidebar/MenuContainer");
|
|
13
13
|
const SidebarSearch_1 = require("../Search/SidebarSearch");
|
|
14
|
-
const
|
|
14
|
+
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
15
15
|
function SidebarLayout({ versions, menu }) {
|
|
16
16
|
const [isOpen, setIsOpen] = (0, useMobileMenu_1.useMobileMenu)();
|
|
17
17
|
const toggleMenu = () => setIsOpen(!isOpen);
|
|
18
|
-
const { search, sidebar } = (0,
|
|
18
|
+
const { search, sidebar } = (0, useThemeConfig_1.useThemeConfig)();
|
|
19
19
|
if (sidebar === null || sidebar === void 0 ? void 0 : sidebar.hide) {
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
@@ -3,7 +3,6 @@ import type { MdHeading } from '@theme/types/portal';
|
|
|
3
3
|
interface TableOfContentProps {
|
|
4
4
|
headings?: Array<MdHeading | null> | null | undefined;
|
|
5
5
|
contentWrapper: HTMLDivElement | null;
|
|
6
|
-
tocMaxDepth: number;
|
|
7
6
|
}
|
|
8
7
|
export declare function TableOfContent(props: TableOfContentProps): JSX.Element | null;
|
|
9
8
|
export {};
|
|
@@ -31,15 +31,14 @@ const react_1 = __importStar(require("react"));
|
|
|
31
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
32
|
const useFullHeight_1 = require("../hooks/useFullHeight");
|
|
33
33
|
const useActiveHeading_1 = require("../hooks/useActiveHeading");
|
|
34
|
-
const
|
|
34
|
+
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
35
35
|
const utils_1 = require("./utils");
|
|
36
36
|
function TableOfContent(props) {
|
|
37
|
-
|
|
38
|
-
const { headings, tocMaxDepth, contentWrapper } = props;
|
|
37
|
+
const { headings, contentWrapper } = props;
|
|
39
38
|
const sidebar = (0, react_1.useRef)(null);
|
|
40
39
|
(0, useFullHeight_1.useFullHeight)(sidebar);
|
|
41
|
-
const { toc } = (0,
|
|
42
|
-
const displayedHeadings = (0, utils_1.getDisplayedHeadings)(headings,
|
|
40
|
+
const { markdown: { toc = {} } = {} } = (0, useThemeConfig_1.useThemeConfig)();
|
|
41
|
+
const displayedHeadings = (0, utils_1.getDisplayedHeadings)(headings, toc.maxDepth || 3);
|
|
43
42
|
const leastDepth = (0, utils_1.getLeastDepth)(displayedHeadings);
|
|
44
43
|
const activeHeadingId = (0, useActiveHeading_1.useActiveHeading)(contentWrapper, (0, utils_1.getDisplayedHeadingsIds)(displayedHeadings));
|
|
45
44
|
if (toc === null || toc === void 0 ? void 0 : toc.hide) {
|
|
@@ -53,9 +52,8 @@ function TableOfContent(props) {
|
|
|
53
52
|
}
|
|
54
53
|
return (react_1.default.createElement(react_1.default.Fragment, null, headings && (react_1.default.createElement(TableOfContentMenu, { "data-component-name": "TableOfContent/TableOfContent" },
|
|
55
54
|
react_1.default.createElement(TableOfContentItems, { ref: sidebar },
|
|
56
|
-
react_1.default.createElement(TocHeader, null,
|
|
55
|
+
react_1.default.createElement(TocHeader, null, toc.header || 'On this page'),
|
|
57
56
|
displayedHeadings.map((heading, idx) => {
|
|
58
|
-
// TODO: not sure about !heading
|
|
59
57
|
if (!heading) {
|
|
60
58
|
return null;
|
|
61
59
|
}
|