@redocly/theme
Version:
Shared UI components lib
45 lines (44 loc) • 2.13 kB
JavaScript
;
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logo = Logo;
const react_1 = __importDefault(require("react"));
const styled_components_1 = __importDefault(require("styled-components"));
const hooks_1 = require("../../core/hooks");
const Link_1 = require("../../components/Link/Link");
const Image_1 = require("../../components/Image/Image");
function Logo(_a) {
var { config, className } = _a, otherProps = __rest(_a, ["config", "className"]);
const { useTelemetry } = (0, hooks_1.useThemeHooks)();
const telemetry = useTelemetry();
if (!(config === null || config === void 0 ? void 0 : config.image) && !(config === null || config === void 0 ? void 0 : config.srcSet)) {
return null;
}
const image = (react_1.default.createElement(Image_1.Image, { className: className, src: config.image, srcSet: config.srcSet, alt: config.altText }));
return (react_1.default.createElement(LogoWrapper, Object.assign({ "data-component-name": "Logo/Logo", className: className }, otherProps), config.link ? (react_1.default.createElement(Link_1.Link, { to: config.link, onClick: () => telemetry.sendLogoClickedMessage() }, image)) : (image)));
}
const LogoWrapper = styled_components_1.default.div `
max-width: var(--logo-max-width);
max-height: var(--logo-max-height);
height: var(--logo-height);
margin: var(--logo-margin);
img {
max-width: 100%;
max-height: 100%;
height: 100%;
}
`;
//# sourceMappingURL=Logo.js.map