UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

26 lines (25 loc) 1.92 kB
import { CloseIcon } from '../icons'; import React from 'react'; import { useTranslationContext } from '../../../context'; import { GeolocationIcon } from '../../Attachment/icons'; const GeolocationPreviewImage = () => (React.createElement("div", { className: 'str-chat__location-preview-image' }, React.createElement(GeolocationIcon, null))); export const GeolocationPreview = ({ location, PreviewImage = GeolocationPreviewImage, remove, }) => { const { t } = useTranslationContext(); return (React.createElement("div", { className: 'str-chat__location-preview', "data-testid": 'location-preview' }, React.createElement(PreviewImage, { location: location }), remove && (React.createElement("button", { "aria-label": t('aria/Remove location attachment'), className: 'str-chat__attachment-preview-delete', "data-testid": 'location-preview-item-delete-button', onClick: remove }, React.createElement(CloseIcon, null))), React.createElement("div", { className: 'str-chat__attachment-preview-metadata' }, location.durationMs ? (React.createElement(React.Fragment, null, React.createElement("div", { className: 'str-chat__attachment-preview-title', title: t('Shared live location') }, t('Live location')), React.createElement("div", { className: 'str-chat__attachment-preview-subtitle' }, t('Live for {{duration}}', { duration: t('duration/Share Location', { milliseconds: location.durationMs, }), })))) : (React.createElement(React.Fragment, null, React.createElement("div", { className: 'str-chat__attachment-preview-title', title: t('Current location') }, t('Current location')), React.createElement("div", { className: 'str-chat__attachment-preview-subtitle' }, location.latitude, ", ", location.longitude)))))); };