Skip to content

Commit 8b17385

Browse files
committed
move opacity slider next to frame controls for #52
1 parent 71c2276 commit 8b17385

1 file changed

Lines changed: 62 additions & 34 deletions

File tree

frontend/src/App.jsx

Lines changed: 62 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default function App() {
2929
);
3030
const [timezone, setTimezone] = useState(dayjs.tz.guess());
3131
const [selectedDuration, setSelectedDuration] = useState("60");
32-
const [geotiffOpacity, setGeotiffOpacity] = useState("100");
32+
const [geotiffOpacity, setGeotiffOpacity] = useState("80");
3333

3434
// API State
3535
const [jobStatus, setJobStatus] = useState("NONE");
@@ -134,6 +134,7 @@ export default function App() {
134134
);
135135
const urls = await Promise.all(promises);
136136
setFrames(urls);
137+
setIsPlaying(true);
137138
console.log("Frames fetched successfully: ", urls);
138139
} catch (err) {
139140
console.error("Error fetching frames:", err);
@@ -298,7 +299,11 @@ export default function App() {
298299
className="w-full max-w-92 h-14"
299300
onClick={fetchRadarData}
300301
variant="contained"
301-
loading={jobStatus === "REQUESTED" || jobStatus === "PROCESSING" || jobStatus === "PENDING"}
302+
loading={
303+
jobStatus === "REQUESTED" ||
304+
jobStatus === "PROCESSING" ||
305+
jobStatus === "PENDING"
306+
}
302307
>
303308
Get Radar Data
304309
</Button>
@@ -315,47 +320,70 @@ export default function App() {
315320
<p>The radar data is pending. Please wait.</p>
316321
)}
317322
{errorMessage && <p className="font-bold">{errorMessage}</p>}
318-
{numFrames !== 0 && <div className="flex items-center w-full max-w-[1000px] bg-white p-2 rounded-full md:shadow-2xl md:mr-4 md:pr-4 mt-3">
319-
<p className="min-w-fit px-3 font-semibold">Opacity</p>
320-
<Slider
321-
value={geotiffOpacity}
322-
min={0}
323-
max={100}
324-
step={1}
325-
onChange={(event, newValue) => setGeotiffOpacity(newValue)}
326-
valueLabelDisplay="auto"
327-
/>
328-
<p className="min-w-fit px-3">{geotiffOpacity}%</p>
329-
</div>
330-
}
331323
{/* Playback Controls */}
332324
{/* The CSS is a little cursed. */}
333325
<div className="flex h-full items-end">
334326
<div className=" flex md:min-w-[calc(100vw-1rem)] md:pl-92 z-999 w-full">
335-
{numFrames !== 0 && <div className="flex items-center w-full max-w-[1000px] bg-white p-2 rounded-full md:shadow-2xl md:mr-4 md:pr-4">
336-
<button
337-
type="button"
338-
onClick={() => setIsPlaying(!isPlaying)}
339-
className="mr-4 cursor-pointer text-white rounded-full bg-[#1976d2] hover:bg-[#1565c0] shadow hover:shadow-lg transition-all flex p-3 h-max"
340-
>
341-
{isPlaying ? <PauseIcon /> : <PlayArrowIcon />}
342-
</button>
343-
<Slider
344-
value={currentFrameIndex}
345-
min={0}
346-
max={frames.length > 0 ? frames.length - 1 : 0}
347-
step={1}
348-
onChange={handleSliderChange}
349-
valueLabelDisplay="auto"
350-
marks={frames.map((_, i) => ({ value: i }))}
351-
/>
352-
</div>}
327+
{numFrames !== 0 && (
328+
<div className="flex flex-col items-center w-full max-w-[800px] bg-white p-2 rounded-xl md:shadow-2xl md:mr-4 md:pr-4">
329+
<div className="flex w-full items-center">
330+
<button
331+
type="button"
332+
onClick={() => setIsPlaying(!isPlaying)}
333+
className="mr-6 ml-2 cursor-pointer text-white rounded-full bg-[#1976d2] hover:bg-[#1565c0] shadow hover:shadow-lg transition-all flex p-3 h-max"
334+
>
335+
{isPlaying ? <PauseIcon /> : <PlayArrowIcon />}
336+
</button>
337+
<Slider
338+
value={currentFrameIndex}
339+
min={0}
340+
max={frames.length > 0 ? frames.length - 1 : 0}
341+
step={1}
342+
onChange={handleSliderChange}
343+
valueLabelDisplay="auto"
344+
marks={frames.map((_, i) => ({ value: i }))}
345+
/>
346+
</div>
347+
<div className="flex w-full pt-4">
348+
<div className="flex items-center w-1/2">
349+
<p className="min-w-fit px-3 text-sm">Opacity</p>
350+
<Slider
351+
value={geotiffOpacity}
352+
min={0}
353+
max={100}
354+
step={1}
355+
onChange={(event, newValue) =>
356+
setGeotiffOpacity(newValue)
357+
}
358+
valueLabelDisplay="auto"
359+
/>
360+
<p className="min-w-fit px-3">{geotiffOpacity}%</p>
361+
</div>
362+
<div className="w-1/2">
363+
{/*TODO: Actual timestamp will go here: */}
364+
<p className="text-sm text-right">
365+
{selectedDateTime
366+
.tz(timezone)
367+
.format("YYYY-MM-DD HH:mm z")}
368+
</p>
369+
</div>
370+
</div>
371+
</div>
372+
)}
353373
</div>
354374
</div>
355375
</div>
356376

357377
<div className="bg-gray-50 min-h-100 w-full">
358-
<div className={jobStatus === "PROCESSING" || jobStatus === "REQUESTED" || jobStatus === "PENDING" ? "opacity-50" : ""}>
378+
<div
379+
className={
380+
jobStatus === "PROCESSING" ||
381+
jobStatus === "REQUESTED" ||
382+
jobStatus === "PENDING"
383+
? "opacity-50"
384+
: ""
385+
}
386+
>
359387
<LeafletMap
360388
stations={stations}
361389
selectedStation={selectedStation}

0 commit comments

Comments
 (0)