Skip to content

Commit 7fdc9fb

Browse files
committed
Fix types related to UI
1 parent 7ce69e3 commit 7fdc9fb

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

src/Animation.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
useControl,
66
} from "react-map-gl/maplibre";
77
import { TileLayer } from "@deck.gl/geo-layers";
8-
import type { _TileLoadProps, TileIndex } from "@deck.gl/geo-layers";
8+
import type { _TileLoadProps } from "@deck.gl/geo-layers";
99

1010
import { MapboxOverlay as DeckOverlay } from "@deck.gl/mapbox";
1111

@@ -45,8 +45,11 @@ const zarrReader = await ZarrReader.initialize({
4545
varName: VAR_NAME,
4646
});
4747

48-
const timestampUnit = 1;
49-
const maxTimestamp = 4;
48+
export type TileIndex = { x: number; y: number; z: number };
49+
50+
const TIME_UNIT = 1;
51+
const MAX_TIMESTAMP = 4;
52+
const SPEED = 0.02;
5053

5154
const quickCache = new Map();
5255

@@ -74,7 +77,7 @@ async function fetchOneTimeStamp({
7477
quickCache.set(keyName, chunkData);
7578
return chunkData;
7679
}
77-
const SPEED = 0.02;
80+
7881
function App() {
7982
const [selectedColormap, setSelectedColormap] = useState<string>("viridis");
8083
const [minMax, setMinMax] = useState<{ min: number; max: number }>(
@@ -83,14 +86,14 @@ function App() {
8386
const [timestamp, setTimestamp] = useState<number>(0.0);
8487
const timestampStart = Math.floor(timestamp);
8588
const timestampEnd = Math.min(
86-
Math.floor(timestamp + timestampUnit),
87-
maxTimestamp
89+
Math.floor(timestamp + TIME_UNIT),
90+
MAX_TIMESTAMP
8891
);
8992

9093
const { isRunning, toggleAnimation } = usePausableAnimation(() => {
9194
// Pass on a function to the setter of the state
9295
// to make sure we always have the latest state
93-
setTimestamp((prev) => (prev + SPEED) % maxTimestamp);
96+
setTimestamp((prev) => (prev + SPEED) % MAX_TIMESTAMP);
9497
});
9598

9699
async function getTileData({ index, signal }: _TileLoadProps) {
@@ -224,7 +227,7 @@ function App() {
224227
/>
225228

226229
<SingleSlider
227-
minMax={[0, maxTimestamp]}
230+
minMax={[0, MAX_TIMESTAMP]}
228231
step={SPEED}
229232
currentValue={timestamp}
230233
label="Timestamp"

src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ function App() {
167167

168168
<SingleSlider
169169
minMax={[0, 2]}
170+
currentValue={timestamp}
170171
step={1}
171172
label="Timestamp"
172173
onValueChange={setTimestamp}

src/components/ui/PlayButton.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { Button } from "@chakra-ui/react";
22

3-
export default function PlayButton({ onPlay, onClick }) {
3+
type PlayButtonProps = {
4+
onPlay: boolean;
5+
onClick: () => void;
6+
};
7+
8+
export default function PlayButton({ onPlay, onClick }: PlayButtonProps) {
49
return <Button onClick={onClick}>{onPlay ? "Pause" : "Play"}</Button>;
510
}

src/components/ui/RangeSlider.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { Slider } from "@chakra-ui/react";
22
import type { SliderUIProps } from "./Slider";
33

4-
type RangeSliderUIProps = SliderUIProps & {
4+
type RangeSliderUIProps = Omit<
5+
SliderUIProps,
6+
"onValueChange" | "currentValue"
7+
> & {
58
onValueChange: (param: { min: number; max: number }) => void;
69
};
710

0 commit comments

Comments
 (0)