Skip to content

Commit

Permalink
handle interval legends
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Apr 4, 2024
1 parent f5712e8 commit 31a54cf
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/pages/viewer/components/LegendWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <SequentialLegend {...data} />;
case 'interval': return <IntervalLegend {...data} />;
default: null;
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/pages/viewer/components/legend-types/Interval.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Columns, Media } from "react-bulma-components";

const { Column } = Columns;

export default function IntervalLegend({ intervals }) {
return (
intervals.map(({ background, description }) => (
<Columns className="interval-legend-entry" key={background}>
<Column size="one-quarter" className="bar">
<div style={{ background, height: '100%', width: '100%' }}></div>
</Column>
<Column className="is-size-7">{description}</Column>
</Columns>
))
)
}
18 changes: 17 additions & 1 deletion src/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ $footer-height: 40px;
}

#legend-box {
width: 200px;
width: 250px;
position: absolute;
bottom: 25px + $footer-height;
right: 0;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 31a54cf

Please sign in to comment.