-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #657 from GeotrekCE/develop
Develop > Main / 3.8.3
- Loading branch information
Showing
61 changed files
with
800 additions
and
256 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
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
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,27 @@ | ||
import React from 'react'; | ||
import { GenericIconProps } from '../types'; | ||
|
||
export const Signage: React.FC<GenericIconProps> = ({ | ||
color = 'currentColor', | ||
opacity, | ||
className, | ||
size, | ||
}) => { | ||
return ( | ||
<svg | ||
width={size} | ||
height={size} | ||
viewBox="0 0 25 25" | ||
xmlns="http://www.w3.org/2000/svg" | ||
className={className} | ||
opacity={opacity} | ||
> | ||
<path | ||
d="M4.6,12.4L2,15.2l2.6,2.9h6.3v6.2H8.7V25h8.6v-0.7h-2.2v-6.2H23l0-5.7H15V9.7H23l0-5.7H15V0h-4.1v3.9H4.6L2,6.8l2.6,2.9 | ||
l6.3,0v2.7L4.6,12.4z M14.3,24.3h-2.7v-6.2h2.7V24.3z M11.6,0.7h2.7v3.2h-2.7V0.7z M4.9,8.9L3,6.8l1.9-2.1h17.3v4.3H4.9z M14.3,9.7 | ||
v2.7h-2.7V9.7H14.3z M22.2,13.1v4.3H4.9L3,15.2l1.9-2.1L22.2,13.1z" | ||
stroke={color} | ||
/> | ||
</svg> | ||
); | ||
}; |
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
110 changes: 110 additions & 0 deletions
110
frontend/src/components/Map/DetailsMap/PointsSignage.tsx
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,110 @@ | ||
import React, { useMemo } from 'react'; | ||
import { Tooltip } from 'react-leaflet'; | ||
import { Signage } from 'components/Icons/Signage'; | ||
import { renderToStaticMarkup } from 'react-dom/server'; | ||
import { SignageDictionary } from 'modules/signage/interface'; | ||
import styled, { css } from 'styled-components'; | ||
import { desktopOnly, getSpacing } from 'stylesheet'; | ||
import { textEllipsisAfterNLines } from 'services/cssHelpers'; | ||
import { RawCoordinate2D } from 'modules/interface'; | ||
import { HoverableMarker } from '../components/HoverableMarker'; | ||
|
||
export type PointsSignageProps = { | ||
signage?: SignageDictionary | null; | ||
}; | ||
|
||
type Locations = { | ||
description: string; | ||
name: string; | ||
imageUrl: string | undefined; | ||
pictogramUri: string; | ||
position: RawCoordinate2D; | ||
type: string; | ||
}[]; | ||
|
||
export const PointsSignage: React.FC<PointsSignageProps> = ({ signage }) => { | ||
const locations: Locations = useMemo(() => { | ||
return Object.values(signage ?? {}) | ||
.filter(({ geometry }) => Boolean(geometry?.coordinates)) | ||
.map(({ description, geometry, name, type, imageUrl }) => ({ | ||
description, | ||
imageUrl, | ||
name, | ||
pictogramUri: type.pictogram ?? renderToStaticMarkup(<Signage color="white" />), | ||
position: [geometry.coordinates[1], geometry.coordinates[0]], | ||
type: type.label, | ||
})); | ||
}, []); | ||
|
||
if (locations.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
{locations.map((location, index: number) => ( | ||
<HoverableMarker | ||
id={location.position.join('')} | ||
key={index} | ||
position={location.position} | ||
pictogramUri={location.pictogramUri} | ||
type={null} | ||
> | ||
<StyledTooltip> | ||
<div className="flex flex-col"> | ||
{location.imageUrl !== undefined && <CoverImage src={location.imageUrl} alt="" />} | ||
<div className="p-4"> | ||
<div className="text-P2 mb-1 text-greyDarkColored">{location.type}</div> | ||
<Name className="text-Mobile-C1 text-primary1 font-bold desktop:text-H4"> | ||
{location.name} | ||
</Name> | ||
<p | ||
className="text-P2 mb-1" | ||
dangerouslySetInnerHTML={{ | ||
__html: location.description, | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
</StyledTooltip> | ||
</HoverableMarker> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
const desktopWidth = 288; | ||
const desktopImgHeight = 122; | ||
const mobileWidth = 215; | ||
const mobileImgHeight = 133; | ||
|
||
const StyledTooltip = styled(Tooltip)` | ||
padding: 0; | ||
border: 0px !important; | ||
border-radius: ${getSpacing(4)} !important; | ||
overflow: hidden; | ||
white-space: initial !important; | ||
width: ${mobileWidth}px; | ||
${desktopOnly(css` | ||
width: ${desktopWidth}px; | ||
`)}; | ||
`; | ||
|
||
const Name = styled.span` | ||
${textEllipsisAfterNLines(2)} | ||
${desktopOnly(css` | ||
white-space: nowrap; | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
display: block; | ||
`)} | ||
`; | ||
|
||
const CoverImage = styled.img` | ||
height: ${mobileImgHeight}px; | ||
${desktopOnly(css` | ||
height: ${desktopImgHeight}px; | ||
`)} | ||
object-fit: cover; | ||
`; |
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
Oops, something went wrong.