-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MapDialog and ViewOnMapButton components
- Loading branch information
Showing
11 changed files
with
191 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.map-dialog { | ||
width: 90%; | ||
height: 90%; | ||
} | ||
|
||
.map-dialog-content { | ||
margin: 0; | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.view-on-map { | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
z-index: 10000; | ||
/* background-color: #062638; */ | ||
background-color: #1a1a1a; | ||
color: #fff; | ||
border: 0; | ||
padding: 5px 10px; | ||
display: flex; | ||
flex-direction: row; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} | ||
|
||
.view-on-map img { | ||
max-width: 20px; | ||
max-height: 20px; | ||
margin-right: 2px; | ||
} | ||
|
||
.view-on-map span { | ||
margin-top: 2px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { useCallback, useEffect, useState } from 'react' | ||
import { Box, Dialog, DialogContent, DialogTitle, IconButton } from '@mui/material' | ||
import { Close as CloseIcon } from '@mui/icons-material' | ||
import * as bookcarsTypes from ':bookcars-types' | ||
import env from '@/config/env.config' | ||
import Map from '@/components/Map' | ||
|
||
import '@/assets/css/map-dialog.css' | ||
|
||
interface MapDialogProps { | ||
pickupLocation?: bookcarsTypes.Location | ||
openMapDialog: boolean | ||
onClose: () => void | ||
} | ||
|
||
const MapDialog = ({ | ||
pickupLocation, | ||
openMapDialog: openMapDialogProp, | ||
onClose, | ||
}: MapDialogProps) => { | ||
const [openMapDialog, setOpenMapDialog] = useState(openMapDialogProp) | ||
|
||
useEffect(() => { | ||
setOpenMapDialog(openMapDialogProp) | ||
}, [openMapDialogProp]) | ||
|
||
const close = useCallback(() => { | ||
setOpenMapDialog(false) | ||
if (onClose) { | ||
onClose() | ||
} | ||
}, [onClose]) | ||
|
||
return ( | ||
<Dialog | ||
fullWidth={env.isMobile} | ||
maxWidth={false} | ||
open={openMapDialog} | ||
onClose={() => { | ||
close() | ||
}} | ||
sx={{ | ||
'& .MuiDialog-container': { | ||
'& .MuiPaper-root': { | ||
width: '90%', | ||
height: '90%', | ||
}, | ||
}, | ||
}} | ||
> | ||
<DialogTitle> | ||
<Box display="flex" justifyContent="flex-end"> | ||
<Box> | ||
<IconButton | ||
onClick={() => { | ||
close() | ||
}} | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
</Box> | ||
</Box> | ||
</DialogTitle> | ||
<DialogContent className="map-dialog-content"> | ||
{pickupLocation && ( | ||
<Map | ||
position={[pickupLocation.latitude || 36.191113, pickupLocation.longitude || 44.009167]} | ||
initialZoom={pickupLocation.latitude && pickupLocation.longitude ? 10 : 2.5} | ||
locations={[pickupLocation]} | ||
parkingSpots={pickupLocation.parkingSpots} | ||
className="map" | ||
/> | ||
)} | ||
</DialogContent> | ||
</Dialog> | ||
) | ||
} | ||
|
||
export default MapDialog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react' | ||
import { strings } from '@/lang/view-on-map-button' | ||
|
||
import ViewOnMap from '@/assets/img/view-on-map.png' | ||
|
||
import '@/assets/css/view-on-map-button.css' | ||
|
||
interface ViewOnMapButtonProps { | ||
onClick: (e?: React.MouseEvent<HTMLButtonElement>) => void | ||
} | ||
|
||
const ViewOnMapButton = ({ onClick }: ViewOnMapButtonProps) => ( | ||
<button | ||
type="button" | ||
onClick={onClick} | ||
className="view-on-map" | ||
> | ||
<img alt="View On Map" src={ViewOnMap} /> | ||
<span>{strings.VIEW_ON_MAP}</span> | ||
</button> | ||
) | ||
|
||
export default ViewOnMapButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import LocalizedStrings from 'localized-strings' | ||
import * as langHelper from '@/common/langHelper' | ||
|
||
const strings = new LocalizedStrings({ | ||
fr: { | ||
VIEW_ON_MAP: 'Voir sur la carte', | ||
}, | ||
en: { | ||
VIEW_ON_MAP: 'View on map', | ||
}, | ||
es: { | ||
VIEW_ON_MAP: 'Ver en el mapa', | ||
}, | ||
}) | ||
|
||
langHelper.setLanguage(strings) | ||
export { strings } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.