From 0304bfaa7f1a7ec3b704944b3f366aab62b31501 Mon Sep 17 00:00:00 2001 From: aloxe Date: Mon, 15 Jul 2024 10:14:56 +0200 Subject: [PATCH 1/2] fix rainbow colours when upload and display --- src/components/FileUpload.jsx | 2 ++ src/components/MainMap.jsx | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/FileUpload.jsx b/src/components/FileUpload.jsx index 0eccbd6..601b640 100644 --- a/src/components/FileUpload.jsx +++ b/src/components/FileUpload.jsx @@ -28,6 +28,7 @@ const FileUpload = ({ isLogged, setIsLogged, setGeojsonList }) => { const geojson = await loadGeoJsonFromGpx(name); const l = geojson.features.length; geojson.features.map((feature, i) => feature.properties.color = calcColor(l,i)); + geojson.gpx = true; setCurrentGeoJson(geojson); setGeojsonList([geojson]); } @@ -72,6 +73,7 @@ const FileUpload = ({ isLogged, setIsLogged, setGeojsonList }) => { }; const uploadjson = async () => { + delete currentGeoJson.gpx; currentGeoJson.date = form.date; currentGeoJson.title = form.title; currentGeoJson.countries = form.countries; diff --git a/src/components/MainMap.jsx b/src/components/MainMap.jsx index 5c0b687..116eb83 100644 --- a/src/components/MainMap.jsx +++ b/src/components/MainMap.jsx @@ -37,7 +37,7 @@ const MainMap = ({geojsonList, tileName, handleClickPopup, currentGeoJson}) => { // removing display for points. return { strokeWidth: "0", stroke: "black", r: '0', }; } - if (geojson.slug && geojson.slug === currentGeoJson?.slug) { // sellected path + if (geojson.gpx || geojson.slug && geojson.slug === currentGeoJson?.slug) { // gpx or sellected path if (geojson.features.length > 1) { // rainbow colours for multi paths geojson return { strokeWidth: "4", From 08dec9567d2870d5add112ca4a4265ab987cca04 Mon Sep 17 00:00:00 2001 From: aloxe Date: Mon, 15 Jul 2024 12:33:42 +0200 Subject: [PATCH 2/2] list feature names --- src/components/Popup.css | 31 +++++++++++++++++++++++++++++++ src/components/Popup.jsx | 38 ++++++++++++++++++++++++-------------- 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/src/components/Popup.css b/src/components/Popup.css index 1e057c6..21e210b 100644 --- a/src/components/Popup.css +++ b/src/components/Popup.css @@ -70,4 +70,35 @@ cursor: pointer; } +.collapse-button { + position: absolute; + right: 20px; + margin: -20px 0 0; + border: 0; + font: 24px sans-serif; + font-weight: normal; + color: #c3c3c3; + text-decoration: none; + font-weight: bold; + background: transparent; + cursor: pointer; + transition: all .5s ease-in-out; +} +.collapse-button.up { + transform: rotate(-90deg); +} + +.popup-names { + max-height: 0; + transition: all 1s ease-in-out; + overflow: hidden; +} + +.popup-names.show { + max-height: 400px; +} + +.popup-names.hide { + max-height: 1px; +} diff --git a/src/components/Popup.jsx b/src/components/Popup.jsx index 79d5985..09e774b 100644 --- a/src/components/Popup.jsx +++ b/src/components/Popup.jsx @@ -1,3 +1,4 @@ +import { useState } from 'react'; import { countryCodeToFlag } from '../helpers/countryUtil'; import { formatDate } from '../helpers/timeUtil'; import Elevation from './Elevation'; @@ -5,6 +6,7 @@ import './Popup.css'; const Popup = ({geojson, handleClickPopup}) => { + const [collapsed, setCollapsed] = useState(false); const handleClick = () => { handleClickPopup("close") @@ -12,23 +14,31 @@ const Popup = ({geojson, handleClickPopup}) => { if (!geojson.title) return return ( - <> -
+
-
-
-
🚲 {geojson?.title || ''}
-
{(formatDate(undefined, "ddMMYYYY", geojson?.date) || '') + ' ' + geojson?.countries.map(cc => countryCodeToFlag(cc)).join(' ')}
- -
{`${geojson?.distance}km`}
-
-
-
-
+
+
+
🚲 {geojson?.title || ''}
+
{(formatDate(undefined, "ddMMYYYY", geojson?.date) || '') + ' ' + geojson?.countries.map(cc => countryCodeToFlag(cc)).join(' ')}
+ +
{`${geojson?.distance}km`}
+ {geojson.features.length > 1 && <> + +
+ {geojson.features.map((feature, index) => ( +
+ {feature.properties.name} +
+ ))} +
+ }
- +
+
+
+
); - } +} export default Popup; \ No newline at end of file