Skip to content

Commit 6ad1af5

Browse files
committed
front: space time horizontal zoom with slider
Signed-off-by: Valentin Chanas <anisometropie@gmail.com>
1 parent 18e4c0d commit 6ad1af5

File tree

2 files changed

+91
-57
lines changed

2 files changed

+91
-57
lines changed

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

+34-9
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,
@@ -50,6 +55,7 @@ type ManchetteWithSpaceTimeChartProps = {
5055
export const MANCHETTE_WITH_SPACE_TIME_CHART_DEFAULT_HEIGHT = 561;
5156
const BOTTOM_TOOLBAR_HEIGHT = 40;
5257
const SPACE_TIME_CHART_DIFF_HEIGHT = 8;
58+
const DEFAULT_ZOOM_MS_PER_PX = 7500;
5359

5460
const ManchetteWithSpaceTimeChartWrapper = ({
5561
operationalPoints,
@@ -63,6 +69,7 @@ const ManchetteWithSpaceTimeChartWrapper = ({
6369
}: ManchetteWithSpaceTimeChartProps) => {
6470
const manchetteWithSpaceTimeCharWrappertRef = useRef<HTMLDivElement>(null);
6571
const manchetteWithSpaceTimeChartRef = useRef<HTMLDivElement>(null);
72+
const spaceTimeChartRef = useRef<HTMLDivElement>(null);
6673

6774
const [waypointsPanelIsOpen, setWaypointsPanelIsOpen] = useState(false);
6875

@@ -159,13 +166,15 @@ const ManchetteWithSpaceTimeChartWrapper = ({
159166
}));
160167
}, [waypointsPanelData, operationalPoints]);
161168

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

170179
const [showSettingsPanel, setShowSettingsPanel] = useState(false);
171180
const [settings, setSettings] = useState({
@@ -251,6 +260,7 @@ const ManchetteWithSpaceTimeChartWrapper = ({
251260
>
252261
<Manchette {...manchettePropsWithWaypointMenu} height={height - BOTTOM_TOOLBAR_HEIGHT} />
253262
<div
263+
ref={spaceTimeChartRef}
254264
className="space-time-chart-container"
255265
style={{
256266
bottom: 0,
@@ -260,6 +270,12 @@ const ManchetteWithSpaceTimeChartWrapper = ({
260270
}}
261271
>
262272
<div className="toolbar">
273+
<button
274+
type="button"
275+
onClick={() => handleXZoom(timeScaleToZoomValue(DEFAULT_ZOOM_MS_PER_PX))}
276+
>
277+
<Iterations />
278+
</button>
263279
<button type="button" onClick={() => setShowSettingsPanel(true)}>
264280
<KebabHorizontal />
265281
</button>
@@ -301,7 +317,16 @@ const ManchetteWithSpaceTimeChartWrapper = ({
301317
</SpaceTimeChart>
302318
</div>
303319
</div>
320+
<Slider
321+
containerClassName="space-time-h-slider-container"
322+
className="space-time-h-slider"
323+
value={xZoom}
324+
onChange={(e) => {
325+
handleXZoom(Number(e.target.value));
326+
}}
327+
/>
304328
</div>
329+
/* TODO use margin or absolute to align with handle */
305330
);
306331
};
307332

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

+57-48
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,65 @@
1-
.manchette-space-time-chart-wrapper {
2-
border-radius: 10px;
3-
box-shadow:
4-
0 4px 9px rgba(0, 0, 0, 0.06),
5-
0 1px 2px rgba(0, 0, 0, 0.19);
6-
background-color: var(--white100);
7-
position: relative;
8-
9-
.header {
1+
.manchette-space-time-chart-wrapper {
2+
width: 100%;
3+
border-radius: 10px;
4+
box-shadow:
5+
0 4px 9px rgba(0, 0, 0, 0.06),
6+
0 1px 2px rgba(0, 0, 0, 0.19);
7+
background-color: var(--white100);
108
position: relative;
11-
height: 40px;
12-
border-radius: 10px 10px 0 0;
13-
box-shadow: inset 0 1px 0 var(--white100);
14-
padding: 4px;
15-
background-color: var(--ambiantB5);
16-
border-bottom: 1px solid var(--black25);
17-
18-
.manchette-menu-button {
19-
border-radius: 8px;
20-
width: 40px;
21-
height: 32px;
22-
margin-bottom: -8px;
23-
24-
&:hover {
25-
background-color: var(--black10);
9+
10+
.header {
11+
position: relative;
12+
height: 40px;
13+
border-radius: 10px 10px 0 0;
14+
box-shadow: inset 0 1px 0 var(--white100);
15+
padding: 4px;
16+
background-color: var(--ambiantB5);
17+
border-bottom: 1px solid var(--black25);
18+
19+
.manchette-menu-button {
20+
border-radius: 8px;
21+
width: 40px;
22+
height: 32px;
23+
margin-bottom: -8px;
24+
25+
&:hover {
26+
background-color: var(--black10);
27+
}
28+
29+
&.menu-open {
30+
background-color: var(--black5);
31+
}
2632
}
27-
28-
&.menu-open {
29-
background-color: var(--black5);
33+
}
34+
.header-separator {
35+
height: 1px;
36+
background-color: var(--white100);
37+
}
38+
39+
.manchette {
40+
overflow-y: auto;
41+
overflow-x: hidden;
42+
43+
&.no-scroll {
44+
overflow-y: clip;
45+
}
46+
47+
.osrd-menu {
48+
width: 305px;
49+
transform: translateY(-2px);
3050
}
3151
}
32-
}
33-
.header-separator {
34-
height: 1px;
35-
background-color: var(--white100);
36-
}
37-
38-
.manchette {
39-
overflow-y: auto;
40-
overflow-x: hidden;
41-
42-
&.no-scroll {
43-
overflow-y: clip;
52+
53+
.space-time-chart-container {
54+
width: 100%;
55+
position: sticky;
4456
}
4557

46-
.osrd-menu {
47-
width: 305px;
48-
transform: translateY(-2px);
49-
}
50-
}
58+
.space-time-h-slider-container {
5159

52-
.space-time-chart-container {
53-
width: 100%;
54-
position: sticky;
60+
position: absolute;
61+
right: 10px;
62+
bottom: -21px;
63+
z-index: 10;
64+
}
5565
}
56-
}

0 commit comments

Comments
 (0)