Skip to content

Commit

Permalink
restore legend sizing, fix vulnerabilities and make slider more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
lstillwe committed Oct 14, 2024
1 parent a77cf96 commit 65f89d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
15 changes: 7 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions src/components/legend/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,12 @@ export const MapLegend = () => {
const nodeRef = useRef(null);

// declare the width min/max for the legend card
//const minWidth = 45;
//const maxWidth = 75;
const minWidth = 65;
const maxWidth = 95;
const minWidth = 45;
const maxWidth = 75;

// declare the height min/max for the legend card
//const minHeight = 250;
//const maxHeight = 350;
const minHeight = 300;
const maxHeight = 400;
const minHeight = 250;
const maxHeight = 350;

return (
<Draggable
Expand Down
8 changes: 7 additions & 1 deletion src/components/trays/settings/colormaps/colormap-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ export const ColormapSlider = ({style}) => {

const handleChange = (event, newValue) => {
// make sure the first thumb value is not >= the second
if (newValue[0] < newValue[1]) {
// and that second is >= sliderStep
if ((newValue[0] < newValue[1]) && (newValue[1] >= sliderStep)) {
setValue(newValue);
}
};
Expand All @@ -193,6 +194,11 @@ export const ColormapSlider = ({style}) => {
if (newValue[0] === newValue[1]) {
newValue[0] = newValue[0]-sliderStep;
}
// since min slider value doesn't appear to work, make
// sure lower slider value is never less tha 0
newValue[0] = (newValue[0] < 0) ? 0 : newValue[0];
// also check for 0 upper value - set sliderStep as lowest value
newValue[1] = (newValue[1] < sliderStep) ? sliderStep : newValue[1];
setValue([newValue[0], newValue[1]]);

// now create new style with altered data range
Expand Down

0 comments on commit 65f89d8

Please sign in to comment.