-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
front: add a new util function to determine the style of an hovered path
Signed-off-by: Math_R_ <[email protected]>
- Loading branch information
Showing
3 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
front/src/modules/simulationResult/components/ManchetteWithSpaceTimeChart/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,18 @@ | ||
import type { PathLevel } from '@osrd-project/ui-spacetimechart'; | ||
import type { HoveredItem } from '@osrd-project/ui-spacetimechart/dist/lib/types'; | ||
|
||
import { PATH_COLORS } from 'modules/simulationResult/consts'; | ||
|
||
/* eslint-disable import/prefer-default-export */ | ||
export const getIdFromTrainPath = (trainPath: string): number => +trainPath.split('-')[0]; | ||
|
||
export const getPathStyle = ( | ||
hovered: HoveredItem | null, | ||
path: { color: string; id: string }, | ||
dragging: boolean | ||
): { color: string; level?: PathLevel } => { | ||
if (hovered && 'pathId' in hovered.element && path.id === hovered?.element.pathId && !dragging) { | ||
return { color: PATH_COLORS.HOVERED_PATH, level: 1 }; | ||
} | ||
return { color: path.color }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters