UNPKG

@botonic/react

Version:

Build Chatbots using React

19 lines 1.35 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { useContext } from 'react'; import { WEBCHAT } from '../../constants'; import { SENDERS } from '../../index-types'; import { resolveImage } from '../../util/environment'; import { WebchatContext } from '../../webchat/context'; import { BotMessageImageContainer } from './styles'; export const MessageImage = ({ imagestyle, sentBy }) => { const { getThemeProperty } = useContext(WebchatContext); const isSentByAgent = sentBy === SENDERS.agent; const isSentByUser = sentBy === SENDERS.user; const timestampsWithImage = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.messageTimestampsWithImage); const BotMessageImage = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.botMessageImage, getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.brandImage)); const AgentMessageImage = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.agentMessageImage, BotMessageImage); return (!timestampsWithImage && !isSentByUser && BotMessageImage && (_jsx(BotMessageImageContainer, Object.assign({ style: Object.assign(Object.assign({}, getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.botMessageImageStyle)), imagestyle) }, { children: _jsx("img", { style: { width: '100%' }, src: resolveImage(isSentByAgent ? AgentMessageImage : BotMessageImage) }) })))); }; //# sourceMappingURL=message-image.js.map