Skip to content

Commit

Permalink
fix extent layer
Browse files Browse the repository at this point in the history
  • Loading branch information
mluena committed Oct 23, 2023
1 parent ef68951 commit 176eb3c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/containers/datasets/habitat-extent/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type { UseParamsOptions } from 'types/widget';

import API, { AnalysisAPI } from 'services/api';

import { years } from './constants';
import type { ExtentData, Indicator, DataResponse } from './types';

const unitOptions = ['km²', 'ha'];
Expand Down Expand Up @@ -219,9 +220,10 @@ export function useSource(): SourceProps {
}

export function useLayers({ year, id }: { year: number; id: LayerProps['id'] }): LayerProps[] {
console.log(year);
return [
{
id,
id: `${id}_${year}`,
type: 'fill',
source: 'habitat_extent',
'source-layer': `mng_mjr_${year}`,
Expand All @@ -234,7 +236,7 @@ export function useLayers({ year, id }: { year: number; id: LayerProps['id'] }):
},
},
{
id: `${id}_line`,
id: `${id}_${year}`,
type: 'line',
source: 'habitat_extent',
'source-layer': `mng_mjr_${year}`,
Expand Down
17 changes: 13 additions & 4 deletions src/containers/datasets/habitat-extent/layer.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import { Source, Layer } from 'react-map-gl';

import { habitatExtentSettings } from 'store/widgets/habitat-extent';

import { useRecoilValue } from 'recoil';

import type { LayerProps } from 'types/layers';

import { useLayers, useSource } from './hooks';
import {} from './hooks';
import { useLayers, useSource, useMangroveHabitatExtent } from './hooks';

const MangrovesHabitatExtentLayer = ({ beforeId, id }: LayerProps) => {
const year = 2020;
const year = useRecoilValue(habitatExtentSettings);
const { data } = useMangroveHabitatExtent({ year });
const years = data?.years?.sort() || [];

const currentYear = year || years[years.length - 1];

const SOURCE = useSource();
const LAYERS = useLayers({ year, id });
const LAYERS = useLayers({ year: currentYear, id });
if (!SOURCE || !LAYERS) return null;

return (
<Source key={SOURCE.id} {...SOURCE}>
{LAYERS.map((LAYER) => (
Expand Down
10 changes: 4 additions & 6 deletions src/containers/widgets/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ const widgets_prod = [
layersIds: ['allen_coral_reef'],
},
{
...(process.env.NEXT_PUBLIC_VERCEL_ENV === 'development' && {
name: 'Salt Marsh',
slug: 'mangrove_salt_marsh',
locationType: ['custom-area', 'wdpa', 'country', 'worldwide'],
categoryIds: ['contextual_layers'],
}),
name: 'Salt Marsh',
slug: 'mangrove_salt_marsh',
locationType: ['custom-area', 'wdpa', 'country', 'worldwide'],
categoryIds: ['contextual_layers'],
},
{
name: 'Tidal flats',
Expand Down
12 changes: 12 additions & 0 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ body {
/* width */
::-webkit-scrollbar {
width: 3px !important;
scrollbar-width: 3px !important;
}


Expand Down Expand Up @@ -63,11 +64,16 @@ body {
display: none;
}


.no-scrollbar {
-ms-overflow-style: none;
scrollbar-width: none;
}

::-webkit-scrollbar {
width: 0.5rem !important;
}

.scroll-thin::-webkit-scrollbar {
width: 0.5rem;
}
Expand Down Expand Up @@ -170,3 +176,9 @@ body {
margin: 0 auto;
}
}

/* Firefox */
* {
scrollbar-width: thin;
scrollbar-color: var(--secondary) var(--primary);
}

0 comments on commit 176eb3c

Please sign in to comment.