-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MapDialog, ViewOnMapButton components and map view to checkout page
- Loading branch information
Showing
11 changed files
with
190 additions
and
98 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,78 @@ | ||
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 movininTypes from ':movinin-types' | ||
import env from '@/config/env.config' | ||
import Map from '@/components/Map' | ||
|
||
import '@/assets/css/map-dialog.css' | ||
|
||
interface MapDialogProps { | ||
location?: movininTypes.Location | ||
openMapDialog: boolean | ||
onClose: () => void | ||
} | ||
|
||
const MapDialog = ({ | ||
location, | ||
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"> | ||
{location && ( | ||
<Map | ||
position={[location.latitude || 36.966428, location.longitude || -95.844032]} | ||
initialZoom={location.latitude && location.longitude ? 10 : 2.5} | ||
locations={[location]} | ||
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,14 @@ | ||
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', | ||
}, | ||
}) | ||
|
||
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
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