Skip to content

Commit e34af20

Browse files
committed
fixup! ui-manchette: highlight selected train
1 parent 709b932 commit e34af20

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

ui-manchette/src/components/Manchette.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { useIsOverflow } from '../hooks/useIsOverFlow';
2323
type ManchetteProps = {
2424
operationalPoints: OperationalPointType[];
2525
projectPathTrainResult: ProjectPathTrainResult[];
26-
selectedProjection: number;
26+
selectedProjection?: number;
2727
};
2828
import usePaths from '../hooks/usePaths';
2929
import type {

ui-manchette/src/hooks/usePaths.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ const transformCurve = (curve: SpaceTimeCurves, departureTime: string) =>
88
position,
99
}));
1010

11-
const usePaths = (projectPathTrainResult: ProjectPathTrainResult[], selectedProjection: number) => {
11+
const usePaths = (
12+
projectPathTrainResult: ProjectPathTrainResult[],
13+
selectedProjection?: number
14+
) => {
1215
return useMemo(() => {
1316
return projectPathTrainResult.map((path) => ({
1417
id: `${path.id}`,
1518
label: path.name,
16-
color: selectedProjection === path.id ? '#201EDE' : '#000000',
19+
color: selectedProjection && selectedProjection === path.id ? '#201EDE' : '#000000',
1720
points: path.space_time_curves.flatMap((curve) => transformCurve(curve, path.departure_time)),
1821
}));
1922
}, [projectPathTrainResult, selectedProjection]);

ui-manchette/src/stories/Manchette.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const meta: Meta<typeof Manchette> = {
2424
},
2525
},
2626
selectedProjection: {
27-
options: SAMPLE_PATHS_DATA.map((path) => path.id),
27+
options: [undefined, ...SAMPLE_PATHS_DATA.map((path) => path.id)],
2828
control: {
2929
type: 'select',
3030
},

0 commit comments

Comments
 (0)