Skip to content

Commit

Permalink
Merge pull request #627 from GeotrekCE/develop
Browse files Browse the repository at this point in the history
Develop > Master / 3.8.0
  • Loading branch information
camillemonchicourt authored Apr 8, 2022
2 parents ff3015a + 9a7b535 commit 7f7d2f6
Show file tree
Hide file tree
Showing 96 changed files with 1,957 additions and 532 deletions.
22 changes: 22 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

3.8.0 (2022-04-08)
------------------

**🚀 New features**

* Filter treks by labels (#418)
* Allow to hide elevation profile on small elevation treks, with new ``minAltitudeDifferenceToDisplayElevationProfile`` setting (#552)
* Display negative elevation on trek pages (#574)
* Add new accessibility fields on trek, outdoor and services detail pages (#536)
* Improve report forms design with location on map and photos (#453)
* Improve outdoor pages detail pages with displaying subobjects on map (#542)
* Allow to translate HTML templates in Homepage (#617)
* Improve anchor system in detail pages
* Improve translations

**🐛 Fixes**

* Fix flickering of the map when loading the detail pages
* Fix reservation widget loading on trek detail pages
* Fix multiple geometries display on maps

3.7.0 (2022-03-11)
------------------

Expand All @@ -8,6 +29,7 @@
* Include 3D view in trek detail pages (#390)
* Add ``maxLengthTrekAllowedFor3DRando`` setting to define the maximum length of a trek to enable the 3D view on its page (or to disable 3D view) (#390)
* Add breadcrumb on detail and information pages (#506)
* Add Meteo France widget on all detail pages based on INSEE code of the content (#525)
* Add Open System reservation widget on trek detail pages with an ``id_reservation`` (#382)
* Add ``reservationPartner`` and ``reservationProject`` settings to enable Open System reservation widget (#382)
* Add a customizable color for each content category (treks, outdoor sites, services and events) to better differentiate content categories (#437)
Expand Down
4 changes: 4 additions & 0 deletions docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ In json files, you can just override the primary keys you need. You have to over
- `enableReport`: to enable report form in trek detail pages
- `enableSearchByMap`: to enable searching by map displayed area (bbox)
- `maxLengthTrekAllowedFor3DRando`: Maximum length of meters allowed to enable 3D mode in the current trek. Adjust this setting carefully as too long a trek could freeze your browser. If this setting is defined to `0` (or `mapSatelliteLayerUrl` from `map.json` is not set) the 3D mode feature is disabled for the whole application
- `minAltitudeDifferenceToDisplayElevationProfile`: Minimum altitude difference in meters required to display the elevation profile in the current trek

- `header.json` to define logo URL, default and available languages, number items to flatpages to display in navbar (see default values in https://github.com/GeotrekCE/Geotrek-rando-v3/blob/main/frontend/config/header.json)

Expand Down Expand Up @@ -149,6 +150,9 @@ You can include some HTML parts in the first and last sections of the homepage,
- `customization/html/homeTop.html`
- `customization/html/homeBottom.html`

You can also internationalize these templates 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à!

See HTML examples in https://github.com/GeotrekCE/Geotrek-rando-v3/tree/main/frontend/customization/html.

Icons are provided by Geotrek-admin API. See [icons documentation](icons.md) to know how they have to be designed.
Expand Down
6 changes: 4 additions & 2 deletions frontend/config/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@
"enableSearchByMap": true,
"enableServerCache": true,
"enableMeteoWidget": true,
"maxLengthTrekAllowedFor3DRando": 25000
}
"maxLengthTrekAllowedFor3DRando": 25000,
"minAltitudeDifferenceToDisplayElevationProfile": 0,
"accessibilityCodeNumber": "114"
}
5 changes: 3 additions & 2 deletions frontend/config/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"searchMapCenter": [44.8, 6.3],
"maximumZoomLevel": 17,
"searchMapZoom": 10,
"mapCredits": "OpenTopoMap",
"mapCredits": "© OpenStreetMap-Contributors, SRTM | Style: © OpenTopoMap",
"mapClassicLayerUrl": "https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",
"mapSatelliteLayerUrl": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
"zoomAvailableOffline": [13, 14, 15]
"zoomAvailableOffline": [13, 14, 15],
"mobileMapPanelDefaultOpened": false
}
6 changes: 3 additions & 3 deletions frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const dotenv = require('dotenv-flow');
const runtimeCachingStrategy = require('./cache');
const headerConfig = require('./config/header.json');
const customHeaderConfig = require('./customization/config/header.json');
const getConfig = require('./src/services/getConfig');
const { getConfig, getTemplates } = require('./src/services/getConfig');

const mergedHeaderConfig = {
...headerConfig,
Expand Down Expand Up @@ -62,8 +62,8 @@ module.exports = withPlugins(plugins, {
defaultLocale: mergedHeaderConfig.menu.defaultLanguage,
},
publicRuntimeConfig: {
homeBottomHtml: getConfig('../html/homeBottom.html', false),
homeTopHtml: getConfig('../html/homeTop.html', false),
homeBottomHtml: getTemplates('../html/homeBottom.html', mergedHeaderConfig.menu.supportedLanguages),
homeTopHtml: getTemplates('../html/homeTop.html', mergedHeaderConfig.menu.supportedLanguages),
style: getConfig('../theme/style.css', false),
colors: getConfig('../theme/colors.json', true),
header: getConfig('header.json', true),
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.7.0",
"version": "3.8.0",
"private": true,
"scripts": {
"debug": "NODE_OPTIONS='--inspect' next ./src",
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/components/Accessibility/PhoneIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as React from 'react';
import { SVGProps } from 'react';

const SvgComponent = (props: SVGProps<SVGSVGElement>) => (
<svg width={22} height={22} fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
<path
clipRule="evenodd"
d="M21 15.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.499 19.499 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 3.11 1h3a2 2 0 0 1 2 1.72c.126.96.36 1.903.7 2.81a2 2 0 0 1-.45 2.11L7.09 8.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.907.339 1.85.574 2.81.7A2 2 0 0 1 21 15.92Z"
stroke="currentColor"
strokeWidth={2}
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);

export default SvgComponent;
261 changes: 261 additions & 0 deletions frontend/src/components/Accessibility/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
import { SmallCarousel } from 'components/Carousel';
import { RemoteIconInformation } from 'components/Information/RemoteIconInformation';
import { Modal } from 'components/Modal';
import { CardSingleImage } from 'components/pages/details/components/DetailsCard';
import { HtmlText } from 'components/pages/details/utils';
import parse from 'html-react-parser';
import { sum } from 'lodash';
import { AccessibilityAttachment, Details } from 'modules/details/interface';
import { getGlobalConfig } from 'modules/utils/api.config';
import { FormattedMessage } from 'react-intl';
import styled, { css } from 'styled-components';
import { colorPalette, desktopOnly } from 'stylesheet';
import PhoneIcon from './PhoneIcon';

const Accessibility = ({ details, language }: { details: Details; language: string }) => {
const accessibilityCodeNumber = getGlobalConfig().accessibilityCodeNumber;

const shouldPictureRowBeDisplayed = details.attachmentsAccessibility
? sum(
['slope', 'width', 'signage']
.filter(k => (details as any)[`accessibility_${k}`])
.map(k => {
const attachments = details.attachmentsAccessibility.filter(
a => a.info_accessibility === k,
);
return attachments.length;
}),
) > 0
: false;

return (
<div>
{details.disabledInfrastructure && (
<HtmlText>{parse(details.disabledInfrastructure)}</HtmlText>
)}
{details.accessibilities && details.accessibilities.length > 0 && (
<div className="flex">
{details.accessibilities
.filter(e => e)
.map((accessibility, i) => (
<StyledRemoteIconInformation
key={i}
iconUri={accessibility.pictogramUri}
className="mr-6 mt-3 desktop:mt-4 text-primary"
>
{accessibility.name}
</StyledRemoteIconInformation>
))}
</div>
)}
{details.accessbilityLevel && (
<Section>
<strong>
<FormattedMessage id="details.accessibility_level" />
</strong>{' '}
: {details.accessbilityLevel.name[language]}
</Section>
)}

{accessibilityCodeNumber && (
<Section>
<strong>
<FormattedMessage id="details.emergency_number" />
</strong>{' '}
:
<EmergencyNumber>
<PhoneIcon />
{accessibilityCodeNumber}
</EmergencyNumber>
</Section>
)}
<Columns>
{details.attachmentsAccessibility &&
['slope', 'width', 'signage']
.filter(k => (details as any)[`accessibility_${k}`])
.map(k => {
let attachments = details.attachmentsAccessibility.filter(
a => a.info_accessibility === k,
);
if (attachments.length === 0) {
attachments = [
{
url: getGlobalConfig().fallbackImageUri,
} as AccessibilityAttachment,
];
}

return (
<div key={k}>
{shouldPictureRowBeDisplayed && (
<Modal>
{({ isFullscreen, toggleFullscreen }) => (
<div id="details_cover" className={!isFullscreen ? '' : 'h-full'}>
<StyledSmallCarousel isFullscreen={isFullscreen}>
{attachments.map((attachment, i) => (
<div className="relative" key={attachment.uuid}>
{isFullscreen && (
<Legend>
{attachment.author} - {attachment.legend}
</Legend>
)}
<CardSingleImage
key={i}
src={attachment.url}
height={200}
onClick={toggleFullscreen}
/>
</div>
))}
</StyledSmallCarousel>
</div>
)}
</Modal>
)}

<h2>
<FormattedMessage id={`details.accessibility_${k}`} /> :
</h2>
<p>
<HtmlText>{parse((details as any)[`accessibility_${k}`])}</HtmlText>
</p>
</div>
);
})}
</Columns>
{['accessibility_covering', 'accessibility_exposure', 'accessibility_advice']
.filter(k => (details as any)[k])
.map(k => (
<Row key={k}>
<h2>
<FormattedMessage id={`details.${k}`} /> :
</h2>
<p>
<HtmlText>{parse((details as any)[k])}</HtmlText>
</p>
</Row>
))}
</div>
);
};

const Legend = styled.div`
position: absolute;
color: white;
font-size: 14px;
left: 50%;
top: 15px;
transform: translateX(-50%);
`;

const StyledRemoteIconInformation = styled(RemoteIconInformation)`
* {
font-size: 16px;
}
`;

const EmergencyNumber = styled.div`
color: ${colorPalette.primary1};
display: flex;
/* border: 3px solid ${colorPalette.primary1}; */
background-color: ${colorPalette.primary2};
border-radius: 30px;
font-size: 20px;
font-weight: bold;
padding: 8px;
margin-left: 10px;
margin-top: auto;
margin-bottom: auto;
& svg {
margin-right: 10px;
}
`;

const Section = styled.div`
display: flex;
align-items: center;
margin-top: 10px;
& strong {
font-weight: bold;
}
`;

const Row = styled.div`
margin-top: 20px;
& h2 {
font-size: 20px;
font-weight: 700;
}
& p {
margin-top: 10px;
}
`;

const Columns = styled.div`
display: flex;
margin-left: -10px;
flex-flow: column;
${desktopOnly(css`
flex-flow: row;
`)}
& h2 {
font-size: 20px;
font-weight: 700;
margin-bottom: 10px;
margin-top: 10px;
}
& > div {
min-width: 150px;
flex: 1;
display: flex;
flex-flow: column;
margin: 10px;
}
`;

const StyledSmallCarousel = styled(SmallCarousel)<{ isFullscreen: boolean }>`
height: auto;
& img {
border-radius: ${props => (props.isFullscreen ? 0 : '30px')};
height: ${props => (props.isFullscreen ? '100vh' : '200px')};
margin: auto;
cursor: pointer;
width: 100%;
${desktopOnly(css`
width: 'auto';
`)}
}
`;

export const shouldDisplayAccessibility = (details: Details) => {
return Boolean(
// eslint-disable-next-line
details.disabledInfrastructure ||
// eslint-disable-next-line
details.accessibilities.length > 0 ||
// eslint-disable-next-line
details.accessbilityLevel ||
// eslint-disable-next-line
details.accessibility_covering ||
// eslint-disable-next-line
details.accessibility_exposure ||
// eslint-disable-next-line
details.accessibility_advice ||
// eslint-disable-next-line
details.accessibility_signage ||
// eslint-disable-next-line
details.accessibility_slope ||
// eslint-disable-next-line
details.accessibility_width,
);
};

export default Accessibility;
2 changes: 1 addition & 1 deletion frontend/src/components/Footer/useFooter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MenuItem } from 'modules/header/interface';
import { getDefaultLanguage } from 'modules/header/utills';
import { FooterConfigInput, FooterConfigOutput, PortalLinkStatic } from './interface';

const getFooterConfig = (): FooterConfigInput => {
export const getFooterConfig = (): FooterConfigInput => {
const {
publicRuntimeConfig: { footer },
} = getNextConfig();
Expand Down
Loading

0 comments on commit 7f7d2f6

Please sign in to comment.