@botonic/react
Version:
Build Chatbots using React
25 lines • 2.27 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultHeader = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const constants_1 = require("../../constants");
const styles_1 = require("../../shared/styles");
const environment_1 = require("../../util/environment");
const react_2 = require("../../util/react");
const context_1 = require("../../webchat/context");
const styles_2 = require("./styles");
const DefaultHeader = () => {
const { getThemeProperty, toggleWebchat } = (0, react_1.useContext)(context_1.WebchatContext);
const animationsEnabled = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.enableAnimations);
const headerImage = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.headerImage, getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.brandImage));
const headerTitle = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.headerTitle);
const headerSubtitle = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.headerSubtitle);
const handleCloseWebchat = () => {
toggleWebchat(false);
};
const color = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.brandColor);
return ((0, jsx_runtime_1.jsxs)(styles_2.HeaderContainer, Object.assign({ role: constants_1.ROLES.HEADER, color: color, style: Object.assign({}, getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.headerStyle)) }, { children: [headerImage && ((0, jsx_runtime_1.jsx)(styles_2.ImageContainer, { children: (0, jsx_runtime_1.jsx)("img", { src: (0, environment_1.resolveImage)(headerImage) }) })), (0, jsx_runtime_1.jsxs)(styles_2.TextContainer, { children: [(0, jsx_runtime_1.jsx)(styles_2.Title, { children: headerTitle }), headerSubtitle ? (0, jsx_runtime_1.jsx)(styles_2.Subtitle, { children: headerSubtitle }) : null] }), (0, jsx_runtime_1.jsx)(react_2.ConditionalWrapper, Object.assign({ condition: animationsEnabled, wrapper: children => (0, jsx_runtime_1.jsx)(styles_1.Scale, { children: children }) }, { children: (0, jsx_runtime_1.jsx)(styles_2.CloseHeader, Object.assign({ onClick: handleCloseWebchat }, { children: "\u2A2F" })) }))] })));
};
exports.DefaultHeader = DefaultHeader;
//# sourceMappingURL=default-header.js.map
;