Skip to content

Commit

Permalink
clean up legends
Browse files Browse the repository at this point in the history
  • Loading branch information
eatyourgreens committed May 30, 2024
1 parent 7ae1aaf commit f6fb2f0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 48 deletions.
44 changes: 0 additions & 44 deletions frontend/src/config/backgrounds.ts

This file was deleted.

23 changes: 19 additions & 4 deletions frontend/src/map/legend/GradientLegend.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Box, Typography } from '@mui/material';
import { FC } from 'react';
import { FC, ReactNode, memo } from 'react';

import { ColorValue } from './RasterLegend';

const legendHeight = 10;

const LegendGradient: FC<{
colorMapValues: any[];
colorMapValues: ColorValue[];
getValueLabel: (value: number) => string;
}> = ({ colorMapValues, getValueLabel }) => {
return (
Expand All @@ -16,7 +18,20 @@ const LegendGradient: FC<{
);
};

export const GradientLegend = ({ label, range, colorMapValues, getValueLabel }) => (
export interface GradientLegendProps {
label: string | ReactNode;
description?: string;
range: [number, number];
colorMapValues: ColorValue[];
getValueLabel: (value: number) => string;
}

export const GradientLegend:FC<GradientLegendProps> = memo(({
label,
range,
colorMapValues,
getValueLabel
}) => (
<Box mb={2}>
<Typography>{label}</Typography>
<Box
Expand Down Expand Up @@ -44,4 +59,4 @@ export const GradientLegend = ({ label, range, colorMapValues, getValueLabel })
)}
</Box>
</Box>
);
));
8 changes: 8 additions & 0 deletions frontend/src/map/legend/RasterLegend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import { ViewLayer } from 'lib/data-map/view-layers';
import { FC, useCallback } from 'react';
import { GradientLegend } from './GradientLegend';
import { useRasterColorMapValues } from './use-color-map-values';
export interface ColorValue {
color: string;
value: any;
}
export interface RasterColorMapValues {
colorMapValues: ColorValue[];
rangeTruncated: [boolean, boolean];
}

export const RasterLegend: FC<{ viewLayer: ViewLayer }> = ({ viewLayer }) => {
const {
Expand Down

0 comments on commit f6fb2f0

Please sign in to comment.