@botonic/react
Version:
Build Chatbots using React
27 lines • 1.26 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { INPUT } from '@botonic/core';
import React from 'react';
import styled from 'styled-components';
import { renderComponent } from '../util/react';
import { Message } from './message';
const Link = styled.a `
text-decoration: none;
font-weight: bold;
target: blank;
`;
const serialize = locationProps => {
return { location: { lat: locationProps.lat, long: locationProps.long } };
};
export const Location = props => {
const { lat, long } = props;
const renderBrowser = () => {
const locationUrl = `https://www.google.com/maps/search/?api=1&query=${lat},${long}`;
return (_jsx(Message, Object.assign({ json: serialize(props) }, props, { type: INPUT.LOCATION }, { children: _jsx(Link, Object.assign({ href: locationUrl, target: '_blank', rel: 'noopener noreferrer' }, { children: props.text || 'Open Location' })) })));
};
const renderNode = () => {
return (_jsxs("message", Object.assign({ type: INPUT.LOCATION }, { children: [_jsx("lat", { children: lat }), _jsx("long", { children: long })] })));
};
return renderComponent({ renderBrowser, renderNode });
};
Location.serialize = serialize;
//# sourceMappingURL=location.js.map