-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathManchette.tsx
70 lines (64 loc) · 2 KB
/
Manchette.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React from 'react';
import { ZoomIn, ZoomOut } from '@osrd-project/ui-icons';
import cx from 'classnames';
import { INITIAL_OP_LIST_HEIGHT, MAX_ZOOM_Y, MIN_ZOOM_Y } from './consts';
import OperationalPointList from './OperationalPointList';
import type { StyledOperationalPointType } from '../types';
type ManchetteProps = {
operationalPoints: StyledOperationalPointType[];
activeOperationalPointId?: string;
zoomYIn: () => void;
zoomYOut: () => void;
resetZoom: () => void;
height?: number;
yZoom?: number;
children?: React.ReactNode;
isProportional?: boolean;
toggleMode: () => void;
};
const Manchette = ({
zoomYIn,
zoomYOut,
resetZoom,
yZoom = 1,
operationalPoints,
activeOperationalPointId,
isProportional = true,
toggleMode,
children,
}: ManchetteProps) => (
<div className="manchette-container">
<div
className="bg-ambientB-10 border-r border-grey-30"
style={{ minHeight: `${INITIAL_OP_LIST_HEIGHT}px` }}
>
<OperationalPointList
operationalPoints={operationalPoints}
activeOperationalPointId={activeOperationalPointId}
/>
{children}
</div>
<div className="manchette-actions">
<div className="zoom-buttons">
<button className="zoom-out" onClick={zoomYOut} disabled={yZoom <= MIN_ZOOM_Y}>
<ZoomOut />
</button>
<button className="zoom-in" onClick={zoomYIn} disabled={yZoom >= MAX_ZOOM_Y}>
<ZoomIn />
</button>
<button className="zoom-reset" onClick={resetZoom}>
Fit
</button>
</div>
<div className="flex items-center ml-auto text-sans font-semibold">
<button className="toggle-mode" onClick={toggleMode}>
<div className="flex flex-col items-end pr-2">
<span className={cx({ 'text-grey-30': !isProportional })}>Km</span>
<span className={cx({ 'text-grey-30': isProportional })}>Linéaire</span>
</div>
</button>
</div>
</div>
</div>
);
export default Manchette;