@botonic/react
Version:
Build Chatbots using React
21 lines • 1.02 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { INPUT, isBrowser } from '@botonic/core';
import styled from 'styled-components';
import { ROLES } from '../constants';
import { staticAsset } from '../util/environment';
import { Message } from './message';
const StyledAudio = styled.audio `
max-width: 100%;
`;
const serialize = (audioProps) => {
return { audio: audioProps.src };
};
export const Audio = (props) => {
props = Object.assign(Object.assign({}, props), { src: staticAsset(props.src) });
let content = props.children;
if (isBrowser())
content = (_jsxs(StyledAudio, Object.assign({ id: 'myAudio', controls: true }, { children: [_jsx("source", { src: props.src, type: 'audio/mpeg' }), "Your browser does not support this audio format."] })));
return (_jsx(Message, Object.assign({ role: ROLES.AUDIO_MESSAGE, json: serialize(props) }, props, { type: INPUT.AUDIO }, { children: content })));
};
Audio.serialize = serialize;
//# sourceMappingURL=audio.js.map