Skip to content

Commit ef6c6c1

Browse files
authored
Merge pull request #50 from mapcomponents/ui/ux-design-pointcloud
PointCloudSettings.jsx UI/UX changes
2 parents 0c9072a + 5b18db3 commit ef6c6c1

File tree

1 file changed

+71
-49
lines changed

1 file changed

+71
-49
lines changed

pointcloud/src/PointCloudSettings.jsx

Lines changed: 71 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {AppBar, Box, Button, Slider, Switch, Typography} from "@mui/material";
2-
import React, {useState} from "react";
1+
import {Box, Button, Slider, Switch, Typography} from "@mui/material";
2+
import React, {useEffect, useState} from "react";
33
import {Sidebar, TopToolbar} from "@mapcomponents/react-maplibre";
44

55
export default function PointCloudSettings(props) {
@@ -12,6 +12,18 @@ export default function PointCloudSettings(props) {
1212

1313
const [sidebarOpen, setSidebarOpen] = useState(false);
1414

15+
function debounce(func, timeout = 300) {
16+
let timer;
17+
return (...args) => {
18+
clearTimeout(timer);
19+
timer = setTimeout(() => {
20+
func.apply(this, args);
21+
}, timeout);
22+
};
23+
}
24+
25+
const processChange = debounce(() => saveData());
26+
1527
const saveData = () => {
1628
props.setPointSize(pointSize);
1729
props.setLight(light);
@@ -21,31 +33,39 @@ export default function PointCloudSettings(props) {
2133
props.setBlue(blue);
2234
}
2335

36+
useEffect(() => {
37+
processChange();
38+
}, [pointSize, light, intensity, red, green, blue]);
39+
2440
return (
2541
<>
2642
<TopToolbar buttons={
2743
<Button
28-
variant= {sidebarOpen?"outlined":"contained"}
29-
onClick={() => setSidebarOpen(true)}
44+
variant={sidebarOpen ? "outlined" : "contained"}
45+
onClick={() => setSidebarOpen(!sidebarOpen)}
3046
>PointCloud settings</Button>
31-
}/>
32-
<Sidebar open={sidebarOpen} setOpen={setSidebarOpen} >
47+
}/>
48+
<Sidebar open={sidebarOpen} setOpen={setSidebarOpen}>
3349
<Box
3450
sx={{
3551
marginTop: '20px',
3652
}}
3753
>
3854
{/* Headline */}
3955
<Typography
40-
variant="h4"
56+
sx={{
57+
fontSize: '1.25rem',
58+
marginBottom: '5px',
59+
}}
4160
>
4261
PointCloud Settings
4362
</Typography>
44-
<hr width='99%'/>
45-
4663
{/* PointSize */}
4764
<Typography
4865
variant="h6"
66+
sx={{
67+
fontSize: '1rem',
68+
}}
4969
>
5070
Point Size
5171
</Typography>
@@ -63,6 +83,9 @@ export default function PointCloudSettings(props) {
6383
{/* Light */}
6484
<Typography
6585
variant="h6"
86+
sx={{
87+
fontSize: '1rem',
88+
}}
6689
>
6790
Light
6891
</Typography>
@@ -73,27 +96,38 @@ export default function PointCloudSettings(props) {
7396
}}
7497
/>
7598

76-
{/* Lightintensity */}
77-
<Typography
78-
variant="h6"
79-
>
80-
Light intensity
81-
</Typography>
82-
<Slider
83-
defaultValue={1.7}
84-
onChange={(e) => {
85-
setIntensity(e.target.value)
86-
}}
87-
aria-label="small"
88-
valueLabelDisplay="auto"
89-
min={0}
90-
max={3}
91-
step={0.1}
92-
/>
99+
{/* Lightintensity */
100+
light &&
101+
<>
102+
<Typography
103+
variant="h6"
104+
sx={{
105+
fontSize: '1rem',
106+
}}
107+
>
108+
Light intensity
109+
</Typography>
110+
<Slider
111+
defaultValue={1.7}
112+
onChange={(e) => {
113+
setIntensity(e.target.value)
114+
}}
115+
aria-label="small"
116+
valueLabelDisplay="auto"
117+
min={0}
118+
max={3}
119+
step={0.1}
120+
/>
121+
</>
122+
123+
}
93124

94125
{/* Color */}
95126
<Typography
96127
variant="h6"
128+
sx={{
129+
fontSize: '1rem',
130+
}}
97131
>
98132
Color
99133
</Typography>
@@ -102,15 +136,17 @@ export default function PointCloudSettings(props) {
102136
<Box
103137
sx={{
104138
display: 'flex',
139+
alignItems: 'center',
105140
}}
106141
>
107142
<Typography
108143
variant="body1"
109144
sx={{
110145
width: '10px',
146+
fontSize: '1rem',
111147
}}
112148
>
113-
r:
149+
R:
114150
</Typography>
115151
<Slider
116152
sx={{
@@ -133,15 +169,17 @@ export default function PointCloudSettings(props) {
133169
<Box
134170
sx={{
135171
display: 'flex',
172+
alignItems: 'center',
136173
}}
137174
>
138175
<Typography
139176
variant="body1"
140177
sx={{
141178
width: '10px',
179+
fontSize: '1rem',
142180
}}
143181
>
144-
g:
182+
G:
145183
</Typography>
146184
<Slider
147185
sx={{
@@ -164,15 +202,17 @@ export default function PointCloudSettings(props) {
164202
<Box
165203
sx={{
166204
display: 'flex',
205+
alignItems: 'center',
167206
}}
168207
>
169208
<Typography
170209
variant="body1"
171210
sx={{
172211
width: '10px',
212+
fontSize: '1rem',
173213
}}
174214
>
175-
b:
215+
B:
176216
</Typography>
177217
<Slider
178218
sx={{
@@ -190,27 +230,9 @@ export default function PointCloudSettings(props) {
190230
step={1}
191231
/>
192232
</Box>
193-
<Box
194-
sx={{
195-
display: 'flex',
196-
justifyContent: 'right',
197-
marginTop: "25px"
198-
}}
199-
>
200-
<Button
201-
variant="contained"
202-
disabled={props.loading}
203-
sx={{
204-
color: 'white',
205-
}}
206-
onClick={() => saveData()}
207-
>
208-
Apply
209-
</Button>
210-
</Box>
211-
212233
</Box>
213234
</Sidebar>
214235
</>
215-
);
236+
)
237+
;
216238
}

0 commit comments

Comments
 (0)