Skip to content

Commit 8a551ba

Browse files
committed
fixup! - remove FC types from ui-warped-map
1 parent e2fbc94 commit 8a551ba

15 files changed

+117
-119
lines changed

ui-core/src/components/inputs/datePicker/Calendar.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ const Day = ({ date, isReferenceDate, isSelectable, dayWrapperClassName, onClick
3434
</div>
3535
);
3636

37-
const Calendar = (props: CalendarProps) => {
38-
const { displayedMonthStartDate, onDayClick } = props;
39-
const { days, isReferenceDate, isDateSelectable, buildDayWrapperClassName } = useCalendar(props);
37+
const Calendar = ({ displayedMonthStartDate, onDayClick }: CalendarProps) => {
38+
const { days, isReferenceDate, isDateSelectable, buildDayWrapperClassName } = useCalendar({
39+
displayedMonthStartDate,
40+
onDayClick,
41+
});
4042
return (
4143
<div className="calendar-wrapper">
4244
<div className="calendar-anatomy">

ui-spacetimechart/src/stories/additional-data.stories.tsx

+12-8
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@ const CLOSED_DOORS = [
3636
},
3737
];
3838

39+
type MonoTrackSpaceProps = {
40+
from: number;
41+
to: number;
42+
};
43+
3944
/**
4045
* This component renders a colored area where the line only has one track:
4146
*/
42-
const MonoTrackSpace = ({ from, to }: { from: number; to: number }) => {
47+
const MonoTrackSpace = ({ from, to }: MonoTrackSpaceProps) => {
4348
const drawMonoTrackSpace = useCallback<DrawingFunction>(
4449
(ctx, { getSpacePixel, width, height, spaceAxis }) => {
4550
const spaceSize = spaceAxis === 'x' ? width : height;
@@ -159,16 +164,15 @@ const ClosedDoor = ({
159164
return null;
160165
};
161166

167+
type WrapperProps = {
168+
swapAxis: boolean;
169+
spaceScaleType: 'linear' | 'proportional';
170+
};
171+
162172
/**
163173
* This story aims at showcasing how to display additional data.
164174
*/
165-
const Wrapper = ({
166-
swapAxis,
167-
spaceScaleType,
168-
}: {
169-
swapAxis: boolean;
170-
spaceScaleType: 'linear' | 'proportional';
171-
}) => {
175+
const Wrapper = ({ swapAxis, spaceScaleType }: WrapperProps) => {
172176
const [state, setState] = useState<{
173177
xOffset: number;
174178
yOffset: number;

ui-spacetimechart/src/stories/base-rendering.stories.tsx

+7-11
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,18 @@ import { SpaceTimeChart, PathLayer } from '../';
88

99
import './lib/tailwind-mockup.css';
1010

11-
/**
12-
* This story aims at showcasing how to render a SpaceTimeChart.
13-
*/
14-
const Wrapper = ({
15-
xZoomLevel,
16-
yZoomLevel,
17-
xOffset,
18-
yOffset,
19-
spaceScaleType,
20-
}: {
11+
type WrapperProps = {
2112
xZoomLevel: number;
2213
yZoomLevel: number;
2314
xOffset: number;
2415
yOffset: number;
2516
spaceScaleType: 'linear' | 'proportional';
26-
}) => (
17+
};
18+
19+
/**
20+
* This story aims at showcasing how to render a SpaceTimeChart.
21+
*/
22+
const Wrapper = ({ xZoomLevel, yZoomLevel, xOffset, yOffset, spaceScaleType }: WrapperProps) => (
2723
<SpaceTimeChart
2824
className="inset-0 absolute"
2925
operationalPoints={OPERATIONAL_POINTS}

ui-spacetimechart/src/stories/custom-styles.stories.tsx

+7-10
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,17 @@ const DEFAULT_COLOR_1 = '#FF511A';
2222
const DEFAULT_COLOR_2 = '#FF8B61';
2323
const DEFAULT_COLOR_3 = '#FFEBE1';
2424

25-
/**
26-
* This story aims at showcasing how to customize inside styles.
27-
*/
28-
const Wrapper = ({
29-
color1,
30-
color2,
31-
color3,
32-
spaceScaleType,
33-
}: {
25+
type WrapperProps = {
3426
color1: string;
3527
color2: string;
3628
color3: string;
3729
spaceScaleType: 'linear' | 'proportional';
38-
}) => {
30+
};
31+
32+
/**
33+
* This story aims at showcasing how to customize inside styles.
34+
*/
35+
const Wrapper = ({ color1, color2, color3, spaceScaleType }: WrapperProps) => {
3936
const [state, setState] = useState<{
4037
xOffset: number;
4138
yOffset: number;

ui-spacetimechart/src/stories/measuring.stories.tsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ import { SpaceTimeChart, PathLayer } from '../';
1010
import { type DataPoint, type Point } from '../lib/types';
1111
import { getDiff } from '../utils/vectors';
1212

13+
type WrapperProps = {
14+
spaceScaleType: 'linear' | 'proportional';
15+
enableSnapping: boolean;
16+
};
17+
1318
/**
1419
* This story aims at showcasing how to measure times and distances in a SpaceTimeChart.
1520
*/
16-
const Wrapper = ({
17-
spaceScaleType,
18-
enableSnapping,
19-
}: {
20-
spaceScaleType: 'linear' | 'proportional';
21-
enableSnapping: boolean;
22-
}) => {
21+
const Wrapper = ({ spaceScaleType, enableSnapping }: WrapperProps) => {
2322
const [state, setState] = useState<{
2423
xOffset: number;
2524
yOffset: number;

ui-spacetimechart/src/stories/options.stories.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ const ScreenshotButton = () => {
4343
);
4444
};
4545

46+
type WrapperProps = {
47+
enableSnapping: boolean;
48+
hideGrid: boolean;
49+
hidePathsLabels: boolean;
50+
swapAxis: boolean;
51+
spaceScaleType: 'linear' | 'proportional';
52+
};
53+
4654
/**
4755
* This story aims at showcasing how to use various specific options in a
4856
* SpaceTimeChart, such as `swapAxis`, `enableSnapping`, `hideGrid` or
@@ -54,13 +62,7 @@ const Wrapper = ({
5462
hidePathsLabels,
5563
swapAxis,
5664
spaceScaleType,
57-
}: {
58-
enableSnapping: boolean;
59-
hideGrid: boolean;
60-
hidePathsLabels: boolean;
61-
swapAxis: boolean;
62-
spaceScaleType: 'linear' | 'proportional';
63-
}) => {
65+
}: WrapperProps) => {
6466
const [state, setState] = useState<{
6567
xOffset: number;
6668
yOffset: number;

ui-spacetimechart/src/stories/paths-interactions.stories.tsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ function delayPath<T extends PathData>(path: T, newTimeOrigin: number): T {
1919
points: path.points.map((point) => ({ ...point, time: point.time + delay })),
2020
};
2121
}
22+
type WrapperProps = {
23+
enableDragPaths: boolean;
24+
pickingTolerance: number;
25+
enableMultiSelection: boolean;
26+
spaceScaleType: 'linear' | 'proportional';
27+
};
2228

2329
/**
2430
* This story aims at showcasing how to manipulate paths in a SpaceTimeChart.
@@ -28,12 +34,7 @@ const Wrapper = ({
2834
pickingTolerance,
2935
enableMultiSelection,
3036
spaceScaleType,
31-
}: {
32-
enableDragPaths: boolean;
33-
enableMultiSelection: boolean;
34-
spaceScaleType: 'linear' | 'proportional';
35-
pickingTolerance: number;
36-
}) => {
37+
}: WrapperProps) => {
3738
const [paths, setPaths] = useState(PATHS);
3839
const pathsDict = useMemo(() => keyBy(paths, 'id'), [paths]);
3940
const [state, setState] = useState<{

ui-spacetimechart/src/stories/performances.stories.tsx

+8-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ const COLORS = [
2727
'#FF9BC6',
2828
];
2929

30+
type WrapperProps = {
31+
operationalPointsCount: number;
32+
trainTypes: number;
33+
pathsPerTrain: number;
34+
spaceScaleType: 'linear' | 'proportional';
35+
};
36+
3037
/**
3138
* This story aims at testing the performances of the SpaceTimeChart component when rendering a
3239
* high number of paths.
@@ -36,12 +43,7 @@ const Wrapper = ({
3643
trainTypes,
3744
pathsPerTrain,
3845
spaceScaleType,
39-
}: {
40-
operationalPointsCount: number;
41-
trainTypes: number;
42-
pathsPerTrain: number;
43-
spaceScaleType: 'linear' | 'proportional';
44-
}) => {
46+
}: WrapperProps) => {
4547
const operationalPoints: OperationalPoint[] = useMemo(() => {
4648
let position = 0;
4749
return range(operationalPointsCount).map((i) => ({

ui-spacetimechart/src/stories/scroll-navigation.stories.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ import './lib/tailwind-mockup.css';
1616

1717
const PATHS_DICT = keyBy(PATHS, 'id');
1818

19+
type WrapperProps = {
20+
spaceScaleType: 'linear' | 'proportional';
21+
};
22+
1923
/**
2024
* This story aims at showcasing how to implement a different kind of navigation, where the mouse
2125
* wheel moves the time axis, and where a selected path must remain focused as much as possible.
2226
*/
23-
const Wrapper = ({ spaceScaleType }: { spaceScaleType: 'linear' | 'proportional' }) => {
27+
const Wrapper = ({ spaceScaleType }: WrapperProps) => {
2428
const [state, setState] = useState<{
2529
xOffset: number;
2630
yOffset: number;

ui-spacetimechart/src/stories/stage-interactions.stories.tsx

+7-11
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,18 @@ import { getDiff } from '../utils/vectors';
1818

1919
import './lib/tailwind-mockup.css';
2020

21-
/**
22-
* This story aims at showcasing how to handle panning and zooming in a SpaceTimeChart.
23-
*/
24-
const Wrapper = ({
25-
xPan,
26-
yPan,
27-
xZoom,
28-
yZoom,
29-
spaceScaleType,
30-
}: {
21+
type WrapperProps = {
3122
xPan: boolean;
3223
yPan: boolean;
3324
xZoom: boolean;
3425
yZoom: boolean;
3526
spaceScaleType: 'linear' | 'proportional';
36-
}) => {
27+
};
28+
29+
/**
30+
* This story aims at showcasing how to handle panning and zooming in a SpaceTimeChart.
31+
*/
32+
const Wrapper = ({ xPan, yPan, xZoom, yZoom, spaceScaleType }: WrapperProps) => {
3733
const [state, setState] = useState<{
3834
xOffset: number;
3935
yOffset: number;

ui-warped-map/src/components/BaseMap.tsx

+7-10
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@ import ReactMapGL, { Layer, type LayerProps, type MapRef, Source } from 'react-m
99

1010
import { type SourceDefinition } from '../core/types';
1111

12-
/**
13-
* This component is for testing purpose only. It displays data as they appear in the DataLoader component.
14-
*/
15-
const BaseMap = ({
16-
path,
17-
mapStyle,
18-
sources,
19-
children,
20-
}: PropsWithChildren<{
12+
type BaseMapProps = {
2113
path: Feature<LineString>;
2214
sources: SourceDefinition[];
2315
mapStyle?: string | StyleSpecification;
24-
}>) => {
16+
};
17+
18+
/**
19+
* This component is for testing purpose only. It displays data as they appear in the DataLoader component.
20+
*/
21+
const BaseMap = ({ path, mapStyle, sources, children }: PropsWithChildren<BaseMapProps>) => {
2522
const [mapRef, setMapRef] = useState<MapRef | null>(null);
2623
const interactiveLayerIds = useMemo(
2724
() => sources.flatMap(({ layers }) => layers.map(({ id }) => id)),

ui-warped-map/src/components/DataLoader.tsx

+10-15
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,23 @@ import { type SourceDefinition } from '../core/types';
1212

1313
const TIME_LABEL = 'Loading data around warped path';
1414

15+
type DataLoaderProps = {
16+
bbox: BBox2d;
17+
mapStyle?: string | StyleSpecification;
18+
onDataLoaded: (sourcesData: Record<string, FeatureCollection>) => void;
19+
sources: SourceDefinition[];
20+
timeout?: number;
21+
log?: boolean;
22+
};
23+
1524
/**
1625
* This component handles loading entities from MapLibre vector servers, and retrieving them as GeoJSONs from the
1726
* MapLibre `querySourceFeatures` method. It's quite dirty (it has to mount a map in the DOM, but somewhere it won't be
1827
* visible), but necessary until we get proper APIs for any sources.
1928
*
2029
* It is designed as a component instead of a hook to simplify mounting/unmounting the temporary invisible map.
2130
*/
22-
const DataLoader = ({
23-
bbox,
24-
mapStyle,
25-
onDataLoaded,
26-
sources,
27-
timeout,
28-
log,
29-
}: {
30-
bbox: BBox2d;
31-
mapStyle?: string | StyleSpecification;
32-
onDataLoaded: (sourcesData: Record<string, FeatureCollection>) => void;
33-
sources: SourceDefinition[];
34-
timeout?: number;
35-
log?: boolean;
36-
}) => {
31+
const DataLoader = ({ bbox, mapStyle, onDataLoaded, sources, timeout, log }: DataLoaderProps) => {
3732
const [mapRef, setMapRef] = useState<MapRef | null>(null);
3833
const [state, setState] = useState<'idle' | 'render' | 'loaded'>('idle');
3934

ui-warped-map/src/components/TransformedDataMap.tsx

+12-10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ import ReactMapGL, {
1515

1616
import { type SourceDefinition } from '../core/types';
1717

18+
type TransformedDataMapProps = {
19+
bbox: BBox2d;
20+
mapStyle?: string | StyleSpecification;
21+
backgroundColor?: string;
22+
sources: SourceDefinition[];
23+
transformedData: Record<string, FeatureCollection>;
24+
path?: Feature<LineString>;
25+
pathLayer?: Omit<LineLayer, 'source-layer'>;
26+
log?: boolean;
27+
};
28+
1829
/**
1930
* This component handles displaying warped data. The data must be warped before being given to this component.
2031
* Check `SimulationWarpedMap` to see an example use case.
@@ -29,16 +40,7 @@ const TransformedDataMap = ({
2940
pathLayer,
3041
log,
3142
children,
32-
}: PropsWithChildren<{
33-
bbox: BBox2d;
34-
mapStyle?: string | StyleSpecification;
35-
backgroundColor?: string;
36-
sources: SourceDefinition[];
37-
transformedData: Record<string, FeatureCollection>;
38-
path?: Feature<LineString>;
39-
pathLayer?: Omit<LineLayer, 'source-layer'>;
40-
log?: boolean;
41-
}>) => {
43+
}: PropsWithChildren<TransformedDataMapProps>) => {
4244
const [mapRef, setMapRef] = useState<MapRef | null>(null);
4345
const pathCollection = useMemo(() => featureCollection(path ? [path] : []), [path]);
4446
const interactiveLayerIds = useMemo(

0 commit comments

Comments
 (0)