Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slider #9907

Merged
merged 1 commit into from
Jan 9, 2025
Merged

Slider #9907

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 29 additions & 62 deletions front/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
"@osrd-project/netzgrafik-frontend": "0.0.0-snapshot.37949a66933e8e1552c9b8e54f702ec491afd415",
"@osrd-project/ui-core": "^0.0.61",
"@osrd-project/ui-icons": "^0.0.59",
"@osrd-project/ui-manchette": "^0.0.59",
"@osrd-project/ui-manchette-with-spacetimechart": "^0.0.59",
"@osrd-project/ui-spacetimechart": "^0.0.59",
"@osrd-project/ui-icons": "^0.0.61",
"@osrd-project/ui-manchette": "^0.0.61",
"@osrd-project/ui-manchette-with-spacetimechart": "^0.0.61",
"@osrd-project/ui-spacetimechart": "^0.0.61",
"@osrd-project/ui-speedspacechart": "^0.0.59",
"@react-pdf/renderer": "^4.1.6",
"@redux-devtools/extension": "^3.3.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { useMemo, useRef, useState } from 'react';

import { KebabHorizontal } from '@osrd-project/ui-icons';
import { Slider } from '@osrd-project/ui-core';
import { KebabHorizontal, Iterations } from '@osrd-project/ui-icons';
import Manchette, { type WaypointMenuData } from '@osrd-project/ui-manchette';
import { useManchettesWithSpaceTimeChart } from '@osrd-project/ui-manchette-with-spacetimechart';
import {
useManchettesWithSpaceTimeChart,
timeScaleToZoomValue,
DEFAULT_ZOOM_MS_PER_PX,
} from '@osrd-project/ui-manchette-with-spacetimechart';
import {
ConflictLayer,
PathLayer,
Expand Down Expand Up @@ -63,6 +68,7 @@ const ManchetteWithSpaceTimeChartWrapper = ({
}: ManchetteWithSpaceTimeChartProps) => {
const manchetteWithSpaceTimeCharWrappertRef = useRef<HTMLDivElement>(null);
const manchetteWithSpaceTimeChartRef = useRef<HTMLDivElement>(null);
const spaceTimeChartRef = useRef<HTMLDivElement>(null);

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

Expand Down Expand Up @@ -159,13 +165,15 @@ const ManchetteWithSpaceTimeChartWrapper = ({
}));
}, [waypointsPanelData, operationalPoints]);

const { manchetteProps, spaceTimeChartProps, handleScroll } = useManchettesWithSpaceTimeChart(
manchetteWaypoints,
cutProjectedTrains,
manchetteWithSpaceTimeChartRef,
selectedTrainScheduleId,
height
);
const { manchetteProps, spaceTimeChartProps, handleScroll, handleXZoom, xZoom } =
useManchettesWithSpaceTimeChart(
manchetteWaypoints,
cutProjectedTrains,
manchetteWithSpaceTimeChartRef,
selectedTrainScheduleId,
height,
spaceTimeChartRef
);

const [showSettingsPanel, setShowSettingsPanel] = useState(false);
const [settings, setSettings] = useState({
Expand Down Expand Up @@ -251,6 +259,7 @@ const ManchetteWithSpaceTimeChartWrapper = ({
>
<Manchette {...manchettePropsWithWaypointMenu} height={height - BOTTOM_TOOLBAR_HEIGHT} />
<div
ref={spaceTimeChartRef}
className="space-time-chart-container"
style={{
bottom: 0,
Expand All @@ -260,7 +269,18 @@ const ManchetteWithSpaceTimeChartWrapper = ({
}}
>
<div className="toolbar">
<button type="button" onClick={() => setShowSettingsPanel(true)}>
<button
type="button"
className="reset-button"
onClick={() => handleXZoom(timeScaleToZoomValue(DEFAULT_ZOOM_MS_PER_PX))}
>
<Iterations />
</button>
<button
type="button"
className="menu-button"
onClick={() => setShowSettingsPanel(true)}
>
<KebabHorizontal />
</button>
</div>
Expand Down Expand Up @@ -301,7 +321,16 @@ const ManchetteWithSpaceTimeChartWrapper = ({
</SpaceTimeChart>
</div>
</div>
<Slider
containerClassName="space-time-h-slider-container"
className="space-time-h-slider"
value={xZoom}
onChange={(e) => {
handleXZoom(Number(e.target.value));
}}
/>
</div>
/* TODO use margin or absolute to align with handle */
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,36 @@
right: 7px;
top: 7px;
z-index: 10;
border: 1px solid var(--black10);
border-radius: 5px;

button {
border: 1px solid var(--black10);
border-radius: 5px;
outline: none;
background: var(--white100);
color: var(--black100);
padding: 0 7px;
}

button:not(:last-child) {
border-radius: 5px 0 0 5px;
border-right: 1px solid var(--black10);
}

button:last-child {
border-radius: 5px;
}

.reset-button {
svg {
transform: rotate(180deg) translate(0, 2px);
}
}

.menu-button {
svg {
transform: translate(0, -1px);
}
}
}

.settings-panel {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.manchette-space-time-chart-wrapper {
width: 100%;
border-radius: 10px;
box-shadow:
0 4px 9px rgba(0, 0, 0, 0.06),
Expand Down Expand Up @@ -53,4 +54,11 @@
width: 100%;
position: sticky;
}

.space-time-h-slider-container {
position: absolute;
right: 24px;
bottom: -21px;
z-index: 10;
}
}
Loading