Skip to content

Commit

Permalink
Merge pull request #657 from GeotrekCE/develop
Browse files Browse the repository at this point in the history
Develop > Main / 3.8.3
  • Loading branch information
camillemonchicourt authored May 24, 2022
2 parents ac519a2 + cdf4f66 commit 0f7fd95
Show file tree
Hide file tree
Showing 61 changed files with 800 additions and 256 deletions.
19 changes: 16 additions & 3 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
# Changelog

3.8.3 (2022-05-24)
------------------

**🚀 New features**

* Add published signages on treks and outdoor maps (#408)
* Add ``groupTreksAndOutdoorFilters`` setting to be able to group Treks and Outdoor filters on search page (#656)

**🐛 Fixes**

* Fix flickering of Outdoor, services and events maps
* Refactoring and improvements of anchor system in detail pages

3.8.2 (2022-04-25)
------------------

**🐛 Fixes**

- Fix HTML interpretation of new "Accessibility" fields (#536 / #638)
- Don't display label filter (Others) in trek filters if no label defined as filter (#418)
- Improve outdoor subobjects display on site maps with adding it in layer control (#542)
* Fix HTML interpretation of new "Accessibility" fields (#536 / #638)
* Don't display label filter (Others) in trek filters if no label defined as filter (#418)
* Improve outdoor subobjects display on site maps with adding it in layer control (#542)

3.8.1 (2022-04-25)
------------------
Expand Down
7 changes: 5 additions & 2 deletions docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ In json files, you can just override the primary keys you need. You have to over
- `maxTouristicContentPerPage`: max number of touristic contents displayed on a single trek page
- `portalIds`: eventual portal filters (list of ids).
- `enableSensitiveAreas`: boolean, default to false. Set it to true if sensitive areas are defined in your Geotrek-admin
- `enableOutdoor`: : boolean, default to false. Set it to true to enable Outdoor sites and courses
- `enableOutdoor`: boolean, default to false. Set it to true to enable Outdoor sites and courses
- `groupTreksAndOutdoorFilters`: boolean, default to false. Groups treks and outdoor filters into a single tab. For this setting to work, `enableOutdoor` must be set to `true`.
- `apiUrl` : Geotrek-admin API URL
- `googleAnalyticsId`: eventual Google Analytics Id
- `googleSiteVerificationToken`: eventual code to enable Google Search Console and Google developer tools
Expand Down Expand Up @@ -135,6 +136,8 @@ It's also possible to change category colors :
}
```

NB: If global config `groupTreksAndOutdoorFilters` is set to `true`, the `outdoor` color is ignored in favor of the `trek` color.

You can also override CSS in `customization/theme/style.css` file. To help overriding CSS, some ID have been added on main DIV components (header, logo, footer, cover, cards, results, maps, details...).

## Translations
Expand All @@ -157,7 +160,7 @@ You can include some HTML parts in different sections of the layout application,
These templates can be translated by using the language code as a suffix (e.g. `homeTop-en.html` will be rendered only for the English interface). The application tries to find the localized template first, otherwise it tries the non-localized template, otherwise it displays nothing.
NB: If you want to display a message common to all languages but not to a particular language (e.g. french), just create the template suffixed with its language code (e.g. `-fr.html`) and leave it empty, and voilà!

You can also include some scripts:
You can also include some scripts:
- `customization/html/scriptsHeader.html`: in the `<head>` of the document
- `customization/html/scriptsFooter.html`: just before the `</body>` end tag

Expand Down
3 changes: 2 additions & 1 deletion frontend/config/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"enableMeteoWidget": true,
"maxLengthTrekAllowedFor3DRando": 25000,
"minAltitudeDifferenceToDisplayElevationProfile": 0,
"accessibilityCodeNumber": "114"
"accessibilityCodeNumber": "114",
"groupTreksAndOutdoorFilters": false
}
2 changes: 1 addition & 1 deletion frontend/customization/html/homeTop.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Example of main content suggestion -->
<div class="home_card"
style="height: 265px;background-image: linear-gradient( 180deg,transparent 0%,#27041970 100% ),url(/medias/trek-selection.jpg); background-size: cover;background-position: center; padding:40px; border-radius: 20px;justify-content: space-between; align-items: flex-start;display: flex;flex-direction: column;">
style="min-height: 265px;background-image: linear-gradient( 180deg,transparent 0%,#27041970 100% ),url(/medias/trek-selection.jpg); background-size: cover;background-position: center; padding:40px; border-radius: 20px;justify-content: space-between; align-items: flex-start;display: flex;flex-direction: column;">
<div
style="background-color: #F5E7EF;padding: 4px 8px; border-radius: 20px; color: #791150; font-size: 16px; line-height: 21px;">
<span>Sélectionné par le Parc national des Écrins</span>
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "geotrek-rando-frontend",
"version": "3.8.2",
"version": "3.8.3",
"private": true,
"scripts": {
"debug": "NODE_OPTIONS='--inspect' next ./src",
Expand Down
27 changes: 27 additions & 0 deletions frontend/src/components/Icons/Signage/index.tsx
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>
);
};
8 changes: 8 additions & 0 deletions frontend/src/components/Map/DetailsMap/DetailsMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { useDetailsAndMapContext } from 'components/pages/details/DetailsAndMapC
import { Check } from 'components/Icons/Check';
import { FormattedMessage } from 'react-intl';
import { InformationDesk } from 'modules/informationDesk/interface';
import { SignageDictionary } from 'modules/signage/interface';
import { BackButton } from '../components/BackButton';

import { TrekMarkersAndCourse } from './TrekMarkersAndCourse';
Expand Down Expand Up @@ -79,6 +80,7 @@ export type PropsType = {
title?: string;
displayAltimetricProfile?: boolean;
informationDesks?: InformationDesk[];
signage?: SignageDictionary | null;
};
export const DetailsMap: React.FC<PropsType> = props => {
const { reportVisibility, setReportVisibility } = useDetailsAndMapContext();
Expand All @@ -105,6 +107,8 @@ export const DetailsMap: React.FC<PropsType> = props => {
toggleCoursesVisibility,
experiencesVisibility,
toggleExperiencesVisibility,
signageVisibility,
toggleSignageVisibility,
} = useDetailsMap();
const mapConfig = getMapConfig();

Expand Down Expand Up @@ -189,13 +193,15 @@ export const DetailsMap: React.FC<PropsType> = props => {
}
coursesVisibility={props.courses ? coursesVisibility : null}
experiencesVisibility={props.experiences ? experiencesVisibility : null}
signageVisibility={props.signage ? signageVisibility : null}
toggleTrekChildrenVisibility={toggleTrekChildrenVisibility}
togglePoiVisibility={togglePoiVisibility}
toggleReferencePointsVisibility={toggleReferencePointsVisibility}
toggleTouristicContentVisibility={toggleTouristicContentVisibility}
toggleInformationDeskVisibility={toggleInformationDeskVisibility}
toggleCoursesVisibility={toggleCoursesVisibility}
toggleExperiencesVisibility={toggleExperiencesVisibility}
toggleSignageVisibility={toggleSignageVisibility}
/>
{props.trekGeometry && (
<TrekMarkersAndCourse
Expand All @@ -219,6 +225,7 @@ export const DetailsMap: React.FC<PropsType> = props => {
pointsReference={props.pointsReference}
trekChildrenGeometry={props.trekChildrenGeometry}
sensitiveAreasGeometry={props.sensitiveAreas}
signage={props.signage}
trekChildrenMobileVisibility={trekChildrenMobileVisibility}
poiMobileVisibility={poiMobileVisibility}
referencePointsMobileVisibility={referencePointsMobileVisibility}
Expand All @@ -228,6 +235,7 @@ export const DetailsMap: React.FC<PropsType> = props => {
coursesVisibility={coursesVisibility}
experiencesVisibility={experiencesVisibility}
informationDesks={props.informationDesks}
signageVisibility={signageVisibility}
/>
{props.displayAltimetricProfile === true && props.trekGeoJSON && (
<AltimetricProfile id="altimetric-profile" trekGeoJSON={props.trekGeoJSON} />
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/components/Map/DetailsMap/MapChildren.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { InformationDesk } from 'modules/informationDesk/interface';
import { Coordinate2D } from 'modules/interface';
import { OutdoorSite } from 'modules/outdoorSite/interface';
import { SensitiveAreaGeometry } from 'modules/sensitiveArea/interface';
import { SignageDictionary } from 'modules/signage/interface';
import React, { useContext } from 'react';
import { useMediaPredicate } from 'react-media-hook';
import { TouristicContentGeometry } from './DetailsMap';
Expand All @@ -12,6 +13,7 @@ import { MarkersWithIcon } from './MarkersWithIcon';
import { PointReport } from './PointReport';
import { PointsInformationDesk } from './PointsInformationDesk';
import { PointsReference } from './PointsReference';
import { PointsSignage } from './PointsSignage';
import { SensitiveAreas } from './SensitiveAreas';
import { TouristicContent } from './TouristicContent';
import { TrekChildren } from './TrekChildren';
Expand Down Expand Up @@ -42,6 +44,8 @@ type Props = {
parentId?: number;
informationDeskMobileVisibility: Visibility;
informationDesks?: InformationDesk[];
signageVisibility: Visibility;
signage?: SignageDictionary | null;
};

export const MapChildren: React.FC<Props> = props => {
Expand Down Expand Up @@ -103,6 +107,8 @@ export const MapChildren: React.FC<Props> = props => {
<PointsInformationDesk informationDesks={props.informationDesks} />
)}

{props.signageVisibility === 'DISPLAYED' && <PointsSignage signage={props.signage} />}

{(isMobile || visibleSection === 'report') && props.reportVisibility && <PointReport />}
</>
);
Expand Down
110 changes: 110 additions & 0 deletions frontend/src/components/Map/DetailsMap/PointsSignage.tsx
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;
`;
17 changes: 9 additions & 8 deletions frontend/src/components/Map/DetailsMap/TouristicContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Popup } from 'components/Map/components/Popup';
import React from 'react';
import React, { Fragment } from 'react';
import 'leaflet/dist/leaflet.css';
import { TouristicContentGeometry } from './DetailsMap';
import { HoverableMarker } from '../components/HoverableMarker';
Expand All @@ -23,12 +23,13 @@ export const TouristicContent: React.FC<PropsType> = ({ contents, type = 'TOURIS
case 'Point':
case 'MultiPoint':
return (
<>
<Fragment key={id}>
{(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates).map(
coordinates =>
pictogramUri ? (
<HoverableMarker
id={`${id}${JSON.stringify(coordinates)}`}
key={`${id}${JSON.stringify(coordinates)}`}
id={id}
position={[coordinates.y, coordinates.x]}
pictogramUri={pictogramUri}
type={type}
Expand All @@ -37,13 +38,13 @@ export const TouristicContent: React.FC<PropsType> = ({ contents, type = 'TOURIS
</HoverableMarker>
) : null,
)}
</>
</Fragment>
);

case 'LineString':
case 'MultiLineString':
return (
<>
<Fragment key={id}>
{(geometry.type === 'LineString'
? [geometry.coordinates]
: geometry.coordinates
Expand All @@ -54,13 +55,13 @@ export const TouristicContent: React.FC<PropsType> = ({ contents, type = 'TOURIS
positions={group.map(point => [point.y, point.x])}
/>
))}
</>
</Fragment>
);

case 'Polygon':
case 'MultiPolygon':
return (
<>
<Fragment key={id}>
{(geometry.type === 'Polygon'
? [geometry.coordinates]
: geometry.coordinates
Expand All @@ -73,7 +74,7 @@ export const TouristicContent: React.FC<PropsType> = ({ contents, type = 'TOURIS
)}
/>
))}
</>
</Fragment>
);

default:
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/Map/DetailsMap/useDetailsMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const useDetailsMap = () => {

const [coursesVisibility, setCoursesVisibility] = useState<Visibility>('HIDDEN');
const [experiencesVisibility, setExperiencesVisibility] = useState<Visibility>('HIDDEN');
const [signageVisibility, setSignageVisibility] = useState<Visibility>('HIDDEN');

const toggleTrekChildrenVisibility = () => setTrekChildrenVisibility(toggleVisibility);

Expand All @@ -31,6 +32,7 @@ export const useDetailsMap = () => {

const toggleExperiencesVisibility = () => setExperiencesVisibility(toggleVisibility);
const toggleCoursesVisibility = () => setCoursesVisibility(toggleVisibility);
const toggleSignageVisibility = () => setSignageVisibility(toggleVisibility);

return {
trekChildrenMobileVisibility,
Expand All @@ -47,5 +49,7 @@ export const useDetailsMap = () => {
toggleCoursesVisibility,
experiencesVisibility,
toggleExperiencesVisibility,
signageVisibility,
toggleSignageVisibility,
};
};
Loading

0 comments on commit 0f7fd95

Please sign in to comment.