Skip to content

Commit

Permalink
Merge pull request #1594 from Vizzuality/MRXN23-523-fe-id-26-2-minor
Browse files Browse the repository at this point in the history
[MRXN23-523]: represents cost surfaces with flat ranges with basic colors
  • Loading branch information
agnlez authored Nov 22, 2023
2 parents cd2d950 + 609d4f3 commit 801e74e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 21 deletions.
65 changes: 45 additions & 20 deletions app/hooks/map/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,28 +354,53 @@ export const LEGEND_LAYERS = {
}) => {
const { items, onChangeVisibility } = options;

return items?.map(({ id, name, min = 1, max = 100 }) => ({
id,
name,
type: 'gradient' as LegendItemType,
settingsManager: {
opacity: true,
visibility: true,
},
items: [
{
color: COLORS.cost[0],
value: `${min === max ? 0 : min}`,
return items?.map(({ id, name, min = 1, max = 100 }) => {
// ? if the cost surface has a flat range, a gradient makes no sense
if (min === max) {
return {
id,
name,
type: 'basic' as LegendItemType,
icon: (
<FaSquare
className="h-3 w-3"
style={{ color: COLORS.cost[1], minWidth: 12, minHeight: 12 }}
/>
),
items: [],
settingsManager: {
opacity: true,
visibility: true,
},
onChangeVisibility: () => {
onChangeVisibility?.(id);
},
};
}

return {
id,
name,
type: 'gradient' as LegendItemType,
settingsManager: {
opacity: true,
visibility: true,
},
{
color: COLORS.cost[1],
value: `${max}`,
items: [
{
color: COLORS.cost[0],
value: min,
},
{
color: COLORS.cost[1],
value: `${max}`,
},
],
onChangeVisibility: () => {
onChangeVisibility?.(id);
},
],
onChangeVisibility: () => {
onChangeVisibility?.(id);
},
}));
};
});
},
'lock-available': (options) => {
const { puAvailableValue, onChangeVisibility } = options;
Expand Down
2 changes: 1 addition & 1 deletion app/hooks/map/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export function useCostSurfaceLayer({
layerSettings.max,
COLORS.cost[1],
],
'fill-opacity': 0.75 * (layerSettings.opacity || 1),
'fill-opacity': 0.75 * (layerSettings.opacity ?? 1),
},
},
],
Expand Down

1 comment on commit 801e74e

@vercel
Copy link

@vercel vercel bot commented on 801e74e Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

marxan – ./

marxan-vizzuality1.vercel.app
marxan23.vercel.app
marxan-git-develop-vizzuality1.vercel.app

Please sign in to comment.