Skip to content

Commit

Permalink
list feature names
Browse files Browse the repository at this point in the history
  • Loading branch information
aloxe committed Jul 23, 2024
1 parent 221ecf5 commit 4e79bf7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 14 deletions.
31 changes: 31 additions & 0 deletions src/components/Popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
38 changes: 24 additions & 14 deletions src/components/Popup.jsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
import { useState } from 'react';
import { countryCodeToFlag } from '../helpers/countryUtil';
import { formatDate } from '../helpers/timeUtil';
import Elevation from './Elevation';
import './Popup.css';


const Popup = ({geojson, handleClickPopup}) => {
const [collapsed, setCollapsed] = useState(false);

const handleClick = () => {
handleClickPopup("close")
}

if (!geojson.title) return
return (
<>
<div className='popup-wraper'>
<div className='popup-wraper'>
<button className="popup-close-button" onClick={handleClick}>×</button>
<div className='popup-content-wrapper'>
<div className='popup-content'>
<div className='popup-title'>🚲 {geojson?.title || ''}</div>
<div className='popup-date'>{(formatDate(undefined, "ddMMYYYY", geojson?.date) || '') + ' ' + geojson?.countries.map(cc => countryCodeToFlag(cc)).join(' ')}</div>
<Elevation geojson={geojson} key="elev" />
<div>{`${geojson?.distance}km`}</div>
</div>
</div>
<div className='popup-tip-container'>
<div className='tip'></div>
<div className='popup-content-wrapper'>
<div className='popup-content'>
<div className='popup-title'>🚲 {geojson?.title || ''}</div>
<div className='popup-date'>{(formatDate(undefined, "ddMMYYYY", geojson?.date) || '') + ' ' + geojson?.countries.map(cc => countryCodeToFlag(cc)).join(' ')}</div>
<Elevation geojson={geojson} key="elev" />
<div>{`${geojson?.distance}km`}</div>
{geojson.features.length > 1 && <>
<button className={`collapse-button ${collapsed ? "up" : "right" }`} onClick={() => setCollapsed(!collapsed)}></button>
<div className={`popup-names ${collapsed ? "show" : "hide" }`}>
{geojson.features.map((feature, index) => (
<div key={index}>
<span style={{color: feature.properties.color ?? "indogo"}}></span> {feature.properties.name}
</div>
))}
</div>
</>}
</div>
</div>
</>
<div className='popup-tip-container'>
<div className='tip'></div>
</div>
</div>
);
}
}

export default Popup;

0 comments on commit 4e79bf7

Please sign in to comment.