-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6464720
commit b20fa35
Showing
7 changed files
with
283 additions
and
25 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
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
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
86 changes: 86 additions & 0 deletions
86
ui-manchette-with-spacetimechart/src/stories/rectangle-zoom.stories.tsx
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import React, { useRef } from 'react'; | ||
|
||
import Manchette, { type ProjectPathTrainResult, type Waypoint } from '@osrd-project/ui-manchette'; | ||
import { PathLayer, SpaceTimeChart, RectangleZoom } from '@osrd-project/ui-spacetimechart'; | ||
import type { Meta } from '@storybook/react'; | ||
|
||
import '@osrd-project/ui-core/dist/theme.css'; | ||
import '@osrd-project/ui-manchette/dist/theme.css'; | ||
import '@osrd-project/ui-manchette-with-spacetimechart/dist/theme.css'; | ||
import '../styles/stories/rectangle-zoom.css'; | ||
|
||
import { SAMPLE_WAYPOINTS, SAMPLE_PATHS_DATA } from '../assets/sampleData'; | ||
import useManchettesWithSpaceTimeChart from '../hooks/useManchetteWithSpaceTimeChart'; | ||
import { ZoomIn } from '@osrd-project/ui-icons'; | ||
|
||
type ManchetteWithSpaceTimeWrapperProps = { | ||
waypoints: Waypoint[]; | ||
projectPathTrainResult: ProjectPathTrainResult[]; | ||
selectedTrain: number; | ||
}; | ||
|
||
const DEFAULT_HEIGHT = 561; | ||
|
||
const ManchetteWithSpaceTimeWrapper = ({ | ||
waypoints, | ||
projectPathTrainResult, | ||
selectedTrain, | ||
}: ManchetteWithSpaceTimeWrapperProps) => { | ||
const manchetteWithSpaceTimeChartRef = useRef<HTMLDivElement>(null); | ||
|
||
const { manchetteProps, spaceTimeChartProps, handleScroll, toggleZoomMode, zoomMode } = | ||
useManchettesWithSpaceTimeChart( | ||
waypoints, | ||
projectPathTrainResult, | ||
manchetteWithSpaceTimeChartRef, | ||
selectedTrain | ||
); | ||
|
||
return ( | ||
<div className="manchette-space-time-chart-wrapper"> | ||
<div | ||
className="header bg-ambientB-5 w-full border-b border-grey-30" | ||
style={{ height: '40px' }} | ||
></div> | ||
<div | ||
ref={manchetteWithSpaceTimeChartRef} | ||
className="manchette flex" | ||
style={{ height: `${DEFAULT_HEIGHT}px` }} | ||
onScroll={handleScroll} | ||
> | ||
<Manchette {...manchetteProps} /> | ||
<div | ||
className="space-time-chart-container w-full sticky" | ||
style={{ bottom: 0, left: 0, top: 2, height: `${DEFAULT_HEIGHT - 6}px` }} | ||
> | ||
<div className="toolbar"> | ||
<button type="button" className="menu-button" onClick={toggleZoomMode}> | ||
<ZoomIn /> | ||
</button> | ||
</div> | ||
<SpaceTimeChart className="inset-0 absolute h-full" {...spaceTimeChartProps}> | ||
{spaceTimeChartProps.paths.map((path) => ( | ||
<PathLayer key={path.id} path={path} color={path.color} level={path.level} /> | ||
))} | ||
{spaceTimeChartProps.rect && <RectangleZoom rect={spaceTimeChartProps.rect} />} | ||
</SpaceTimeChart> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
const meta: Meta<typeof ManchetteWithSpaceTimeWrapper> = { | ||
title: 'Manchette with SpaceTimeChart/Zoom rectangle', | ||
component: ManchetteWithSpaceTimeWrapper, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default = { | ||
args: { | ||
waypoints: SAMPLE_WAYPOINTS, | ||
projectPathTrainResult: SAMPLE_PATHS_DATA, | ||
selectedTrain: 1, | ||
}, | ||
}; |
Oops, something went wrong.