From 31a54cfd94dd5b35a06cf97215228cbf9abbdfd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Cant=C3=B9?= Date: Thu, 4 Apr 2024 11:49:56 +0200 Subject: [PATCH] handle interval legends --- src/pages/viewer/components/LegendWidget.jsx | 2 ++ .../components/legend-types/Interval.jsx | 16 ++++++++++++++++ src/styles/app.scss | 18 +++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/pages/viewer/components/legend-types/Interval.jsx diff --git a/src/pages/viewer/components/LegendWidget.jsx b/src/pages/viewer/components/LegendWidget.jsx index dd80edd..79b9dde 100644 --- a/src/pages/viewer/components/LegendWidget.jsx +++ b/src/pages/viewer/components/LegendWidget.jsx @@ -2,11 +2,13 @@ import { useContext, useMemo } from "react" import { MapContext } from "../contexts" import { Box } from "react-bulma-components"; import SequentialLegend from "./legend-types/Sequential"; +import IntervalLegend from "./legend-types/Interval"; function LegendRender({ type, ...data }) { switch(type) { case 'sequential': return ; + case 'interval': return ; default: null; } } diff --git a/src/pages/viewer/components/legend-types/Interval.jsx b/src/pages/viewer/components/legend-types/Interval.jsx new file mode 100644 index 0000000..68662ee --- /dev/null +++ b/src/pages/viewer/components/legend-types/Interval.jsx @@ -0,0 +1,16 @@ +import { Columns, Media } from "react-bulma-components"; + +const { Column } = Columns; + +export default function IntervalLegend({ intervals }) { + return ( + intervals.map(({ background, description }) => ( + + +
+
+ {description} +
+ )) + ) +} \ No newline at end of file diff --git a/src/styles/app.scss b/src/styles/app.scss index 0b90f7f..8966161 100644 --- a/src/styles/app.scss +++ b/src/styles/app.scss @@ -91,7 +91,7 @@ $footer-height: 40px; } #legend-box { - width: 200px; + width: 250px; position: absolute; bottom: 25px + $footer-height; right: 0; @@ -121,6 +121,22 @@ $footer-height: 40px; padding: 0.2rem; } } + + .interval-legend-entry { + margin-top: 0.1rem; + margin-left: 0; + margin-right: 0; + margin-bottom: 0; + width: 100%; + + .column { + padding: 0.2rem ; + } + .bar { + max-width: 25px; + } + } + } #basemap {