@botonic/react
Version:
Build Chatbots using React
32 lines • 1.63 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Location = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const core_1 = require("@botonic/core");
const react_1 = tslib_1.__importDefault(require("react"));
const styled_components_1 = tslib_1.__importDefault(require("styled-components"));
const react_2 = require("../util/react");
const message_1 = require("./message");
const Link = styled_components_1.default.a `
text-decoration: none;
font-weight: bold;
target: blank;
`;
const serialize = locationProps => {
return { location: { lat: locationProps.lat, long: locationProps.long } };
};
const Location = props => {
const { lat, long } = props;
const renderBrowser = () => {
const locationUrl = `https://www.google.com/maps/search/?api=1&query=${lat},${long}`;
return ((0, jsx_runtime_1.jsx)(message_1.Message, Object.assign({ json: serialize(props) }, props, { type: core_1.INPUT.LOCATION }, { children: (0, jsx_runtime_1.jsx)(Link, Object.assign({ href: locationUrl, target: '_blank', rel: 'noopener noreferrer' }, { children: props.text || 'Open Location' })) })));
};
const renderNode = () => {
return ((0, jsx_runtime_1.jsxs)("message", Object.assign({ type: core_1.INPUT.LOCATION }, { children: [(0, jsx_runtime_1.jsx)("lat", { children: lat }), (0, jsx_runtime_1.jsx)("long", { children: long })] })));
};
return (0, react_2.renderComponent)({ renderBrowser, renderNode });
};
exports.Location = Location;
exports.Location.serialize = serialize;
//# sourceMappingURL=location.js.map
;