-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from Vizzuality/SKY30-108-fe-implement-the-eez…
…-layers [SKY30-108]: EEZ legend
- Loading branch information
Showing
19 changed files
with
431 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
frontend/src/containers/data-tool/content/map/labels-manager/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useCallback, useEffect } from 'react'; | ||
|
||
import { useMap } from 'react-map-gl'; | ||
|
||
import { useSyncMapSettings } from '@/containers/data-tool/content/map/sync-settings'; | ||
|
||
const LABELS_LAYER_ID = 'country-label'; | ||
|
||
const LabelsManager = () => { | ||
const { default: mapRef } = useMap(); | ||
const [{ labels }] = useSyncMapSettings(); | ||
|
||
const toggleLabels = useCallback(() => { | ||
if (!mapRef) return; | ||
const map = mapRef.getMap(); | ||
|
||
map.setLayoutProperty(LABELS_LAYER_ID, 'visibility', labels ? 'visible' : 'none'); | ||
}, [mapRef, labels]); | ||
|
||
const handleStyleLoad = useCallback(() => { | ||
toggleLabels(); | ||
}, [toggleLabels]); | ||
|
||
useEffect(() => { | ||
if (!mapRef) return; | ||
mapRef.on('style.load', handleStyleLoad); | ||
|
||
return () => { | ||
mapRef.off('style.load', handleStyleLoad); | ||
}; | ||
}, [mapRef, handleStyleLoad]); | ||
|
||
useEffect(() => { | ||
if (!mapRef) return; | ||
toggleLabels(); | ||
}, [mapRef, toggleLabels]); | ||
|
||
return null; | ||
}; | ||
|
||
export default LabelsManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
frontend/src/containers/data-tool/content/map/layers-toolbox/legend/eez/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Icon from '@/components/ui/icon'; | ||
import { Tooltip, TooltipProvider, TooltipTrigger, TooltipContent } from '@/components/ui/tooltip'; | ||
import EEZIcon from '@/styles/icons/eez.svg?sprite'; | ||
import InfoIcon from '@/styles/icons/info.svg?sprite'; | ||
import SelectedEEZIcon from '@/styles/icons/selected-eez.svg?sprite'; | ||
import SeveralEEZIcon from '@/styles/icons/several-eez.svg?sprite'; | ||
import { useGetDataInfos } from '@/types/generated/data-info'; | ||
|
||
const ITEM_LIST_CLASSES = 'flex items-center space-x-2'; | ||
const ICON_CLASSES = 'h-7 w-7'; | ||
|
||
const EEZLayerLegend = () => { | ||
const EEZInfoQuery = useGetDataInfos( | ||
{ | ||
filters: { | ||
slug: 'eez-legend', | ||
}, | ||
}, | ||
{ | ||
query: { | ||
select: ({ data }) => data?.[0].attributes, | ||
}, | ||
} | ||
); | ||
|
||
return ( | ||
<ul className="space-y-3 font-mono text-xs"> | ||
<li className={ITEM_LIST_CLASSES}> | ||
<Icon icon={EEZIcon} className={ICON_CLASSES} /> | ||
<span>EEZs</span> | ||
</li> | ||
<li className={ITEM_LIST_CLASSES}> | ||
<Icon icon={SelectedEEZIcon} className={ICON_CLASSES} /> | ||
<span>Selected EEZ</span> | ||
</li> | ||
<li className={ITEM_LIST_CLASSES}> | ||
<Icon icon={SeveralEEZIcon} className={ICON_CLASSES} /> | ||
<div className="max-w-[195px] space-x-1"> | ||
<span> | ||
Area corresponding to more <br /> than one EEZ | ||
</span> | ||
<TooltipProvider skipDelayDuration={0} delayDuration={0}> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<button type="button" className="translate-y-[4px]"> | ||
<Icon icon={InfoIcon} className="h-4 w-4" /> | ||
</button> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<div className="max-w-[235px] p-4">{EEZInfoQuery.data?.content}</div> | ||
</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
</div> | ||
</li> | ||
</ul> | ||
); | ||
}; | ||
|
||
export default EEZLayerLegend; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.