Skip to content

Commit

Permalink
Merge pull request #451 from GNS-Science/feature/444_opacity_slider_d…
Browse files Browse the repository at this point in the history
…efault_100

Feature/444 opacity slider default 100
  • Loading branch information
benjamineac authored Mar 14, 2024
2 parents a1b3927 + e7612d0 commit 1155553
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/components/common/SliderWithInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export const SliderWithInput: React.FC<SliderWithInputProps> = ({
const handleBlur = () => {
if (value < 0) {
setValue(0);
} else if (value > 100) {
setValue(100);
} else if (value > 10) {
setValue(10);
}
};

Expand All @@ -46,9 +46,11 @@ export const SliderWithInput: React.FC<SliderWithInputProps> = ({
<Grid item xs>
<Slider
value={typeof value === "number" ? value : 0}
step={10}
step={1}
onChange={handleSliderChange}
aria-labelledby="input-slider"
min={1}
max={10}
/>
</Grid>
<Grid item>
Expand All @@ -58,9 +60,9 @@ export const SliderWithInput: React.FC<SliderWithInputProps> = ({
onChange={handleInputChange}
onBlur={handleBlur}
inputProps={{
step: 10,
min: 0,
max: 100,
step: 1,
min: 1,
max: 10,
type: "number",
"aria-labelledby": "input-slider",
}}
Expand Down
4 changes: 2 additions & 2 deletions src/views/hazardMaps/HazardMapsControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const HazardMapsControls: React.FC<HazardMapsControlsProps> = ({
const [vs30, setVs30] = useState<number>(state.vs30);
const [poe, setPoe] = useState<number>(state.poe);
const [colorScale, setColorScale] = useState<string>("inferno");
const [gridOpacity, setGridOpacity] = useState<number>(50);
const [gridOpacity, setGridOpacity] = useState<number>(10);
const [dataFetched, setDataFetched] = useState<boolean>(true);
const [controlsChanged, setControlsChanged] = useState<number>(0);

Expand Down Expand Up @@ -77,7 +77,7 @@ const HazardMapsControls: React.FC<HazardMapsControlsProps> = ({
poe: poe,
color_scale: colorScale,
color_scale_vmax: MAP_GRID_VMAX,
fill_opacity: Number(gridOpacity / 100),
fill_opacity: Number(gridOpacity / 10),
stroke_width: MAP_GRID_STROKE_WIDTH,
stroke_opacity: 0.0,
});
Expand Down

0 comments on commit 1155553

Please sign in to comment.