Skip to content

Commit

Permalink
close hover card when drawer is active
Browse files Browse the repository at this point in the history
  • Loading branch information
vnugent committed May 29, 2024
1 parent b58458f commit 7d7a881
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/components/maps/GlobalMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ export const GlobalMap: React.FC<GlobalMapProps> = ({
const { layer, geometry, properties } = feature

setClickInfo(prev => {
setActiveFeatureVisual(prev, { selected: false })
setActiveFeatureVisual(prev, { selected: false, hover: false })
const activeFeature = tileToFeature(layer.id, event.point, geometry, properties as TileProps, mapInstance)
setActiveFeatureVisual(activeFeature, { selected: true })
setActiveFeatureVisual(activeFeature, { selected: true, hover: false })
return activeFeature
})
}
Expand All @@ -119,9 +119,10 @@ export const GlobalMap: React.FC<GlobalMapProps> = ({
*/
const onHoverCardClick = (feature: ActiveFeature): void => {
setClickInfo(prevFeature => {
setActiveFeatureVisual(prevFeature, { selected: false })
setHoverInfo(null)
setActiveFeatureVisual(prevFeature, { selected: false, hover: false })
if (feature.type === 'area-boundaries') {
setActiveFeatureVisual(feature, { selected: true })
setActiveFeatureVisual(feature, { selected: true, hover: false })
}
return feature
})
Expand Down
8 changes: 2 additions & 6 deletions src/components/maps/TileHandlers/CragContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const MicroClimbList: React.FC<{ climbs: SimpleClimbType[] }> = ({ climbs }) =>
)
}

export const CragHoverCardContent: React.FC<CragFeatureProperties> = ({ id, areaName, climbs, media }) => {
export const CragHoverCardContent: React.FC<CragFeatureProperties> = ({ id, areaName, climbs }) => {
return (
<div className='flex flex-col gap-y-1 text-xs'>
<a
Expand All @@ -68,11 +68,7 @@ export const CragHoverCardContent: React.FC<CragFeatureProperties> = ({ id, area
>
{areaName}
</a>
<div className='font-sm text-secondary flex items-center gap-1'>
<EntityIcon type='crag' size={16} />
·
<span className='text-xs'>{climbs.length} climbs</span>
</div>
<Subheading id={id} totalClimbs={climbs.length} />
</div>
)
}

0 comments on commit 7d7a881

Please sign in to comment.