@redocly/theme
Version:
Shared UI components lib
27 lines • 2.3 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PreviousButton = PreviousButton;
const react_1 = __importDefault(require("react"));
const NavigationButton_1 = require("../../components/PageNavigation/NavigationButton");
const hooks_1 = require("../../core/hooks");
const ArrowLeftIcon_1 = require("../../icons/ArrowLeftIcon/ArrowLeftIcon");
function PreviousButton({ prevPage, className }) {
var _a, _b, _c, _d, _e, _f;
const { navigation } = (0, hooks_1.useThemeConfig)();
const { useTranslate, usePageProps } = (0, hooks_1.useThemeHooks)();
const { frontmatter } = usePageProps();
const { translate } = useTranslate();
const translationKey = 'page.previousButton';
const label = ((_b = (_a = frontmatter === null || frontmatter === void 0 ? void 0 : frontmatter.navigation) === null || _a === void 0 ? void 0 : _a.previousButton) === null || _b === void 0 ? void 0 : _b.label) || (prevPage === null || prevPage === void 0 ? void 0 : prevPage.label) || (prevPage === null || prevPage === void 0 ? void 0 : prevPage.routeSlug) || '';
const link = ((_d = (_c = frontmatter === null || frontmatter === void 0 ? void 0 : frontmatter.navigation) === null || _c === void 0 ? void 0 : _c.previousButton) === null || _d === void 0 ? void 0 : _d.link) || (prevPage === null || prevPage === void 0 ? void 0 : prevPage.link);
const text = ((_e = navigation === null || navigation === void 0 ? void 0 : navigation.previousButton) === null || _e === void 0 ? void 0 : _e.text) ||
translate(translationKey, { defaultValue: 'Previous page' });
if (((_f = navigation === null || navigation === void 0 ? void 0 : navigation.previousButton) === null || _f === void 0 ? void 0 : _f.hide) || !link || !label) {
return react_1.default.createElement("div", null, "\u00A0");
}
return (react_1.default.createElement(NavigationButton_1.NavigationButton, { label: label, link: link, text: text, translationKey: translationKey, position: "left", className: className, icon: react_1.default.createElement(ArrowLeftIcon_1.ArrowLeftIcon, null) }));
}
//# sourceMappingURL=PreviousButton.js.map