Skip to content

Commit 38f11bd

Browse files
committed
front: space time horizontal zoom with slider
Signed-off-by: Valentin Chanas <anisometropie@gmail.com>
1 parent fdfd8ac commit 38f11bd

File tree

5 files changed

+104
-78
lines changed

5 files changed

+104
-78
lines changed

front/package-lock.json

+29-62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
1010
"@osrd-project/netzgrafik-frontend": "0.0.0-snapshot.37949a66933e8e1552c9b8e54f702ec491afd415",
1111
"@osrd-project/ui-core": "^0.0.61",
12-
"@osrd-project/ui-icons": "^0.0.59",
13-
"@osrd-project/ui-manchette": "^0.0.59",
14-
"@osrd-project/ui-manchette-with-spacetimechart": "^0.0.59",
15-
"@osrd-project/ui-spacetimechart": "^0.0.59",
12+
"@osrd-project/ui-icons": "^0.0.61",
13+
"@osrd-project/ui-manchette": "^0.0.61",
14+
"@osrd-project/ui-manchette-with-spacetimechart": "^0.0.61",
15+
"@osrd-project/ui-spacetimechart": "^0.0.61",
1616
"@osrd-project/ui-speedspacechart": "^0.0.59",
1717
"@react-pdf/renderer": "^4.1.6",
1818
"@redux-devtools/extension": "^3.3.0",

front/src/modules/simulationResult/components/ManchetteWithSpaceTimeChart/ManchetteWithSpaceTimeChart.tsx

+39-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { useMemo, useRef, useState } from 'react';
22

3-
import { KebabHorizontal } from '@osrd-project/ui-icons';
3+
import { Slider } from '@osrd-project/ui-core';
4+
import { KebabHorizontal, Iterations } from '@osrd-project/ui-icons';
45
import Manchette, { type WaypointMenuData } from '@osrd-project/ui-manchette';
5-
import { useManchettesWithSpaceTimeChart } from '@osrd-project/ui-manchette-with-spacetimechart';
6+
import {
7+
useManchettesWithSpaceTimeChart,
8+
timeScaleToZoomValue,
9+
DEFAULT_ZOOM_MS_PER_PX,
10+
} from '@osrd-project/ui-manchette-with-spacetimechart';
611
import {
712
ConflictLayer,
813
PathLayer,
@@ -63,6 +68,7 @@ const ManchetteWithSpaceTimeChartWrapper = ({
6368
}: ManchetteWithSpaceTimeChartProps) => {
6469
const manchetteWithSpaceTimeCharWrappertRef = useRef<HTMLDivElement>(null);
6570
const manchetteWithSpaceTimeChartRef = useRef<HTMLDivElement>(null);
71+
const spaceTimeChartRef = useRef<HTMLDivElement>(null);
6672

6773
const [waypointsPanelIsOpen, setWaypointsPanelIsOpen] = useState(false);
6874

@@ -159,13 +165,15 @@ const ManchetteWithSpaceTimeChartWrapper = ({
159165
}));
160166
}, [waypointsPanelData, operationalPoints]);
161167

162-
const { manchetteProps, spaceTimeChartProps, handleScroll } = useManchettesWithSpaceTimeChart(
163-
manchetteWaypoints,
164-
cutProjectedTrains,
165-
manchetteWithSpaceTimeChartRef,
166-
selectedTrainScheduleId,
167-
height
168-
);
168+
const { manchetteProps, spaceTimeChartProps, handleScroll, handleXZoom, xZoom } =
169+
useManchettesWithSpaceTimeChart(
170+
manchetteWaypoints,
171+
cutProjectedTrains,
172+
manchetteWithSpaceTimeChartRef,
173+
selectedTrainScheduleId,
174+
height,
175+
spaceTimeChartRef
176+
);
169177

170178
const [showSettingsPanel, setShowSettingsPanel] = useState(false);
171179
const [settings, setSettings] = useState({
@@ -251,6 +259,7 @@ const ManchetteWithSpaceTimeChartWrapper = ({
251259
>
252260
<Manchette {...manchettePropsWithWaypointMenu} height={height - BOTTOM_TOOLBAR_HEIGHT} />
253261
<div
262+
ref={spaceTimeChartRef}
254263
className="space-time-chart-container"
255264
style={{
256265
bottom: 0,
@@ -260,7 +269,18 @@ const ManchetteWithSpaceTimeChartWrapper = ({
260269
}}
261270
>
262271
<div className="toolbar">
263-
<button type="button" onClick={() => setShowSettingsPanel(true)}>
272+
<button
273+
type="button"
274+
className="reset-button"
275+
onClick={() => handleXZoom(timeScaleToZoomValue(DEFAULT_ZOOM_MS_PER_PX))}
276+
>
277+
<Iterations />
278+
</button>
279+
<button
280+
type="button"
281+
className="menu-button"
282+
onClick={() => setShowSettingsPanel(true)}
283+
>
264284
<KebabHorizontal />
265285
</button>
266286
</div>
@@ -301,7 +321,16 @@ const ManchetteWithSpaceTimeChartWrapper = ({
301321
</SpaceTimeChart>
302322
</div>
303323
</div>
324+
<Slider
325+
containerClassName="space-time-h-slider-container"
326+
className="space-time-h-slider"
327+
value={xZoom}
328+
onChange={(e) => {
329+
handleXZoom(Number(e.target.value));
330+
}}
331+
/>
304332
</div>
333+
/* TODO use margin or absolute to align with handle */
305334
);
306335
};
307336

front/src/modules/simulationResult/styles/manchetteWithSpaceTimeChart.scss

+24-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,36 @@
1111
right: 7px;
1212
top: 7px;
1313
z-index: 10;
14+
border: 1px solid var(--black10);
15+
border-radius: 5px;
1416

1517
button {
16-
border: 1px solid var(--black10);
17-
border-radius: 5px;
18+
outline: none;
1819
background: var(--white100);
1920
color: var(--black100);
2021
padding: 0 7px;
2122
}
23+
24+
button:not(:last-child) {
25+
border-radius: 5px 0 0 5px;
26+
border-right: 1px solid var(--black10);
27+
}
28+
29+
button:last-child {
30+
border-radius: 5px;
31+
}
32+
33+
.reset-button {
34+
svg {
35+
transform: rotate(180deg) translate(0, 2px);
36+
}
37+
}
38+
39+
.menu-button {
40+
svg {
41+
transform: translate(0, -1px);
42+
}
43+
}
2244
}
2345

2446
.settings-panel {

front/src/styles/scss/common/components/_manchetteWithSpaceTimeChart.scss

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.manchette-space-time-chart-wrapper {
2+
width: 100%;
23
border-radius: 10px;
34
box-shadow:
45
0 4px 9px rgba(0, 0, 0, 0.06),
@@ -53,4 +54,11 @@
5354
width: 100%;
5455
position: sticky;
5556
}
57+
58+
.space-time-h-slider-container {
59+
position: absolute;
60+
right: 24px;
61+
bottom: -21px;
62+
z-index: 10;
63+
}
5664
}

0 commit comments

Comments
 (0)