@redocly/theme 0.6.0 → 0.6.2
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/README.md +1 -1
- package/lib/ColorModeSwitcher/ColorModeSwitcher.js +1 -1
- package/lib/Footer/Footer.d.ts +6 -3
- package/lib/Footer/Footer.js +3 -3
- package/lib/PageNavigation/NextButton.d.ts +2 -0
- package/lib/PageNavigation/{NextPageLink.js → NextButton.js} +7 -7
- package/lib/PageNavigation/PageNavigation.js +5 -5
- package/lib/PageNavigation/PreviousButton.d.ts +2 -0
- package/lib/PageNavigation/{PreviousPageLink.js → PreviousButton.js} +7 -7
- package/lib/PageNavigation/index.d.ts +2 -2
- package/lib/PageNavigation/index.js +2 -2
- package/lib/Sidebar/types/NavItem.d.ts +1 -1
- package/lib/TableOfContent/TableOfContent.js +14 -19
- package/lib/TableOfContent/utils.d.ts +1 -1
- package/lib/TableOfContent/utils.js +2 -2
- package/lib/config.d.ts +342 -72
- package/lib/config.js +61 -17
- package/lib/mocks/hooks/index.js +4 -5
- package/package.json +3 -3
- package/src/ColorModeSwitcher/ColorModeSwitcher.tsx +1 -1
- package/src/Footer/Footer.tsx +8 -5
- package/src/PageNavigation/{NextPageLink.tsx → NextButton.tsx} +4 -4
- package/src/PageNavigation/PageNavigation.tsx +5 -5
- package/src/PageNavigation/{PreviousPageLink.tsx → PreviousButton.tsx} +4 -4
- package/src/PageNavigation/index.ts +2 -2
- package/src/Sidebar/types/NavItem.ts +1 -1
- package/src/TableOfContent/TableOfContent.tsx +24 -32
- package/src/TableOfContent/utils.ts +2 -2
- package/src/config.ts +73 -24
- package/src/mocks/hooks/index.ts +4 -5
- package/src/settings.yaml +2 -2
- package/src/types/portal/src/shared/constants.d.ts +0 -1
- package/src/types/portal/src/shared/types/nav.d.ts +0 -1
- package/lib/PageNavigation/NextPageLink.d.ts +0 -2
- package/lib/PageNavigation/PreviousPageLink.d.ts +0 -2
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
For more details, contact team@redocly.com
|
|
1
|
+
For more details, contact team@redocly.com.
|
|
@@ -36,7 +36,7 @@ function ColorModeSwitcher() {
|
|
|
36
36
|
const colorMode = themeSettings.colorMode;
|
|
37
37
|
const [activeColorMode, setActiveColorMode] = (0, react_1.useState)('');
|
|
38
38
|
const modes = (colorMode === null || colorMode === void 0 ? void 0 : colorMode.modes) || ['light', 'dark'];
|
|
39
|
-
const defaultColor =
|
|
39
|
+
const defaultColor = modes[0] || 'light';
|
|
40
40
|
(0, hooks_1.useMount)(() => {
|
|
41
41
|
setActiveColorMode(document.documentElement.className || defaultColor);
|
|
42
42
|
});
|
package/lib/Footer/Footer.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { NavGroup } from '@theme/types/portal';
|
|
3
3
|
interface FooterProps {
|
|
4
|
-
data:
|
|
4
|
+
data: {
|
|
5
|
+
items?: NavGroup;
|
|
6
|
+
copyrightText?: string;
|
|
7
|
+
};
|
|
5
8
|
}
|
|
6
|
-
export declare function Footer({ data: {
|
|
9
|
+
export declare function Footer({ data: { items, copyrightText } }: FooterProps): JSX.Element | null;
|
|
7
10
|
export {};
|
package/lib/Footer/Footer.js
CHANGED
|
@@ -10,13 +10,13 @@ const FooterColumns_1 = require("../Footer/FooterColumns");
|
|
|
10
10
|
const FooterCopyright_1 = require("../Footer/FooterCopyright");
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
12
|
const hooks_1 = require("../hooks");
|
|
13
|
-
function Footer({ data: {
|
|
13
|
+
function Footer({ data: { items, copyrightText } }) {
|
|
14
14
|
const { footer } = (0, hooks_1.useThemeConfig)();
|
|
15
|
-
if ((0, utils_1.isEmptyArray)(
|
|
15
|
+
if ((0, utils_1.isEmptyArray)(items) || !copyrightText || (footer === null || footer === void 0 ? void 0 : footer.hide)) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
18
|
return (react_1.default.createElement(FooterContainer, { "data-component-name": "Footer/Footer" },
|
|
19
|
-
react_1.default.createElement(FooterColumns_1.FooterColumns, { columns:
|
|
19
|
+
react_1.default.createElement(FooterColumns_1.FooterColumns, { columns: items }),
|
|
20
20
|
react_1.default.createElement(FooterCopyright_1.FooterCopyright, { copyrightText: copyrightText })));
|
|
21
21
|
}
|
|
22
22
|
exports.Footer = Footer;
|
|
@@ -26,24 +26,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.NextButton = void 0;
|
|
30
30
|
const React = __importStar(require("react"));
|
|
31
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
32
|
const hooks_1 = require("../mocks/hooks");
|
|
33
33
|
const Button_1 = require("../Button/Button");
|
|
34
34
|
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
35
|
-
function
|
|
35
|
+
function NextButton() {
|
|
36
36
|
var _a, _b;
|
|
37
37
|
const { nextPage } = (0, hooks_1.useSidebarSiblingsData)() || {};
|
|
38
38
|
const { navigation } = (0, useThemeConfig_1.useThemeConfig)();
|
|
39
|
-
if (!nextPage || ((_a = navigation === null || navigation === void 0 ? void 0 : navigation.
|
|
39
|
+
if (!nextPage || ((_a = navigation === null || navigation === void 0 ? void 0 : navigation.nextButton) === null || _a === void 0 ? void 0 : _a.hide)) {
|
|
40
40
|
return React.createElement("div", null, "\u00A0");
|
|
41
41
|
}
|
|
42
|
-
const
|
|
43
|
-
return (React.createElement(StyledButton, { variant: "outlined", size: "large", to: nextPage.link, "data-component-name": "PageNavigation/NextPageLink" },
|
|
42
|
+
const text = (((_b = navigation === null || navigation === void 0 ? void 0 : navigation.nextButton) === null || _b === void 0 ? void 0 : _b.text) || '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" }, text));
|
|
44
44
|
}
|
|
45
|
-
exports.
|
|
45
|
+
exports.NextButton = NextButton;
|
|
46
46
|
const StyledButton = (0, styled_components_1.default)(Button_1.Button) `
|
|
47
47
|
font-family: var(--font-family-base);
|
|
48
48
|
`;
|
|
49
|
-
//# sourceMappingURL=
|
|
49
|
+
//# sourceMappingURL=NextButton.js.map
|
|
@@ -6,18 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.PageNavigation = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const PreviousButton_1 = require("../PageNavigation/PreviousButton");
|
|
10
|
+
const NextButton_1 = require("../PageNavigation/NextButton");
|
|
11
11
|
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
12
12
|
function PageNavigation() {
|
|
13
13
|
var _a, _b;
|
|
14
14
|
const { navigation } = (0, useThemeConfig_1.useThemeConfig)();
|
|
15
|
-
if (((_a = navigation === null || navigation === void 0 ? void 0 : navigation.
|
|
15
|
+
if (((_a = navigation === null || navigation === void 0 ? void 0 : navigation.previousButton) === null || _a === void 0 ? void 0 : _a.hide) && ((_b = navigation === null || navigation === void 0 ? void 0 : navigation.nextButton) === null || _b === void 0 ? void 0 : _b.hide)) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
18
|
return (react_1.default.createElement(PageNavigationWrapper, { "data-component-name": "PageNavigation/PageNavigation" },
|
|
19
|
-
react_1.default.createElement(
|
|
20
|
-
react_1.default.createElement(
|
|
19
|
+
react_1.default.createElement(PreviousButton_1.PreviousButton, null),
|
|
20
|
+
react_1.default.createElement(NextButton_1.NextButton, null)));
|
|
21
21
|
}
|
|
22
22
|
exports.PageNavigation = PageNavigation;
|
|
23
23
|
const PageNavigationWrapper = styled_components_1.default.div `
|
|
@@ -3,24 +3,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.PreviousButton = 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
10
|
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
11
11
|
const Button_1 = require("../Button/Button");
|
|
12
|
-
function
|
|
12
|
+
function PreviousButton() {
|
|
13
13
|
var _a, _b;
|
|
14
14
|
const { prevPage } = (0, hooks_1.useSidebarSiblingsData)() || {};
|
|
15
15
|
const { navigation } = (0, useThemeConfig_1.useThemeConfig)();
|
|
16
|
-
if (!prevPage || ((_a = navigation === null || navigation === void 0 ? void 0 : navigation.
|
|
16
|
+
if (!prevPage || ((_a = navigation === null || navigation === void 0 ? void 0 : navigation.previousButton) === null || _a === void 0 ? void 0 : _a.hide)) {
|
|
17
17
|
return react_1.default.createElement("div", null, "\u00A0");
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
return (react_1.default.createElement(StyledButton, { variant: "outlined", size: "large", to: prevPage.link, "data-component-name": "PageNavigation/PreviousPageLink" },
|
|
19
|
+
const text = (((_b = navigation === null || navigation === void 0 ? void 0 : navigation.previousButton) === null || _b === void 0 ? void 0 : _b.text) || 'Back to {label}').replace('{label}', prevPage.label || prevPage.routeSlug || '');
|
|
20
|
+
return (react_1.default.createElement(StyledButton, { variant: "outlined", size: "large", to: prevPage.link, "data-component-name": "PageNavigation/PreviousPageLink" }, text));
|
|
21
21
|
}
|
|
22
|
-
exports.
|
|
22
|
+
exports.PreviousButton = PreviousButton;
|
|
23
23
|
const StyledButton = (0, styled_components_1.default)(Button_1.Button) `
|
|
24
24
|
font-family: var(--font-family-base);
|
|
25
25
|
`;
|
|
26
|
-
//# sourceMappingURL=
|
|
26
|
+
//# sourceMappingURL=PreviousButton.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from '../PageNavigation/
|
|
1
|
+
export * from '../PageNavigation/NextButton';
|
|
2
2
|
export * from '../PageNavigation/PageNavigation';
|
|
3
|
-
export * from '../PageNavigation/
|
|
3
|
+
export * from '../PageNavigation/PreviousButton';
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("../PageNavigation/
|
|
17
|
+
__exportStar(require("../PageNavigation/NextButton"), exports);
|
|
18
18
|
__exportStar(require("../PageNavigation/PageNavigation"), exports);
|
|
19
|
-
__exportStar(require("../PageNavigation/
|
|
19
|
+
__exportStar(require("../PageNavigation/PreviousButton"), exports);
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.TableOfContent = void 0;
|
|
30
|
-
const
|
|
30
|
+
const React = __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");
|
|
@@ -35,31 +35,26 @@ const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
|
35
35
|
const utils_1 = require("./utils");
|
|
36
36
|
function TableOfContent(props) {
|
|
37
37
|
const { headings, contentWrapper } = props;
|
|
38
|
-
const sidebar =
|
|
38
|
+
const sidebar = React.useRef(null);
|
|
39
39
|
(0, useFullHeight_1.useFullHeight)(sidebar);
|
|
40
40
|
const { markdown: { toc = {} } = {} } = (0, useThemeConfig_1.useThemeConfig)();
|
|
41
|
-
const displayedHeadings = (0, utils_1.getDisplayedHeadings)(headings, toc.
|
|
41
|
+
const displayedHeadings = (0, utils_1.getDisplayedHeadings)(headings, toc.depth || 3);
|
|
42
42
|
const leastDepth = (0, utils_1.getLeastDepth)(displayedHeadings);
|
|
43
43
|
const activeHeadingId = (0, useActiveHeading_1.useActiveHeading)(contentWrapper, (0, utils_1.getDisplayedHeadingsIds)(displayedHeadings));
|
|
44
44
|
if (toc === null || toc === void 0 ? void 0 : toc.hide) {
|
|
45
45
|
return null;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
const href = '#' + heading.id;
|
|
61
|
-
return (react_1.default.createElement(MenuItem, { key: href + idx, href: href, depth: heading.depth - leastDepth + 1 || 0, className: activeHeadingId === heading.id ? 'active' : '', dangerouslySetInnerHTML: { __html: heading.value || '' }, "data-cy": `toc-${heading.value}` }));
|
|
62
|
-
}))))));
|
|
47
|
+
return (React.createElement(React.Fragment, null,
|
|
48
|
+
React.createElement(TableOfContentMenu, { "data-component-name": "TableOfContent/TableOfContent" },
|
|
49
|
+
React.createElement(TableOfContentItems, { ref: sidebar },
|
|
50
|
+
displayedHeadings.length ? React.createElement(TocHeader, null, toc.header || 'On this page') : null,
|
|
51
|
+
displayedHeadings.map((heading, idx) => {
|
|
52
|
+
if (!heading) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const href = '#' + heading.id;
|
|
56
|
+
return (React.createElement(MenuItem, { key: href + idx, href: href, depth: heading.depth - leastDepth + 1 || 0, className: activeHeadingId === heading.id ? 'active' : '', dangerouslySetInnerHTML: { __html: heading.value || '' }, "data-cy": `toc-${heading.value}` }));
|
|
57
|
+
})))));
|
|
63
58
|
}
|
|
64
59
|
exports.TableOfContent = TableOfContent;
|
|
65
60
|
const TocHeader = styled_components_1.default.div `
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { MdHeading } from '@theme/types/portal';
|
|
2
|
-
export declare function getDisplayedHeadings(headings: Array<MdHeading | null> | null | undefined,
|
|
2
|
+
export declare function getDisplayedHeadings(headings: Array<MdHeading | null> | null | undefined, tocDepth: number): Array<MdHeading | null>;
|
|
3
3
|
export declare function getDisplayedHeadingsIds(headings: Array<MdHeading | null> | null | undefined): Array<string | undefined>;
|
|
4
4
|
export declare function getLeastDepth(headings: Array<MdHeading | null> | null | undefined): number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLeastDepth = exports.getDisplayedHeadingsIds = exports.getDisplayedHeadings = void 0;
|
|
4
|
-
function getDisplayedHeadings(headings,
|
|
4
|
+
function getDisplayedHeadings(headings, tocDepth) {
|
|
5
5
|
if (!headings) {
|
|
6
6
|
return [];
|
|
7
7
|
}
|
|
@@ -12,7 +12,7 @@ function getDisplayedHeadings(headings, tocMaxDepth) {
|
|
|
12
12
|
if (idx === 0 && heading.depth === 1) {
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
|
-
return !(heading.depth && heading.depth >
|
|
15
|
+
return !(heading.depth && heading.depth > tocDepth);
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
exports.getDisplayedHeadings = getDisplayedHeadings;
|